Skip to content

Use 3.3 DI features in CodeExplorerBundle #576

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

Merged
merged 1 commit into from
Jun 20, 2017

Conversation

ogizanagi
Copy link
Contributor

Since 3.3, listeners do not have to be public anymore.
I also believe declaring services private by default by adding _defaults: { public: false } on top will become a best practice, so I think we should use it in the CodeExplorerBundle.

Actually, we could also use classnamed services, autoconfigure and autowiring, but at least for the last one, I think we should keep a place in this application where services are declared entirely manually (autoconfigure is debatable this way too, that's true).

WDYT?

tags:
- { name: twig.extension }
class: CodeExplorerBundle\Twig\SourceCodeExtension
tags: [twig.extension]
Copy link
Member

Choose a reason for hiding this comment

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

use autoconfiguration to simplify the file too. almost everything can be removed then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, if there is a consensus on this, I'd be pleased to add autoconfigure and classnamed services here, as explained in the description (I just want to gather opinions here first) :)

Copy link
Member

@stof stof May 31, 2017

Choose a reason for hiding this comment

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

Well, AppBundle was migrated to use all new features. I think CodeExplorerBundle should be updated too (and the listener should become a subscriber to avoid tagging manually)

Copy link
Member

Choose a reason for hiding this comment

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

At first I thought as Maxime: let's show the new Symfony in AppBundle and the old Symfony in CodeExplorerBundle. But now I'm starting to think as Christophe. If this is the new and recommended Symfony ... why show the old Symfony too?

Besides, before November we'll delete the CodeExplorerBundle (and Appbundle too!) because we'll use Symfony 4 and there are no bundles in that version!

@ogizanagi ogizanagi changed the title Default to private services + short tag syntax in CodeExplorerBundle Use 3.3 DI features in CodeExplorerBundle May 31, 2017
@ogizanagi
Copy link
Contributor Author

ogizanagi commented May 31, 2017

Following #576 (review), I've updated the PR to use most of the new 3.3 DI features. But I still avoided to use PSR-4 autoloading & autowiring on the contrary of what we did for the AppBundle.

At first I thought as Maxime: let's show the new Symfony in AppBundle and the old Symfony in CodeExplorerBundle. But now I'm starting to think as Christophe. If this is the new and recommended Symfony ... why show the old Symfony too?

Because we could consider this bundle as a more advanced entrypoint for intermediate developers, while the AppBundle is the main show case for newcomers. I still think it's important to show how to wire things manually and demonstrate the Symfony DI & its configuration capabilities. Developers can learn a lot by going deeper on how things work behind the scene (actually, it's not even that far, its only basic configuration we wrote since years. Still, it feels important to me).

But if my concerns aren't shared, I can still update the PR to use PSR-4 autoloading & autowiring on the whole src directory instead. Let me know 😄

* examples see https://symfony.com/doc/current/cookbook/service_container/event_listener.html
* Tip: listeners and subscribers are common in Symfony applications, but this particular
* one is too advanced and too specific for the demo application needs.
* For more common examples see https://symfony.com/doc/current/event_dispatcher.html
Copy link
Member

Choose a reason for hiding this comment

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

I would remove this extended doc. We already have it on the subscribers in the AppBundle. People digging into the internals of CodeExplorerBundle should already know what a subscriber is. And it will avoid having to maintain this message multiple time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@javiereguiluz
Copy link
Member

Thanks @ogizanagi.

@javiereguiluz javiereguiluz merged commit c391498 into symfony:master Jun 20, 2017
javiereguiluz added a commit that referenced this pull request Jun 20, 2017
This PR was merged into the master branch.

Discussion
----------

Use 3.3 DI features in CodeExplorerBundle

Since 3.3, [listeners do not have to be public anymore](https://github.com/symfony/symfony/pull/20953/files#diff-8604f72b4ae78c6c364c1af8c1dee17cL63).
I also believe declaring services private by default by adding `_defaults: { public: false }` on top will become a best practice, so I think we should use it in the CodeExplorerBundle.

Actually, we could also use classnamed services, autoconfigure and autowiring, but at least for the last one, I think we should keep a place in this application where services are declared entirely manually (autoconfigure is debatable this way too, that's true).

WDYT?

Commits
-------

c391498 Use 3.3 DI features in CodeExplorerBundle
@ogizanagi ogizanagi deleted the code_expl/3.3 branch June 20, 2017 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants