-
-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Domain structure content blocks #2096
Domain structure content blocks #2096
Conversation
Isn't moving everything into a Domain folder (with only Command, Event and Exception in it's own folder) making it more complicated to see what is what? Instead of clear folder names Command, DBALType, Entity, Form, Repository? |
@jeroendesloovere I think in this case I would keep the action classes the same as they are in fork 4 apart from that I agree with your points. |
@jonasdekeukelaere It makes more sense to group all things related to the entity in one parent namespace and separate that from the structure of the cms If you have a category and a post for instance just adding everything in repository is the wrong approach imho (and also others) since you are grouping it wrong, The repository of the category has nothing to do with the repository of the post. The reason I am for this is because this is a way simpler module so it is easier to point to then a more complex module like the media library. The structure should be consistent |
For me it's more clearer to have (for example) all repositories, (or all Form types) in a folder together than have all those classes in 1 folder under Domain. Then you know directly what each class is suppose to do. But that sounds too easy maybe. |
@jeroendesloovere I usually point to https://github.com/sumocoders/fork-partners/tree/master/src/Backend/Modules/Partners since it is a rather simple module. I also just used add edit delete there because it made sense |
@jonasdekeukelaere no need to get passive aggressive |
For example the partners module, you have everything in this 1 folder https://github.com/sumocoders/fork-partners/tree/master/src/Backend/Modules/Partners/Domain/Partner - doesn't look right, really. To be honest, this change feels like a step backwards somehow. |
the problem with your approach @jonasdekeukelaere is that the main goal of namespaces is to group and avoid naming collisions. If you have a post and a category, and both of them have a status value object but it is not the same value object When there are a lot of things of the same type withing a domain namespace I always add an extra sublevel, for instance with commands |
Then you can start making subfolders in your (for example) Repository or ValueObject folder. |
removed since jeroens explanation was better |
@jonasdekeukelaere Take a look at this "Realizations module" example: |
Ok agree about that the entity is the common thing. But then I would make subfolders in the Domain/ContentBlock folder. Because now in @jeroendesloovere his example you just have a bunch of files that not really belong together. Some are Entity, some are DTO, some Form type, some Repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonasdekeukelaere that is because you can't see beyond what they are to you, a form, a DTO etc but they belong together, just like 2 wheels, a frame, a steer and some other things form a bike and are useless apart from each other (to a certain level)
|
||
/** | ||
* This is the add-action, it will display a form to create a new item | ||
*/ | ||
class Add extends BackendBaseActionAdd | ||
class ContentBlockAdd extends BackendBaseActionAdd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep this as Add if for some unforeseeable reason this would once in the future make the naming incorrect we can tackle it then, for now I would keep it at Add, Edit, Delete, and Index
@@ -43,27 +38,55 @@ public function execute(): void | |||
} | |||
|
|||
/** @var CreateContentBlock $createContentBlock */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this anymore since the method has a return type and that gives us the autocompletion that this provided in the past
[ | ||
'report' => 'added', | ||
'report' => 'content-block-added', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you change this?
$form = $this->createForm( | ||
ContentBlockType::class, | ||
new CreateContentBlock(), | ||
['theme' => $this->get('fork.settings')->get('Core', 'theme', 'Core')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see previous feedback, can you rebase on 5.0.0-dev because you are missing changes or fix this manually and check that you didn't occidentally remove something, I would personally prefer the rebase
/** | ||
* This is the delete-action, it will delete an item. | ||
*/ | ||
class ContentBlockDelete extends BackendBaseActionDelete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
Sure they belong together, but for example all the code in 1 class belongs together as well, you will split that up into methods, right? For example the refactoring of all the installers. Why is that different with files and ok to just drop them al in 1 folder? |
$this->redirect( | ||
$this->getBackLink( | ||
[ | ||
'report' => 'content-block-deleted', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
{ | ||
parent::execute(); | ||
|
||
/** @var ContentBlock $contentBlock */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
/** | ||
* This is the edit-action, it will display a form to edit an existing item | ||
*/ | ||
class ContentBlockEdit extends BackendBaseActionEdit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
return; | ||
} | ||
|
||
/** @var UpdateContentBlock $updateContentBlock */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
ContentBlockType::class, | ||
new UpdateContentBlock($contentBlock), | ||
[ | ||
'theme' => $this->get('fork.settings')->get('Core', 'theme', 'Core'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
use Common\Locale; | ||
use DateTime; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Table(name="content_blocks") | ||
* @ORM\Entity(repositoryClass="Backend\Modules\ContentBlocks\Repository\ContentBlockRepository") | ||
* @ORM\Entity(repositoryClass="Backend\Modules\ContentBlocks\Domain\ContentBlock\ContentBlockRepository") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should try it first, but I think because they are in the same namespace you can drop the FQCN and just use ContentBlockRepository
if ($dataTransferObject->hasExistingContentBlock()) { | ||
$dataTransferObject->getContentBlockEntity()->status = Status::archived(); | ||
|
||
return self::create($dataTransferObject); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you repeat what is done below so you can just have the ifstatement and use one return here
@@ -1,68 +0,0 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you rebase and actually remove these files in the same commit as you create the new class so that git sees it as a move?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeroendesloovere this shows as outdated but I need you to look at it :p
use Doctrine\DBAL\Types\Type; | ||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
|
||
class ContentBlockStatusDBALType extends Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
@@ -35,8 +35,8 @@ private function configureBackendNavigation(): void | |||
$this->setNavigation( | |||
$navigationModulesId, | |||
$this->getModule(), | |||
'content_blocks/index', | |||
['content_blocks/add', 'content_blocks/edit'] | |||
'content_blocks/content_block_index', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would revert this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments, something went wrong and the comments got posted as normal comments
@carakas thanks for your feedback. I've fixed it. |
Except merging forkcms 5.0.0 dev |
@carakas, can I rename the frontend action "Detail" to "ContentBlock"? |
you can add a rename for the widget if you also provide the update query and info in the upgrade guide |
Type
Resolves the following issues
Pull request description