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

Apply Symfony best practices #126

Merged
merged 5 commits into from
Dec 18, 2017
Merged

Apply Symfony best practices #126

merged 5 commits into from
Dec 18, 2017

Conversation

emodric
Copy link
Collaborator

@emodric emodric commented Dec 16, 2017

  • Remove class parameters
  • use kernel.project_dir instead of kernel.root_dir
  • Use Twig namespaces for templates
  • Marked all services as private/public

@emodric emodric changed the title Apply Symfony best practices [WIP] Apply Symfony best practices Dec 16, 2017
@emodric emodric force-pushed the sf_best_practices branch 2 times, most recently from 237c856 to cc2f0d7 Compare December 16, 2017 17:13
@emodric emodric changed the title [WIP] Apply Symfony best practices Apply Symfony best practices Dec 16, 2017
@andrerom
Copy link
Contributor

ping @lolautruche

* @param \eZ\Bundle\EzPublishLegacyBundle\SetupWizard\ConfigurationDumper $configDumper
* @param \eZ\Bundle\EzPublishLegacyBundle\SetupWizard\ConfigurationConverter $configConverter
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
* @param \Symfony\Component\HttpKernel\KernelInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed var name in this line?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the whole PHPDoc could be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, thanks. Will fix it tomorrow, when I'm at my laptop :)

Copy link
Contributor

@lolautruche lolautruche left a comment

Choose a reason for hiding this comment

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

A BC note should be added somewhere as some of those changes could be considered as BC breaks (e.g. class parameters if one were relying on that to override)

* @param \eZ\Bundle\EzPublishLegacyBundle\SetupWizard\ConfigurationDumper $configDumper
* @param \eZ\Bundle\EzPublishLegacyBundle\SetupWizard\ConfigurationConverter $configConverter
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
* @param \Symfony\Component\HttpKernel\KernelInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the whole PHPDoc could be removed

@@ -5,7 +5,7 @@ parameters:
ezpublish_legacy.default.module_default_layout: ~

# Pagelayout to use while rendering a content view in legacy
ezpublish_legacy.default.view_default_layout: EzPublishLegacyBundle::legacy_view_default_pagelayout.html.twig
ezpublish_legacy.default.view_default_layout: "@@EzPublishLegacy/legacy_view_default_pagelayout.html.twig"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a double @ here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without it, Symfony crashes with unknown service error or something similar. I can't find the doc about it ATM, but I have it working like this on some of our other projects, after I've read it in the docs 🙊

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ha, found it!

http://symfony.com/doc/current/service_container/parameters.html

If you use a string that starts with @ or has % anywhere in it, you need to escape it by adding another @ or %

# config/services.yaml
parameters:
    # This will be parsed as string '@securepass'
    mailer_password: '@@securepass'

    # Parsed as http://symfony.com/?foo=%s&bar=%d
    url_pattern: 'http://symfony.com/?foo=%%s&bar=%%d'

@emodric
Copy link
Collaborator Author

emodric commented Dec 17, 2017

@lolautruche I'll write up some 2.0 upgrade docs, thanks 👍

@emodric
Copy link
Collaborator Author

emodric commented Dec 17, 2017

Note to self: Need to rebase on master to get the tests running once #122 is merged.

@andrerom
Copy link
Contributor

Note to self: Need to rebase on master to get the tests running once #122 is merged.

merged

@emodric emodric changed the base branch from 2.0 to master December 18, 2017 08:48
@emodric emodric force-pushed the sf_best_practices branch 2 times, most recently from 371d616 to 6b9323a Compare December 18, 2017 08:55
@@ -263,7 +264,7 @@ public function setCLIHandler(ezpKernelHandler $kernelHandler)
public function buildLegacyKernelHandlerTreeMenu()
{
return $this->buildLegacyKernelHandlerWeb(
$this->container->getParameter('ezpublish_legacy.kernel_handler.treemenu.class'),
ezpKernelWeb::class,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be ezpKernelTreeMenu?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Eeeek, you're right!!

Fixed, thanks!

@emodric
Copy link
Collaborator Author

emodric commented Dec 18, 2017

@andrerom @crevillo @blankse @lolautruche Ready for final review and merge :)

Will writeup upgrade docs in a separate PR.

Copy link
Contributor

@blankse blankse left a comment

Choose a reason for hiding this comment

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

LGTM

@emodric emodric merged commit 4551926 into master Dec 18, 2017
@emodric
Copy link
Collaborator Author

emodric commented Dec 18, 2017

Thanks everyone!

@andrerom andrerom deleted the sf_best_practices branch December 18, 2017 15:45
@emodric emodric mentioned this pull request Dec 19, 2017
calls:
- [setLegacyHelper, ["@ezpublish_legacy.templating.legacy_helper"]]

# Overriding core helper
ezpublish.templating.global_helper:
alias: ezpublish.templating.global_helper.legacy
public: false
Copy link
Contributor

Choose a reason for hiding this comment

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

Is EzPublishCoreBundle\Controller deprecated? The breaks it's 'getGlobalHelper' as it needs the service to be public or an exception is thrown and it is private now.

Copy link
Contributor

@andrerom andrerom Nov 5, 2018

Choose a reason for hiding this comment

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

My guess: helper should be adapted to inject the service(s) instead of relying on contianer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe when aliasing a service we should change its viability either which is causing me the issue I see.

Copy link
Contributor

Choose a reason for hiding this comment

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

That could be as well.

@emodric as you're the author of this change, any opinions on the matter :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm fine with it being public, no problem :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Another approach would be to use the service locator feature in EzPublishCoreBundle\Controller (Symfony 3.3+)

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi guys, I've found this issue after upgrading from an old 5.4 to the new 2.5.6, solved by overriding service definition on my own services.yml file.

Copy link
Contributor

@andrerom andrerom Dec 3, 2019

Choose a reason for hiding this comment

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

Someone willing to do PR to drop this? I agree we should not change this from kernel.

Copy link
Contributor

Choose a reason for hiding this comment

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

PR: #175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants