From 8db99129f42fcf37de2fddbb2e00505834157803 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Thu, 7 Jul 2016 01:34:33 +0200 Subject: [PATCH] Use getParameter method in controllers --- book/controller.rst | 8 ++++++++ cookbook/controller/upload_file.rst | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/book/controller.rst b/book/controller.rst index fcfb5752628..a63721f963e 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -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 diff --git a/cookbook/controller/upload_file.rst b/cookbook/controller/upload_file.rst index a5359b64591..a81dabefacd 100644 --- a/cookbook/controller/upload_file.rst +++ b/cookbook/controller/upload_file.rst @@ -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 ); @@ -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',