Skip to content

Use getParameter method in controllers #6726

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
Jul 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions book/controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,14 @@ console command:

For more information, see the :doc:`/book/service_container` chapter.

.. tip::

To get a container configuration parameter in controller you can use the
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getParameter`
method::

$from = $this->getParameter('app.mailer.from');

.. index::
single: Controller; Managing errors
single: Controller; 404 pages
Expand Down
4 changes: 2 additions & 2 deletions cookbook/controller/upload_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Finally, you need to update the code of the controller that handles the form::

// Move the file to the directory where brochures are stored
$file->move(
$this->container->getParameter('brochures_directory'),
$this->getParameter('brochures_directory'),
$fileName
);

Expand Down Expand Up @@ -408,7 +408,7 @@ Now, register this class as a Doctrine listener:

// app/config/services.php
use Symfony\Component\DependencyInjection\Reference;

// ...
$definition = new Definition(
'AppBundle\EventListener\BrochureUploaderListener',
Expand Down