Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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:56 - Dateigröße: 2.37 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  class FilterControllerEvent extends KernelEvent
 029  {
 030      /**
 031       * The current controller.
 032       */
 033      private $controller;
 034   
 035      public function __construct(HttpKernelInterface $kernel, $controller, Request $request, $requestType)
 036      {
 037          parent::__construct($kernel, $request, $requestType);
 038   
 039          $this->setController($controller);
 040      }
 041   
 042      /**
 043       * Returns the current controller.
 044       *
 045       * @return callable
 046       */
 047      public function getController()
 048      {
 049          return $this->controller;
 050      }
 051   
 052      /**
 053       * Sets a new controller.
 054       *
 055       * @param callable $controller
 056       *
 057       * @throws \LogicException
 058       */
 059      public function setController($controller)
 060      {
 061          // controller must be a callable
 062          if (!is_callable($controller)) {
 063              throw new \LogicException(sprintf('The controller must be a callable (%s given).', $this->varToString($controller)));
 064          }
 065   
 066          $this->controller = $controller;
 067      }
 068   
 069      private function varToString($var)
 070      {
 071          if (is_object($var)) {
 072              return sprintf('Object(%s)', get_class($var));
 073          }
 074   
 075          if (is_array($var)) {
 076              $a = array();
 077              foreach ($var as $k => $v) {
 078                  $a[] = sprintf('%s => %s', $k, $this->varToString($v));
 079              }
 080   
 081              return sprintf('Array(%s)', implode(', ', $a));
 082          }
 083   
 084          if (is_resource($var)) {
 085              return sprintf('Resource(%s)', get_resource_type($var));
 086          }
 087   
 088          if (null === $var) {
 089              return 'null';
 090          }
 091   
 092          if (false === $var) {
 093              return 'false';
 094          }
 095   
 096          if (true === $var) {
 097              return 'true';
 098          }
 099   
 100          return (string) $var;
 101      }
 102  }
 103