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

Skip to content

Router service is now private #8985

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

Closed
wants to merge 1 commit into from

Conversation

TheDevilOnLine
Copy link
Contributor

The router service is private and not accessible in Symfony 4+, therefor $this->router should be used instead of $this->get('router'). Just above the example in question is explained how to get the router in your construct, so this should be clear.

The router service is private and not accessible in Symfony 4+, therefor $this->router should be used instead of $this->get('router'). Just above the example in question is explained how to get the router in your construct, so this should be clear.
@TheDevilOnLine
Copy link
Contributor Author

Will move these changes over to #8986

TheDevilOnLine pushed a commit to TheDevilOnLine/symfony-docs that referenced this pull request Jan 5, 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
javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull request Jan 7, 2018
* 4.0:
  Update collection.rst
  Mention that PSR-1 doesn't recommend CamelCase or anything else
  Fixed the XML and PHP config instead of the YAML config
  Use controller method injection instead of the constructor
  Add missing references
  Updated documentation to reflect best practice of using Dependency Injection over Container. Includes changes from PR symfony#8985
  Removed "Accessing the Container Directly"
  minor symfony#8091 Update js-datepicker usage for new jQuery UI (AdrianBorodziuk, javiereguiluz)
  minor symfony#8983 cross-reference console command testing from testing guide (dbu)
  Fix YAML config bug
  Removed invalid examples
  commands are automatically registered in symfony full stack
  update forms.rst
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.

2 participants