Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

LocaleListener.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 1.79 KiB


01  <?php
02   
03  /*
04   * This file is part of the Symfony package.
05   *
06   * (c) Fabien Potencier <fabien@symfony.com>
07   *
08   * For the full copyright and license information, please view the LICENSE
09   * file that was distributed with this source code.
10   */
11   
12  namespace Symfony\Component\HttpKernel\EventListener;
13   
14  use Symfony\Component\HttpKernel\Event\GetResponseEvent;
15  use Symfony\Component\HttpKernel\KernelEvents;
16  use Symfony\Component\HttpFoundation\Request;
17  use Symfony\Component\Routing\RequestContextAwareInterface;
18  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
19   
20  /**
21   * Initializes the locale based on the current request.
22   *
23   * @author Fabien Potencier <fabien@symfony.com>
24   */
25  class LocaleListener implements EventSubscriberInterface
26  {
27      private $router;
28      private $defaultLocale;
29   
30      public function __construct($defaultLocale = 'en', RequestContextAwareInterface $router = null)
31      {
32          $this->defaultLocale = $defaultLocale;
33          $this->router = $router;
34      }
35   
36      public function setRequest(Request $request = null)
37      {
38          if (null === $request) {
39              return;
40          }
41   
42          if ($locale = $request->attributes->get('_locale')) {
43              $request->setLocale($locale);
44          }
45   
46          if (null !== $this->router) {
47              $this->router->getContext()->setParameter('_locale', $request->getLocale());
48          }
49      }
50   
51      public function onKernelRequest(GetResponseEvent $event)
52      {
53          $request = $event->getRequest();
54          $request->setDefaultLocale($this->defaultLocale);
55   
56          $this->setRequest($request);
57      }
58   
59      public static function getSubscribedEvents()
60      {
61          return array(
62              // must be registered after the Router to have access to the _locale
63              KernelEvents::REQUEST => array(array('onKernelRequest', 16)),
64          );
65      }
66  }
67