35 throw new LogicException(
'$parsers must a an array of Twig_TokenParserInterface');
37 $this->parsers[$parser->getTag()] =
$parser;
41 throw new LogicException(
'$brokers must a an array of Twig_TokenParserBrokerInterface');
43 $this->brokers[] = $broker;
65 if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) {
66 unset($this->parsers[$name]);
77 $this->brokers[] = $broker;
87 if (
false !== $pos = array_search($broker, $this->brokers)) {
88 unset($this->brokers[$pos]);
103 if (isset($this->parsers[$tag])) {
104 return $this->parsers[$tag];
106 $broker = end($this->brokers);
107 while (
false !== $broker) {
108 $parser = $broker->getTokenParser($tag);
112 $broker = prev($this->brokers);
129 foreach ($this->parsers as $tokenParser) {
130 $tokenParser->setParser($parser);
132 foreach ($this->brokers as $broker) {
133 $broker->setParser($parser);
addTokenParserBroker(Twig_TokenParserBroker $broker)
Adds a TokenParserBroker.
getTag()
Gets the tag name associated with this token parser.
Default implementation of a token parser broker.
setParser(Twig_ParserInterface $parser)
Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows of...
getParser()
Gets the Twig_ParserInterface.
Interface implemented by token parsers.
getTokenParser($tag)
Gets a suitable TokenParser for a tag.
removeTokenParser(Twig_TokenParserInterface $parser)
Removes a TokenParser.
Interface implemented by token parser brokers.
removeTokenParserBroker(Twig_TokenParserBroker $broker)
Removes a TokenParserBroker.
__construct($parsers=array(), $brokers=array())
Constructor.
addTokenParser(Twig_TokenParserInterface $parser)
Adds a TokenParser.
Interface implemented by parser classes.