Upgrade Twig library
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -54,6 +54,19 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
|
||||
$this->parsers[$parser->getTag()] = $parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -64,6 +77,18 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
|
||||
$this->brokers[] = $broker;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -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()
|
||||
|
Reference in New Issue
Block a user