From 474285981d841739d943e7930f3fdcf09f76f2e7 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 16 Sep 2014 22:49:25 +0200 Subject: [PATCH 1/3] fix ContainerAwareEventDispatcher definition --- components/event_dispatcher/introduction.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/components/event_dispatcher/introduction.rst b/components/event_dispatcher/introduction.rst index 1b32938c89a..e862af05347 100644 --- a/components/event_dispatcher/introduction.rst +++ b/components/event_dispatcher/introduction.rst @@ -208,6 +208,8 @@ instance of ``Symfony\Component\HttpKernel\Event\FilterResponseEvent``:: .. sidebar:: Registering Event Listeners in the Service Container When you are using the + :class:`Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher` + and the :doc:`DependencyInjection component `, you can use the :class:`Symfony\\Component\\HttpKernel\\DependencyInjection\\RegisterListenersPass` @@ -216,16 +218,17 @@ instance of ``Symfony\Component\HttpKernel\Event\FilterResponseEvent``:: use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; + use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass; $containerBuilder = new ContainerBuilder(new ParameterBag()); $containerBuilder->addCompilerPass(new RegisterListenersPass()); // register the event dispatcher service - $containerBuilder->register( - 'event_dispatcher', - 'Symfony\Component\EventDispatcher\EventDispatcher' - ); + $containerBuilder->setDefinition('event_dispatcher', new Definition( + 'Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher', + array(new Reference('service_container')) + )); // register your event listener service $listener = new Definition('AcmeListener'); From 9790975d0c0081081d8fdd1c59603d567e94baf6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 18 Sep 2014 00:27:58 +0200 Subject: [PATCH 2/3] link translation DIC tags to components section The `translation.loader` and `translation.dumper` DIC tags link to the respective sections in the Translation component documentation. --- components/translation/custom_formats.rst | 4 +++ reference/dic_tags.rst | 33 +++++++---------------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/components/translation/custom_formats.rst b/components/translation/custom_formats.rst index cf2d899e4d7..4378d249f86 100644 --- a/components/translation/custom_formats.rst +++ b/components/translation/custom_formats.rst @@ -18,6 +18,8 @@ message. A translation file would look like this: (goodbye)(au revoir) (hello)(bonjour) +.. _components-translation-custom-loader: + Creating a Custom Loader ------------------------ @@ -65,6 +67,8 @@ Once created, it can be used as any other loader:: It will print *"accueil"*. +.. _components-translation-custom-dumper: + Creating a Custom Dumper ------------------------ diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index ffe098ce8ae..a746ef7ef86 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -1029,32 +1029,12 @@ translation.loader **Purpose**: To register a custom service that loads translations By default, translations are loaded from the filesystem in a variety of different -formats (YAML, XLIFF, PHP, etc). If you need to load translations from some -other source, first create a class that implements the -:class:`Symfony\\Component\\Translation\\Loader\\LoaderInterface` interface:: +formats (YAML, XLIFF, PHP, etc). - // src/Acme/MainBundle/Translation/MyCustomLoader.php - namespace Acme\MainBundle\Translation; - - use Symfony\Component\Translation\Loader\LoaderInterface; - use Symfony\Component\Translation\MessageCatalogue; - - class MyCustomLoader implements LoaderInterface - { - public function load($resource, $locale, $domain = 'messages') - { - $catalogue = new MessageCatalogue($locale); - - // some how load up some translations from the "resource" - // then set them into the catalogue - $catalogue->set('hello.world', 'Hello World!', $domain); - - return $catalogue; - } - } +.. seealso:: -Your custom loader's ``load`` method is responsible for returning a -:Class:`Symfony\\Component\\Translation\\MessageCatalogue`. + Learn how to :ref:`load custom formats ` + in the components section. Now, register your loader as a service and tag it with ``translation.loader``: @@ -1252,6 +1232,11 @@ This is the name that's used to determine which dumper should be used. ) ->addTag('translation.dumper', array('alias' => 'json')); +.. seealso:: + + Learn how to :ref:`dump to custom formats ` + in the components section. + .. _reference-dic-tags-twig-extension: twig.extension From 7568732e01e22439bdde7638e01e6d4ac880d570 Mon Sep 17 00:00:00 2001 From: thewilkybarkid Date: Tue, 16 Sep 2014 19:47:58 +0100 Subject: [PATCH 3/3] Remove redundant references to trusting HttpCache --- book/http_cache.rst | 4 ---- components/http_foundation/trusting_proxies.rst | 6 ------ cookbook/request/load_balancer_reverse_proxy.rst | 6 ------ 3 files changed, 16 deletions(-) diff --git a/book/http_cache.rst b/book/http_cache.rst index a8166ef4241..190a64fc5fb 100644 --- a/book/http_cache.rst +++ b/book/http_cache.rst @@ -163,10 +163,6 @@ kernel:: The caching kernel will immediately act as a reverse proxy - caching responses from your application and returning them to the client. -Now that you're using a "proxy", you'll need to configure ``127.0.0.1`` under -the ``trusted_proxies`` configuration (see :ref:`the reference `). -Without this, the client's IP address and a few other things won't report correctly. - .. tip:: The cache kernel has a special ``getLog()`` method that returns a string diff --git a/components/http_foundation/trusting_proxies.rst b/components/http_foundation/trusting_proxies.rst index dc126617e5e..fbe9b30cdee 100644 --- a/components/http_foundation/trusting_proxies.rst +++ b/components/http_foundation/trusting_proxies.rst @@ -30,12 +30,6 @@ your proxy. // only trust proxy headers coming from this IP addresses Request::setTrustedProxies(array('192.0.0.1', '10.0.0.0/8')); -.. note:: - - When using Symfony's internal reverse proxy (``AppCache.php``) make sure to add - ``127.0.0.1`` to the list of trusted proxies. - - Configuring Header Names ------------------------ diff --git a/cookbook/request/load_balancer_reverse_proxy.rst b/cookbook/request/load_balancer_reverse_proxy.rst index 324cbd12838..e23e0ac01c2 100644 --- a/cookbook/request/load_balancer_reverse_proxy.rst +++ b/cookbook/request/load_balancer_reverse_proxy.rst @@ -11,12 +11,6 @@ special ``X-Forwarded-*`` headers. For example, instead of reading the ``REMOTE_ header (which will now be the IP address of your reverse proxy), the user's true IP will be stored in an ``X-Forwarded-For`` header. -.. tip:: - - If you're using Symfony's :ref:`AppCache` for caching, - then you *are* using a reverse proxy with the IP address ``127.0.0.1``. - You'll need to configure that address as a trusted proxy below. - If you don't configure Symfony to look for these headers, you'll get incorrect information about the client's IP address, whether or not the client is connecting via HTTPS, the client's port and the hostname being requested.