-
-
Notifications
You must be signed in to change notification settings - Fork 326
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
Using Domain structure for ContentBlocks module #2091
Using Domain structure for ContentBlocks module #2091
Conversation
@jeroendesloovere, thanks for your PR! By analyzing the history of the files in this pull request, we identified @carakas, @tijsverkoyen and @WouterSioen to be potential reviewers. |
Note to self: saving a review isn't working |
); | ||
|
||
$form->handleRequest($this->get('request')); | ||
/** @var Form $form */ |
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 don't need this phpdoc since the return type is already the form
|
||
/** | ||
* 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 think in this case renaming this might be a bit overkill, but if you do it you need to make sure that all the changes needed to the database are added to the upgrade guide
Goes for all the other actions in this case as well.
$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.
This must be $this->get('fork.settings')->get('Core', 'theme', 'Fork')
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 guess this has/will be fixed in another PR, so I won't change this. OK?
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.
That PR has already been made and has been merged, so you should make sure you have the latests version of 5.0.0-dev, since git saw your changes as delete and add instead of move that change would've been lost
*/ | ||
class ContentBlockDelete extends BackendBaseActionDelete | ||
{ | ||
public function execute(): void |
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.
if #2090 gets merged before this one the logic here needs to be updated since it won't get merged because you changed everything in one big commit and thereby are breaking the git history
|
||
$form->handleRequest($this->get('request')); | ||
/** @var Form $form */ | ||
$form = $this->getForm(); | ||
|
||
if (!$form->isValid()) { |
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.
checking if a form is valid before checking if a form is submitted is deprecated in symfony 3.3 and removed in symfony 4, since we will need to upgrade for fork 5 this will need to be changed here as well
@@ -38,20 +38,43 @@ public function getNextIdForLanguage(Locale $locale): int | |||
->getSingleScalarResult() + 1; | |||
} | |||
|
|||
public function findOneByIdAndLocale($id, Locale $locale): ?ContentBlock | |||
public function findOneByIdAndLocale(int $id = null, Locale $locale): ?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.
wrong method signature, if the int needs to be able to receive a null (maybe check the implementation) you need to use ?int
and not = null
because now you have an optional parameter before a required one
} | ||
|
||
public function findOneByRevisionIdAndLocale($revisionId, Locale $locale): ?ContentBlock | ||
public function findOneByRevisionIdAndLocale(int $revisionId = null, Locale $locale): 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.
likewise
|
||
public static function getHtml(ContentBlock $contentBlock, Locale $locale): string | ||
{ | ||
return (string) (new self($contentBlock, $locale))->getContent(); |
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.
we no longer need to cast to string since ->getContent()
now always will return a string and no longer null
but ''
when there are no results
|
||
use Exception; | ||
|
||
class ContentBlockNotFound extends Exception |
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.
👍
@@ -51,7 +51,7 @@ | |||
<div class="col-md-12"> | |||
<div class="btn-toolbar"> | |||
<div class="btn-group pull-left" role="group"> | |||
{% if showContentBlocksDelete %} | |||
{% if showContentBlocksContentBlockDelete %} |
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 with the renaming of the actions in this case it only complicates reading things like this
I'm going to close this one like we discussed since too much of the git history is broken. |
Type
Pull request description