Skip to content

Commit 8db9912

Browse files
committed
Use getParameter method in controllers
1 parent dc75ff5 commit 8db9912

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

book/controller.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,14 @@ console command:
540540

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

543+
.. tip::
544+
545+
To get a container configuration parameter in controller you can use the
546+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getParameter`
547+
method::
548+
549+
$from = $this->getParameter('app.mailer.from');
550+
543551
.. index::
544552
single: Controller; Managing errors
545553
single: Controller; 404 pages

cookbook/controller/upload_file.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Finally, you need to update the code of the controller that handles the form::
140140

141141
// Move the file to the directory where brochures are stored
142142
$file->move(
143-
$this->container->getParameter('brochures_directory'),
143+
$this->getParameter('brochures_directory'),
144144
$fileName
145145
);
146146

@@ -408,7 +408,7 @@ Now, register this class as a Doctrine listener:
408408
409409
// app/config/services.php
410410
use Symfony\Component\DependencyInjection\Reference;
411-
411+
412412
// ...
413413
$definition = new Definition(
414414
'AppBundle\EventListener\BrochureUploaderListener',

0 commit comments

Comments
 (0)