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

FilterControllerEvent.php

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


 001  <?php
 002   
 003  /*
 004   * This file is part of the Symfony package.
 005   *
 006   * (c) Fabien Potencier <fabien@symfony.com>
 007   *
 008   * For the full copyright and license information, please view the LICENSE
 009   * file that was distributed with this source code.
 010   */
 011   
 012  namespace Symfony\Component\HttpKernel\Event;
 013   
 014  use Symfony\Component\HttpKernel\HttpKernelInterface;
 015  use Symfony\Component\HttpFoundation\Request;
 016   
 017  /**
 018   * Allows filtering of a controller callable
 019   *
 020   * You can call getController() to retrieve the current controller. With
 021   * setController() you can set a new controller that is used in the processing
 022   * of the request.
 023   *
 024   * Controllers should be callables.
 025   *
 026   * @author Bernhard Schussek <bschussek@gmail.com>
 027   *
 028   * @api
 029   */
 030  class FilterControllerEvent extends KernelEvent
 031  {
 032      /**
 033       * The current controller
 034       * @var callable
 035       */
 036      private $controller;
 037   
 038      public function __construct(HttpKernelInterface $kernel, $controller, Request $request, $requestType)
 039      {
 040          parent::__construct($kernel, $request, $requestType);
 041   
 042          $this->setController($controller);
 043      }
 044   
 045      /**
 046       * Returns the current controller
 047       *
 048       * @return callable
 049       *
 050       * @api
 051       */
 052      public function getController()
 053      {
 054          return $this->controller;
 055      }
 056   
 057      /**
 058       * Sets a new controller
 059       *
 060       * @param callable $controller
 061       *
 062       * @throws \LogicException
 063       *
 064       * @api
 065       */
 066      public function setController($controller)
 067      {
 068          // controller must be a callable
 069          if (!is_callable($controller)) {
 070              throw new \LogicException(sprintf('The controller must be a callable (%s given).', $this->varToString($controller)));
 071          }
 072   
 073          $this->controller = $controller;
 074      }
 075   
 076      private function varToString($var)
 077      {
 078          if (is_object($var)) {
 079              return sprintf('Object(%s)', get_class($var));
 080          }
 081   
 082          if (is_array($var)) {
 083              $a = array();
 084              foreach ($var as $k => $v) {
 085                  $a[] = sprintf('%s => %s', $k, $this->varToString($v));
 086              }
 087   
 088              return sprintf("Array(%s)", implode(', ', $a));
 089          }
 090   
 091          if (is_resource($var)) {
 092              return sprintf('Resource(%s)', get_resource_type($var));
 093          }
 094   
 095          if (null === $var) {
 096              return 'null';
 097          }
 098   
 099          if (false === $var) {
 100              return 'false';
 101          }
 102   
 103          if (true === $var) {
 104              return 'true';
 105          }
 106   
 107          return (string) $var;
 108      }
 109  }
 110