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

TokenParserBroker.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 3.79 KiB


 001  <?php
 002   
 003  /*
 004   * This file is part of Twig.
 005   *
 006   * (c) 2010 Fabien Potencier
 007   * (c) 2010 Arnaud Le Blanc
 008   *
 009   * For the full copyright and license information, please view the LICENSE
 010   * file that was distributed with this source code.
 011   */
 012   
 013  /**
 014   * Default implementation of a token parser broker.
 015   *
 016   * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
 017   * @deprecated since 1.12 (to be removed in 2.0)
 018   */
 019  class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
 020  {
 021      protected $parser;
 022      protected $parsers = array();
 023      protected $brokers = array();
 024   
 025      /**
 026       * Constructor.
 027       *
 028       * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
 029       * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
 030       */
 031      public function __construct($parsers = array(), $brokers = array())
 032      {
 033          foreach ($parsers as $parser) {
 034              if (!$parser instanceof Twig_TokenParserInterface) {
 035                  throw new LogicException('$parsers must a an array of Twig_TokenParserInterface');
 036              }
 037              $this->parsers[$parser->getTag()] = $parser;
 038          }
 039          foreach ($brokers as $broker) {
 040              if (!$broker instanceof Twig_TokenParserBrokerInterface) {
 041                  throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface');
 042              }
 043              $this->brokers[] = $broker;
 044          }
 045      }
 046   
 047      /**
 048       * Adds a TokenParser.
 049       *
 050       * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance
 051       */
 052      public function addTokenParser(Twig_TokenParserInterface $parser)
 053      {
 054          $this->parsers[$parser->getTag()] = $parser;
 055      }
 056   
 057      /**
 058       * Removes a TokenParser.
 059       *
 060       * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance
 061       */
 062      public function removeTokenParser(Twig_TokenParserInterface $parser)
 063      {
 064          $name = $parser->getTag();
 065          if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) {
 066              unset($this->parsers[$name]);
 067          }
 068      }
 069   
 070      /**
 071       * Adds a TokenParserBroker.
 072       *
 073       * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance
 074       */
 075      public function addTokenParserBroker(Twig_TokenParserBroker $broker)
 076      {
 077          $this->brokers[] = $broker;
 078      }
 079   
 080      /**
 081       * Removes a TokenParserBroker.
 082       *
 083       * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance
 084       */
 085      public function removeTokenParserBroker(Twig_TokenParserBroker $broker)
 086      {
 087          if (false !== $pos = array_search($broker, $this->brokers)) {
 088              unset($this->brokers[$pos]);
 089          }
 090      }
 091   
 092      /**
 093       * Gets a suitable TokenParser for a tag.
 094       *
 095       * First looks in parsers, then in brokers.
 096       *
 097       * @param string $tag A tag name
 098       *
 099       * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found
 100       */
 101      public function getTokenParser($tag)
 102      {
 103          if (isset($this->parsers[$tag])) {
 104              return $this->parsers[$tag];
 105          }
 106          $broker = end($this->brokers);
 107          while (false !== $broker) {
 108              $parser = $broker->getTokenParser($tag);
 109              if (null !== $parser) {
 110                  return $parser;
 111              }
 112              $broker = prev($this->brokers);
 113          }
 114      }
 115   
 116      public function getParsers()
 117      {
 118          return $this->parsers;
 119      }
 120   
 121      public function getParser()
 122      {
 123          return $this->parser;
 124      }
 125   
 126      public function setParser(Twig_ParserInterface $parser)
 127      {
 128          $this->parser = $parser;
 129          foreach ($this->parsers as $tokenParser) {
 130              $tokenParser->setParser($parser);
 131          }
 132          foreach ($this->brokers as $broker) {
 133              $broker->setParser($parser);
 134          }
 135      }
 136  }
 137