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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
TokenParserBroker.php
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 *
018 * @deprecated since 1.12 (to be removed in 2.0)
019 */
020 class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
021 {
022 protected $parser;
023 protected $parsers = array();
024 protected $brokers = array();
025
026 /**
027 * Constructor.
028 *
029 * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
030 * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
031 * @param bool $triggerDeprecationError
032 */
033 public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true)
034 {
035 if ($triggerDeprecationError) {
036 @trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED);
037 }
038
039 foreach ($parsers as $parser) {
040 if (!$parser instanceof Twig_TokenParserInterface) {
041 throw new LogicException('$parsers must a an array of Twig_TokenParserInterface.');
042 }
043 $this->parsers[$parser->getTag()] = $parser;
044 }
045 foreach ($brokers as $broker) {
046 if (!$broker instanceof Twig_TokenParserBrokerInterface) {
047 throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface.');
048 }
049 $this->brokers[] = $broker;
050 }
051 }
052
053 /**
054 * Adds a TokenParser.
055 *
056 * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance
057 */
058 public function addTokenParser(Twig_TokenParserInterface $parser)
059 {
060 $this->parsers[$parser->getTag()] = $parser;
061 }
062
063 /**
064 * Removes a TokenParser.
065 *
066 * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance
067 */
068 public function removeTokenParser(Twig_TokenParserInterface $parser)
069 {
070 $name = $parser->getTag();
071 if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) {
072 unset($this->parsers[$name]);
073 }
074 }
075
076 /**
077 * Adds a TokenParserBroker.
078 *
079 * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance
080 */
081 public function addTokenParserBroker(Twig_TokenParserBroker $broker)
082 {
083 $this->brokers[] = $broker;
084 }
085
086 /**
087 * Removes a TokenParserBroker.
088 *
089 * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance
090 */
091 public function removeTokenParserBroker(Twig_TokenParserBroker $broker)
092 {
093 if (false !== $pos = array_search($broker, $this->brokers)) {
094 unset($this->brokers[$pos]);
095 }
096 }
097
098 /**
099 * Gets a suitable TokenParser for a tag.
100 *
101 * First looks in parsers, then in brokers.
102 *
103 * @param string $tag A tag name
104 *
105 * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found
106 */
107 public function getTokenParser($tag)
108 {
109 if (isset($this->parsers[$tag])) {
110 return $this->parsers[$tag];
111 }
112 $broker = end($this->brokers);
113 while (false !== $broker) {
114 $parser = $broker->getTokenParser($tag);
115 if (null !== $parser) {
116 return $parser;
117 }
118 $broker = prev($this->brokers);
119 }
120 }
121
122 public function getParsers()
123 {
124 return $this->parsers;
125 }
126
127 public function getParser()
128 {
129 return $this->parser;
130 }
131
132 public function setParser(Twig_ParserInterface $parser)
133 {
134 $this->parser = $parser;
135 foreach ($this->parsers as $tokenParser) {
136 $tokenParser->setParser($parser);
137 }
138 foreach ($this->brokers as $broker) {
139 $broker->setParser($parser);
140 }
141 }
142 }
143