Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Removed invalid examples #8986

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 4 commits into from
Jan 7, 2018
Merged

Removed invalid examples #8986

merged 4 commits into from
Jan 7, 2018

Conversation

TheDevilOnLine
Copy link
Contributor

Templating isn't a service in Symfony 4+ (even after composer req templating), so probably we're looking for the twig service.

The Router service isn't public and can therefor not be called from the container:

$ php bin/console debug:container router

 // This service is an alias for the service router.default

Information for Service "router.default"
========================================

 ---------------- -----------------------------------------------
  Option           Value
 ---------------- -----------------------------------------------
  Service ID       router.default
  Class            Symfony\Bundle\FrameworkBundle\Routing\Router
  Tags             -
  Calls            setConfigCacheFactory
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- -----------------------------------------------

Templating isn't a service in Symfony 4+ (even after `composer req templating`), so probably we're looking for the twig service.

The Router service isn't public and can therefor not be called from the container:
```
Information for Service "router.default"
========================================

 ---------------- -----------------------------------------------
  Option           Value
 ---------------- -----------------------------------------------
  Service ID       router.default
  Class            Symfony\Bundle\FrameworkBundle\Routing\Router
  Tags             -
  Calls            setConfigCacheFactory
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- -----------------------------------------------
```
@javiereguiluz
Copy link
Member

Maybe it's time to remove the Accessing the Container Directly section entirely. @weaverryan what do you think?

@weaverryan
Copy link
Member

Yea, I agree: we should remove this section entirely. Could you do that @TheDevilOnLine?

Removed "Accessing the Container Directly" section, as this way of work is currently deprecated.
@TheDevilOnLine
Copy link
Contributor Author

TheDevilOnLine commented Jan 5, 2018

@weaverryan Done. Can you guys do the squashing when doing the merge?

Want me to check the rest of the documentation for these kind of container usage as well?

@weaverryan
Copy link
Member

@TheDevilOnLine Yep, no worries - we'll handle the squashing.

Want me to check the rest of the documentation for these kind of container usage as well?

YES! I was literally just thinking this as I opened up your PR. There probably are a few legit cases still, but yea, we need to check all the docs to be sure.

Thanks!

@TheDevilOnLine
Copy link
Contributor Author

TheDevilOnLine commented Jan 5, 2018

I've went over the documentation and checked all instances containing $this->get() or $this->container->get() and added changes for the places where it makes sense. All remaining instances only show 'the old way', or explain about public/private services.

The only thing I didn't know for sure (which might improve the documentation), is if there's a way to get a Doctrine EntityManager, other than the default one, through dependency injection. If this is possible, I think it's a good idea to add this information to multiple_entity_managers.rst as well

I think the only other way is to inject the complete doctrine service, and call getManager('customer') on it, but I don't feel this is better than $this->getDoctrine()->getManager('customer'), do you? Also including documentation about defining it in the service,yml (like below, thanks @chasen for the example) seems like to much for this specific part in the documentation.

App\Service\SomeService:
    arguments:
        $doctrine: "@doctrine.orm.manager_name"

@javiereguiluz
Copy link
Member

@TheDevilOnLine thanks for updating all this and congrats on your first contribution to Symfony Docs!

@javiereguiluz javiereguiluz merged commit 3492028 into symfony:4.0 Jan 7, 2018
javiereguiluz added a commit that referenced this pull request Jan 7, 2018
… javiereguiluz)

This PR was merged into the 4.0 branch.

Discussion
----------

Removed invalid examples

Templating isn't a service in Symfony 4+ (even after `composer req templating`), so probably we're looking for the twig service.

The Router service isn't public and can therefor not be called from the container:
```
$ php bin/console debug:container router

 // This service is an alias for the service router.default

Information for Service "router.default"
========================================

 ---------------- -----------------------------------------------
  Option           Value
 ---------------- -----------------------------------------------
  Service ID       router.default
  Class            Symfony\Bundle\FrameworkBundle\Routing\Router
  Tags             -
  Calls            setConfigCacheFactory
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- -----------------------------------------------
```

Commits
-------

3492028 Use controller method injection instead of the constructor
f9091b0 Updated documentation to reflect best practice of using Dependency Injection over Container. Includes changes from PR #8985
18e6d9e Removed "Accessing the Container Directly"
89e38ef Removed invalid examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants