diff options
| author | czaks <marcin@6irc.net> | 2013-08-01 23:43:20 -0400 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-08-01 23:43:20 -0400 |
| commit | 1ed45ebe9e39724ec70098abfcd267d8ac478511 (patch) | |
| tree | da133b7426dedaf0785f64be752aa0437de7e80a /inc/lib/Twig/TokenParserBroker.php | |
| parent | dc84ccc6a8e0b6fd3fc626eb1f321e4cf2d05511 (diff) | |
| parent | 40ab2e0c1728fab613bc16a19ab8fcb3fa78c1d4 (diff) | |
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
Conflicts:
stylesheets/dark.css
stylesheets/futaba+vichan.css
stylesheets/miku.css
stylesheets/stripes.css
stylesheets/testorange.css
stylesheets/wasabi.css
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() |
