diff options
| author | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-01 15:20:12 -0400 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-01 15:20:12 -0400 |
| commit | 0fe552857468aa12097a74e08f51f5aaa983be07 (patch) | |
| tree | 22dbca1be90d7086b20a077752552296abf23325 /inc/lib/Twig/TokenParserBroker.php | |
| parent | 22f3a95e0e421de05a11633eac846df96a2a4768 (diff) | |
Upgrade Twig library
Diffstat (limited to 'inc/lib/Twig/TokenParserBroker.php')
| -rw-r--r-- | inc/lib/Twig/TokenParserBroker.php | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/inc/lib/Twig/TokenParserBroker.php b/inc/lib/Twig/TokenParserBroker.php index 34fcdfbf..ec3fba67 100644 --- a/inc/lib/Twig/TokenParserBroker.php +++ b/inc/lib/Twig/TokenParserBroker.php @@ -13,8 +13,8 @@ /** * Default implementation of a token parser broker. * - * @package twig - * @author Arnaud Le Blanc <arnaud.lb@gmail.com> + * @author Arnaud Le Blanc <arnaud.lb@gmail.com> + * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface { @@ -32,13 +32,13 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface { foreach ($parsers as $parser) { if (!$parser instanceof Twig_TokenParserInterface) { - throw new Twig_Error('$parsers must a an array of Twig_TokenParserInterface'); + throw new LogicException('$parsers must a an array of Twig_TokenParserInterface'); } $this->parsers[$parser->getTag()] = $parser; } foreach ($brokers as $broker) { if (!$broker instanceof Twig_TokenParserBrokerInterface) { - throw new Twig_Error('$brokers must a an array of Twig_TokenParserBrokerInterface'); + throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface'); } $this->brokers[] = $broker; } @@ -55,6 +55,19 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface } /** + * Removes a TokenParser. + * + * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance + */ + public function removeTokenParser(Twig_TokenParserInterface $parser) + { + $name = $parser->getTag(); + if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) { + unset($this->parsers[$name]); + } + } + + /** * Adds a TokenParserBroker. * * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance @@ -65,6 +78,18 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface } /** + * Removes a TokenParserBroker. + * + * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance + */ + public function removeTokenParserBroker(Twig_TokenParserBroker $broker) + { + if (false !== $pos = array_search($broker, $this->brokers)) { + unset($this->brokers[$pos]); + } + } + + /** * Gets a suitable TokenParser for a tag. * * First looks in parsers, then in brokers. @@ -86,7 +111,11 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface } $broker = prev($this->brokers); } - return null; + } + + public function getParsers() + { + return $this->parsers; } public function getParser() |
