Skip to content
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

EZP-28849: Allow repository forms to use View Manager for handling draft edit controller and template dispatching #215

Merged

Conversation

webhdx
Copy link
Contributor

@webhdx webhdx commented Feb 16, 2018

JIRA: https://jira.ez.no/browse/EZP-28849
Requires: ezsystems/ezplatform-admin-ui#375 (to work with AdminUI)

Description

I heard from @bdunogier it was always the initial idea but no one had time to finish it. As Page Builder is meant to replace edit interface for Landing Pages we need this feature. This PR only affects draft edit action, next one will be dedicated to content create.

I'd like a solid code review as this PR might potentially introduce some BC breaks.

QA Testing

Might be hard to test by QA as this is mostly related to developer experience but I'd advise to get through content editing briefly. If the content editing screen is displayed correctly and the actions are performed as expected it should be alright.

Copy link
Member

@bdunogier bdunogier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the idea, right ! I'll leave the BC to you guys :)
I had a look, and it seems fine to me, besides one point.

The controller action should be empty. If it is not, a developer has to extend from our own controller, and this is what we wanted to avoid, and why viewAction ended up empty.

The logic in the controller action needs to be moved to the ContentEditViewBuilder.

{
/** @var ContentEditView $view */
$view = $event->getView();
if (!$view instanceof ContentEditView) {
Copy link
Member

@bdunogier bdunogier Feb 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should ContentEditView inherit from ContentView ? That way, you wouldn't need to reimplement this listener. You can of course have an extra one that does edit specific things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't mix the two. Hard to predict how someone is going to use ContentView. In some cases he wouldn't expect to get content editing view. Anyway I also removed ContentEditViewParametersInjectorListener as it's no longer needed.

@webhdx webhdx force-pushed the EZP-28849_draft_edit_dispatching branch from dd81e8f to a66d7cf Compare February 22, 2018 13:12
@webhdx
Copy link
Contributor Author

webhdx commented Feb 28, 2018

ping @Nattfarinn @mikadamczyk @ViniTou any chance for code review?

Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commits overlap with #217, AFAICS my review done there applies here as well. Hopefully I didn't miss anything new.

Emphasizing one thing mentioned also in the other PR:

@@ -117,7 +110,7 @@ public function createWithoutDraftAction($contentTypeIdentifier, $language, $par
* @param string $toLanguage
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return \EzSystems\RepositoryForms\Content\View\ContentCreateDraftView|\Symfony\Component\HttpFoundation\Response
* @return \EzSystems\RepositoryForms\Content\View\ContentCreateDraftView|Response
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of inconsistency in PhpDoc type hinting. Please decide to use either FQCN or short name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my knowledge, we use fully-qualified namespaces.

While real IDEs will help navigate with short names, you don't get that option when reviewing code on github. I think it's a very valid argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on the repository. AdminUI uses short names. Is there a way to enforce it with PHP CS Fixer? @alongosz do you know?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to enforce it with PHP CS Fixer?

No, I already looked for it some time ago. Checked just now - nothing changed - we probably would need to contribute... :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I've changed to FQCN.

@webhdx
Copy link
Contributor Author

webhdx commented Mar 8, 2018

@mikadamczyk @ViniTou @alongosz @Nattfarinn Code review needed.

@webhdx
Copy link
Contributor Author

webhdx commented Mar 8, 2018

@bdunogier Controller won't stay empty because in ViewBuilder context you don't have an access to the Request thus you can't handle the form. I can get master request from the Container but the question is - is it the proper way to do it? Looks too hardcore for my liking. I'd rather have minimal logic in the controller so that anyone can override default behavior. The View is only passing information which is needed to render the template and it's fine for me. What do you think?

@bdunogier
Copy link
Member

@webhdx actually, you do get the Request with ViewBuilder Filters. It is what I had used when I had prototyped this: https://github.com/ezsystems/repository-forms/pull/62/files#diff-03ff5c01c6c75308bdf76dbeb0596a18.

Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review taken from #217 (I got lost initially due to overlapping commits and posted things there)

* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
* @throws \eZ\Publish\Core\Base\Exceptions\BadStateException
* @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException
* @throws \eZ\Publish\Core\Base\Exceptions\UnauthorizedException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@webhdx please type-hint API

*
* @return \eZ\Publish\API\Repository\Values\Content\Content
*
* @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@webhdx please type-hint API

@@ -0,0 +1,298 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: missing PhpDoc with license and copyright

@webhdx webhdx force-pushed the EZP-28849_draft_edit_dispatching branch from 185dc43 to cc1d362 Compare March 9, 2018 09:22
@webhdx
Copy link
Contributor Author

webhdx commented Mar 9, 2018

@alongosz Fixed.
@bdunogier Ok, managed to use ViewFilter event to handle the form. Controller action is just now acting as a passthrough for the ContentEditView object.

…aft edit controller and template dispatching
@webhdx webhdx force-pushed the EZP-28849_draft_edit_dispatching branch from cc1d362 to 4025795 Compare March 9, 2018 09:26
@barbaragr barbaragr self-assigned this Mar 9, 2018
@lserwatka lserwatka merged commit d059304 into ezsystems:master Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants