Skip to content

Latest commit

 

History

History
58 lines (36 loc) · 1.75 KB

SimplifyTheCommentModel.md

File metadata and controls

58 lines (36 loc) · 1.75 KB

Simplify the Comment-Model

Let's assume only authenticated Frontend-Users care allowed to create comments.. so we can remove the obsolete NodeData Properties and load the Data directly form the Users.

Remove the Properties from the NodeType and Inspector Section

Vendor.Blog/Configuration/NodeTypes.Comment.yaml

'WebExcess.Comments:Comment':
	properties:
		firstname: null
		lastname: null
		email: null

Create a custom Comment-Model which includes the new Property

Vendor.Blog/Classes/Vendor/Blog/Domain/Model/Comment.php

<?php

namespace Vendor\Blog\Domain\Model;

use Neos\Flow\Annotations as Flow;
use WebExcess\Comments\Domain\Model\CommentAbstract;
use WebExcess\Comments\Domain\Model\CommentInterface;

class Comment extends CommentAbstract implements CommentInterface
{
	// Override loadNodeData(..) an loadAccountDataIfAuthenticated() if needed..
}

Replace the original Comment-Model with your version

Vendor.Blog/Classes/Vendor/Blog/Configuration/Objects.yaml

WebExcess\Comments\Domain\Model\CommentInterface:
	className: 'Vendor\Blog\Domain\Model\Comment'

Point to your custom Templates

Vendor.Blog/Configuration/Views.yaml

-
	requestFilter: 'isPackage("WebExcess.Comments") && isController("Comments")'
	options:
		templatePathAndFilename: 'resource://Vendor.Blog/Private/Templates/Comments/Index.html'

Copy the Base-Template and remove unused Form-Fields

Vendor.Blog/Resources/Private/Templates/Comments/Index.html

<!-- ... -->

Result

Now your Blog-Package is using webexcess/comments and does not store Commenter-Data twice.

Without breaking forking the original Package itself.