Replace deprecated Twig class references, refs: #4209.
This commit is contained in:
parent
8c1106f027
commit
c86bec7f08
|
|
@ -9,8 +9,8 @@ use Cms\Twig\Extension as CmsTwigExtension;
|
|||
use Cms\Components\ViewBag;
|
||||
use System\Twig\Extension as SystemTwigExtension;
|
||||
use October\Rain\Halcyon\Processors\SectionParser;
|
||||
use Twig_Source;
|
||||
use Twig_Environment;
|
||||
use Twig\Source as TwigSource;
|
||||
use Twig\Environment as TwigEnvironment;
|
||||
use ApplicationException;
|
||||
|
||||
/**
|
||||
|
|
@ -405,16 +405,16 @@ class CmsCompoundObject extends CmsObject
|
|||
* @link http://twig.sensiolabs.org/doc/internals.html Twig internals
|
||||
* @param mixed $markup Specifies the markup content.
|
||||
* Use FALSE to load the content from the markup section.
|
||||
* @return Twig_Node_Module A node tree
|
||||
* @return Twig\Node\ModuleNode A node tree
|
||||
*/
|
||||
public function getTwigNodeTree($markup = false)
|
||||
{
|
||||
$loader = new TwigLoader();
|
||||
$twig = new Twig_Environment($loader, []);
|
||||
$twig = new TwigEnvironment($loader, []);
|
||||
$twig->addExtension(new CmsTwigExtension());
|
||||
$twig->addExtension(new SystemTwigExtension);
|
||||
|
||||
$stream = $twig->tokenize(new Twig_Source($markup === false ? $this->markup : $markup, 'getTwigNodeTree'));
|
||||
$stream = $twig->tokenize(new TwigSource($markup === false ? $this->markup : $markup, 'getTwigNodeTree'));
|
||||
return $twig->parse($stream);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Classes;
|
||||
|
||||
use File;
|
||||
use Twig_Error;
|
||||
use Twig\Error\Error as TwigError;
|
||||
use October\Rain\Exception\ApplicationException;
|
||||
use October\Rain\Halcyon\Processors\SectionParser;
|
||||
use Exception;
|
||||
|
|
@ -199,7 +199,7 @@ class CmsException extends ApplicationException
|
|||
protected function processTwig(Exception $exception)
|
||||
{
|
||||
// Must be a Twig related exception
|
||||
if (!$exception instanceof Twig_Error) {
|
||||
if (!$exception instanceof TwigError) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ class CodeParser
|
|||
|
||||
/**
|
||||
* Writes content with concurrency support and cache busting
|
||||
* This work is based on the Twig_Cache_Filesystem class
|
||||
* This work is based on the Twig\Cache\FilesystemCache class
|
||||
*/
|
||||
protected function writeContentSafe($path, $content)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ use Request;
|
|||
use Response;
|
||||
use Exception;
|
||||
use BackendAuth;
|
||||
use Twig_Environment;
|
||||
use Twig_Cache_Filesystem;
|
||||
use Twig\Environment as TwigEnvironment;
|
||||
use Twig\Cache\FilesystemCache as TwigCacheFilesystem;
|
||||
use Cms\Twig\Loader as TwigLoader;
|
||||
use Cms\Twig\DebugExtension;
|
||||
use Cms\Twig\Extension as CmsTwigExtension;
|
||||
|
|
@ -75,7 +75,7 @@ class Controller
|
|||
protected $layoutObj;
|
||||
|
||||
/**
|
||||
* @var \Twig_Environment Keeps the Twig environment object.
|
||||
* @var TwigEnvironment Keeps the Twig environment object.
|
||||
*/
|
||||
protected $twig;
|
||||
|
||||
|
|
@ -600,13 +600,13 @@ class Controller
|
|||
];
|
||||
|
||||
if ($useCache) {
|
||||
$options['cache'] = new Twig_Cache_Filesystem(
|
||||
$options['cache'] = new TwigCacheFilesystem(
|
||||
storage_path().'/cms/twig',
|
||||
$forceBytecode ? Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION : 0
|
||||
$forceBytecode ? TwigCacheFilesystem::FORCE_BYTECODE_INVALIDATION : 0
|
||||
);
|
||||
}
|
||||
|
||||
$this->twig = new Twig_Environment($this->loader, $options);
|
||||
$this->twig = new TwigEnvironment($this->loader, $options);
|
||||
$this->twig->addExtension(new CmsTwigExtension($this));
|
||||
$this->twig->addExtension(new SystemTwigExtension);
|
||||
|
||||
|
|
@ -1272,7 +1272,7 @@ class Controller
|
|||
|
||||
/**
|
||||
* Returns the Twig environment.
|
||||
* @return Twig_Environment
|
||||
* @return TwigEnvironment
|
||||
*/
|
||||
public function getTwig()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a component node
|
||||
|
|
@ -9,9 +9,9 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class ComponentNode extends Twig_Node
|
||||
class ComponentNode extends TwigNode
|
||||
{
|
||||
public function __construct(Twig_Node $nodes, $paramNames, $lineno, $tag = 'component')
|
||||
public function __construct(TwigNode $nodes, $paramNames, $lineno, $tag = 'component')
|
||||
{
|
||||
parent::__construct(['nodes' => $nodes], ['names' => $paramNames], $lineno, $tag);
|
||||
}
|
||||
|
|
@ -19,9 +19,9 @@ class ComponentNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig_Error_Syntax;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
use Twig\Error\SyntaxError as TwigErrorSyntax;
|
||||
|
||||
/**
|
||||
* Parser for the `{% component %}` Twig tag.
|
||||
|
|
@ -13,15 +13,15 @@ use Twig_Error_Syntax;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class ComponentTokenParser extends Twig_TokenParser
|
||||
class ComponentTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
* @return TwigNode A TwigNode instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$lineno = $token->getLine();
|
||||
$stream = $this->parser->getStream();
|
||||
|
|
@ -35,18 +35,18 @@ class ComponentTokenParser extends Twig_TokenParser
|
|||
$current = $stream->next();
|
||||
|
||||
switch ($current->getType()) {
|
||||
case Twig_Token::NAME_TYPE:
|
||||
case TwigToken::NAME_TYPE:
|
||||
$paramNames[] = $current->getValue();
|
||||
$stream->expect(Twig_Token::OPERATOR_TYPE, '=');
|
||||
$stream->expect(TwigToken::OPERATOR_TYPE, '=');
|
||||
$nodes[] = $this->parser->getExpressionParser()->parseExpression();
|
||||
break;
|
||||
|
||||
case Twig_Token::BLOCK_END_TYPE:
|
||||
case TwigToken::BLOCK_END_TYPE:
|
||||
$end = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Twig_Error_Syntax(
|
||||
throw new TwigErrorSyntax(
|
||||
sprintf('Invalid syntax in the component tag. Line %s', $lineno),
|
||||
$stream->getCurrent()->getLine(),
|
||||
$stream->getSourceContext()
|
||||
|
|
@ -55,7 +55,7 @@ class ComponentTokenParser extends Twig_TokenParser
|
|||
}
|
||||
}
|
||||
|
||||
return new ComponentNode(new Twig_Node($nodes), $paramNames, $token->getLine(), $this->getTag());
|
||||
return new ComponentNode(new TwigNode($nodes), $paramNames, $token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a content node
|
||||
|
|
@ -9,9 +9,9 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class ContentNode extends Twig_Node
|
||||
class ContentNode extends TwigNode
|
||||
{
|
||||
public function __construct(Twig_Node $nodes, $paramNames, $lineno, $tag = 'content')
|
||||
public function __construct(TwigNode $nodes, $paramNames, $lineno, $tag = 'content')
|
||||
{
|
||||
parent::__construct(['nodes' => $nodes], ['names' => $paramNames], $lineno, $tag);
|
||||
}
|
||||
|
|
@ -19,9 +19,9 @@ class ContentNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig_Error_Syntax;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
use Twig\Error\SyntaxError as TwigErrorSyntax;
|
||||
|
||||
/**
|
||||
* Parser for the `{% content %}` Twig tag.
|
||||
|
|
@ -17,15 +17,15 @@ use Twig_Error_Syntax;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class ContentTokenParser extends Twig_TokenParser
|
||||
class ContentTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
* @return TwigNode A TwigNode instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$lineno = $token->getLine();
|
||||
$stream = $this->parser->getStream();
|
||||
|
|
@ -39,18 +39,18 @@ class ContentTokenParser extends Twig_TokenParser
|
|||
$current = $stream->next();
|
||||
|
||||
switch ($current->getType()) {
|
||||
case Twig_Token::NAME_TYPE:
|
||||
case TwigToken::NAME_TYPE:
|
||||
$paramNames[] = $current->getValue();
|
||||
$stream->expect(Twig_Token::OPERATOR_TYPE, '=');
|
||||
$stream->expect(TwigToken::OPERATOR_TYPE, '=');
|
||||
$nodes[] = $this->parser->getExpressionParser()->parseExpression();
|
||||
break;
|
||||
|
||||
case Twig_Token::BLOCK_END_TYPE:
|
||||
case TwigToken::BLOCK_END_TYPE:
|
||||
$end = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Twig_Error_Syntax(
|
||||
throw new TwigErrorSyntax(
|
||||
sprintf('Invalid syntax in the content tag. Line %s', $lineno),
|
||||
$stream->getCurrent()->getLine(),
|
||||
$stream->getSourceContext()
|
||||
|
|
@ -59,7 +59,7 @@ class ContentTokenParser extends Twig_TokenParser
|
|||
}
|
||||
}
|
||||
|
||||
return new ContentNode(new Twig_Node($nodes), $paramNames, $token->getLine(), $this->getTag());
|
||||
return new ContentNode(new TwigNode($nodes), $paramNames, $token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Template;
|
||||
use Twig_Extension;
|
||||
use Twig_Environment;
|
||||
use Twig_SimpleFunction;
|
||||
use Twig\Template as TwigTemplate;
|
||||
use Twig\Extension\AbstractExtension as TwigExtension;
|
||||
use Twig\Environment as TwigEnvironment;
|
||||
use Twig\TwigFunction as TwigSimpleFunction;
|
||||
use Cms\Classes\Controller;
|
||||
use Cms\Classes\ComponentBase;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
|
|
@ -12,7 +12,7 @@ use Illuminate\Support\Debug\HtmlDumper;
|
|||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
use October\Rain\Database\Model;
|
||||
|
||||
class DebugExtension extends Twig_Extension
|
||||
class DebugExtension extends TwigExtension
|
||||
{
|
||||
const PAGE_CAPTION = 'Page variables';
|
||||
const ARRAY_CAPTION = 'Array variables';
|
||||
|
|
@ -68,7 +68,7 @@ class DebugExtension extends Twig_Extension
|
|||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new Twig_SimpleFunction('dump', [$this, 'runDump'], [
|
||||
new TwigSimpleFunction('dump', [$this, 'runDump'], [
|
||||
'is_safe' => ['html'],
|
||||
'needs_context' => true,
|
||||
'needs_environment' => true
|
||||
|
|
@ -79,11 +79,11 @@ class DebugExtension extends Twig_Extension
|
|||
/**
|
||||
* Processes the dump variables, if none is supplied, all the twig
|
||||
* template variables are used
|
||||
* @param Twig_Environment $env
|
||||
* @param TwigEnvironment $env
|
||||
* @param array $context
|
||||
* @return string
|
||||
*/
|
||||
public function runDump(Twig_Environment $env, $context)
|
||||
public function runDump(TwigEnvironment $env, $context)
|
||||
{
|
||||
if (!$env->isDebug()) {
|
||||
return;
|
||||
|
|
@ -97,7 +97,7 @@ class DebugExtension extends Twig_Extension
|
|||
$this->variablePrefix = true;
|
||||
$vars = [];
|
||||
foreach ($context as $key => $value) {
|
||||
if (!$value instanceof Twig_Template) {
|
||||
if (!$value instanceof TwigTemplate) {
|
||||
$vars[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a "default" node
|
||||
|
|
@ -9,7 +9,7 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class DefaultNode extends Twig_Node
|
||||
class DefaultNode extends TwigNode
|
||||
{
|
||||
public function __construct($lineno, $tag = 'default')
|
||||
{
|
||||
|
|
@ -19,9 +19,9 @@ class DefaultNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
|
||||
/**
|
||||
* Parser for the `{% default %}` Twig tag.
|
||||
|
|
@ -14,18 +14,18 @@ use Twig_TokenParser;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class DefaultTokenParser extends Twig_TokenParser
|
||||
class DefaultTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
* @return Twig\Node\Node A Twig\Node\Node instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$stream = $this->parser->getStream();
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$stream->expect(TwigToken::BLOCK_END_TYPE);
|
||||
return new DefaultNode($token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
use Block;
|
||||
use Event;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFilter;
|
||||
use Twig_SimpleFunction;
|
||||
use Twig\Extension\AbstractExtension as TwigExtension;
|
||||
use Twig\TwigFilter as TwigSimpleFilter;
|
||||
use Twig\TwigFunction as TwigSimpleFunction;
|
||||
use Cms\Classes\Controller;
|
||||
|
||||
/**
|
||||
|
|
@ -13,7 +13,7 @@ use Cms\Classes\Controller;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class Extension extends Twig_Extension
|
||||
class Extension extends TwigExtension
|
||||
{
|
||||
/**
|
||||
* @var \Cms\Classes\Controller A reference to the CMS controller.
|
||||
|
|
@ -37,11 +37,11 @@ class Extension extends Twig_Extension
|
|||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new Twig_SimpleFunction('page', [$this, 'pageFunction'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFunction('partial', [$this, 'partialFunction'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFunction('content', [$this, 'contentFunction'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFunction('component', [$this, 'componentFunction'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFunction('placeholder', [$this, 'placeholderFunction'], ['is_safe' => ['html']]),
|
||||
new TwigSimpleFunction('page', [$this, 'pageFunction'], ['is_safe' => ['html']]),
|
||||
new TwigSimpleFunction('partial', [$this, 'partialFunction'], ['is_safe' => ['html']]),
|
||||
new TwigSimpleFunction('content', [$this, 'contentFunction'], ['is_safe' => ['html']]),
|
||||
new TwigSimpleFunction('component', [$this, 'componentFunction'], ['is_safe' => ['html']]),
|
||||
new TwigSimpleFunction('placeholder', [$this, 'placeholderFunction'], ['is_safe' => ['html']]),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -53,8 +53,8 @@ class Extension extends Twig_Extension
|
|||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
new Twig_SimpleFilter('page', [$this, 'pageFilter'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFilter('theme', [$this, 'themeFilter'], ['is_safe' => ['html']]),
|
||||
new TwigSimpleFilter('page', [$this, 'pageFilter'], ['is_safe' => ['html']]),
|
||||
new TwigSimpleFilter('theme', [$this, 'themeFilter'], ['is_safe' => ['html']]),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a flash node
|
||||
|
|
@ -9,9 +9,9 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class FlashNode extends Twig_Node
|
||||
class FlashNode extends TwigNode
|
||||
{
|
||||
public function __construct($name, Twig_Node $body, $lineno, $tag = 'flash')
|
||||
public function __construct($name, TwigNode $body, $lineno, $tag = 'flash')
|
||||
{
|
||||
parent::__construct(['body' => $body], ['name' => $name], $lineno, $tag);
|
||||
}
|
||||
|
|
@ -19,9 +19,9 @@ class FlashNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$attrib = $this->getAttribute('name');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
|
||||
/**
|
||||
* Parser for the {% flash %} Twig tag.
|
||||
|
|
@ -10,35 +10,35 @@ use Twig_TokenParser;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class FlashTokenParser extends Twig_TokenParser
|
||||
class FlashTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
*
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @return TwigNode A TwigNode instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$lineno = $token->getLine();
|
||||
$stream = $this->parser->getStream();
|
||||
|
||||
if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
|
||||
if ($token = $stream->nextIf(TwigToken::NAME_TYPE)) {
|
||||
$name = $token->getValue();
|
||||
}
|
||||
else {
|
||||
$name = 'all';
|
||||
}
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$stream->expect(TwigToken::BLOCK_END_TYPE);
|
||||
|
||||
$body = $this->parser->subparse([$this, 'decideIfEnd'], true);
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$stream->expect(TwigToken::BLOCK_END_TYPE);
|
||||
|
||||
return new FlashNode($name, $body, $lineno, $this->getTag());
|
||||
}
|
||||
|
||||
public function decideIfEnd(Twig_Token $token)
|
||||
public function decideIfEnd(TwigToken $token)
|
||||
{
|
||||
return $token->test(['endflash']);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use System\Classes\CombineAssets;
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a "framework" node
|
||||
|
|
@ -10,7 +10,7 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class FrameworkNode extends Twig_Node
|
||||
class FrameworkNode extends TwigNode
|
||||
{
|
||||
public function __construct($name, $lineno, $tag = 'framework')
|
||||
{
|
||||
|
|
@ -20,9 +20,9 @@ class FrameworkNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$attrib = $this->getAttribute('name');
|
||||
$includeExtras = strtolower(trim($attrib)) == 'extras';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
|
||||
/**
|
||||
* Parser for the `{% framework %}` Twig tag.
|
||||
|
|
@ -11,25 +11,25 @@ use Twig_TokenParser;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class FrameworkTokenParser extends Twig_TokenParser
|
||||
class FrameworkTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
* @return Twig\Node\Node A Twig\Node\Node instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$lineno = $token->getLine();
|
||||
$stream = $this->parser->getStream();
|
||||
|
||||
$name = null;
|
||||
if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
|
||||
if ($token = $stream->nextIf(TwigToken::NAME_TYPE)) {
|
||||
$name = $token->getValue();
|
||||
}
|
||||
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$stream->expect(TwigToken::BLOCK_END_TYPE);
|
||||
return new FrameworkNode($name, $lineno, $this->getTag());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Event;
|
||||
use Twig_Source;
|
||||
use Twig_LoaderInterface;
|
||||
use Twig\Source as TwigSource;;
|
||||
use Twig\Loader\LoaderInterface as TwigLoaderInterface;
|
||||
use Cms\Contracts\CmsObject;
|
||||
use System\Twig\Loader as LoaderBase;
|
||||
use Cms\Classes\Partial as CmsPartial;
|
||||
|
|
@ -13,7 +13,7 @@ use Cms\Classes\Partial as CmsPartial;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class Loader extends LoaderBase implements Twig_LoaderInterface
|
||||
class Loader extends LoaderBase implements TwigLoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var \Cms\Classes\CmsCompoundObject A CMS object to load the template from.
|
||||
|
|
@ -60,7 +60,7 @@ class Loader extends LoaderBase implements Twig_LoaderInterface
|
|||
$dataHolder = (object) ['content' => $content];
|
||||
Event::fire('cms.template.processTwigContent', [$this->obj, $dataHolder]);
|
||||
|
||||
return new Twig_Source($dataHolder->content, $name);
|
||||
return new TwigSource($dataHolder->content, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a page node
|
||||
|
|
@ -9,7 +9,7 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class PageNode extends Twig_Node
|
||||
class PageNode extends TwigNode
|
||||
{
|
||||
public function __construct($lineno, $tag = 'page')
|
||||
{
|
||||
|
|
@ -19,9 +19,9 @@ class PageNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
|
||||
/**
|
||||
* Parser for the `{% page %}` Twig tag.
|
||||
|
|
@ -11,18 +11,18 @@ use Twig_TokenParser;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class PageTokenParser extends Twig_TokenParser
|
||||
class PageTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
* @return Twig\Node\Node A Twig\Node\Node instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$stream = $this->parser->getStream();
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$stream->expect(TwigToken::BLOCK_END_TYPE);
|
||||
return new PageNode($token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a partial node
|
||||
|
|
@ -9,9 +9,9 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class PartialNode extends Twig_Node
|
||||
class PartialNode extends TwigNode
|
||||
{
|
||||
public function __construct(Twig_Node $nodes, $paramNames, $lineno, $tag = 'partial')
|
||||
public function __construct(TwigNode $nodes, $paramNames, $lineno, $tag = 'partial')
|
||||
{
|
||||
parent::__construct(['nodes' => $nodes], ['names' => $paramNames], $lineno, $tag);
|
||||
}
|
||||
|
|
@ -19,9 +19,9 @@ class PartialNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig_Error_Syntax;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
use Twig\Error\SyntaxError as TwigErrorSyntax;
|
||||
|
||||
/**
|
||||
* Parser for the `{% partial %}` Twig tag.
|
||||
|
|
@ -17,15 +17,15 @@ use Twig_Error_Syntax;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class PartialTokenParser extends Twig_TokenParser
|
||||
class PartialTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
* @return TwigNode A TwigNode instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$lineno = $token->getLine();
|
||||
$stream = $this->parser->getStream();
|
||||
|
|
@ -39,18 +39,18 @@ class PartialTokenParser extends Twig_TokenParser
|
|||
$current = $stream->next();
|
||||
|
||||
switch ($current->getType()) {
|
||||
case Twig_Token::NAME_TYPE:
|
||||
case TwigToken::NAME_TYPE:
|
||||
$paramNames[] = $current->getValue();
|
||||
$stream->expect(Twig_Token::OPERATOR_TYPE, '=');
|
||||
$stream->expect(TwigToken::OPERATOR_TYPE, '=');
|
||||
$nodes[] = $this->parser->getExpressionParser()->parseExpression();
|
||||
break;
|
||||
|
||||
case Twig_Token::BLOCK_END_TYPE:
|
||||
case TwigToken::BLOCK_END_TYPE:
|
||||
$end = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Twig_Error_Syntax(
|
||||
throw new TwigErrorSyntax(
|
||||
sprintf('Invalid syntax in the partial tag. Line %s', $lineno),
|
||||
$stream->getCurrent()->getLine(),
|
||||
$stream->getSourceContext()
|
||||
|
|
@ -59,7 +59,7 @@ class PartialTokenParser extends Twig_TokenParser
|
|||
}
|
||||
}
|
||||
|
||||
return new PartialNode(new Twig_Node($nodes), $paramNames, $token->getLine(), $this->getTag());
|
||||
return new PartialNode(new TwigNode($nodes), $paramNames, $token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a placeholder node
|
||||
|
|
@ -9,7 +9,7 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class PlaceholderNode extends Twig_Node
|
||||
class PlaceholderNode extends TwigNode
|
||||
{
|
||||
public function __construct($name, $paramValues, $body, $lineno, $tag = 'placeholder')
|
||||
{
|
||||
|
|
@ -28,9 +28,9 @@ class PlaceholderNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$hasBody = $this->hasNode('default');
|
||||
$varId = '__placeholder_'.$this->getAttribute('name').'_default_contents';
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig_Error_Syntax;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
use Twig\Error\SyntaxError as TwigErrorSyntax;
|
||||
|
||||
/**
|
||||
* Parser for the `{% placeholder %}` Twig tag.
|
||||
|
|
@ -19,27 +19,27 @@ use Twig_Error_Syntax;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class PlaceholderTokenParser extends Twig_TokenParser
|
||||
class PlaceholderTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
* @return TwigNode A TwigNode instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$stream = $this->parser->getStream();
|
||||
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
||||
$name = $stream->expect(TwigToken::NAME_TYPE)->getValue();
|
||||
$body = null;
|
||||
$params = [];
|
||||
|
||||
if ($stream->test(Twig_Token::NAME_TYPE, 'default')) {
|
||||
if ($stream->test(TwigToken::NAME_TYPE, 'default')) {
|
||||
$stream->next();
|
||||
$params = $this->loadParams($stream);
|
||||
|
||||
$body = $this->parser->subparse([$this, 'decidePlaceholderEnd'], true);
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$stream->expect(TwigToken::BLOCK_END_TYPE);
|
||||
}
|
||||
else {
|
||||
$params = $this->loadParams($stream);
|
||||
|
|
@ -48,7 +48,7 @@ class PlaceholderTokenParser extends Twig_TokenParser
|
|||
return new PlaceholderNode($name, $params, $body, $token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
public function decidePlaceholderEnd(Twig_Token $token)
|
||||
public function decidePlaceholderEnd(TwigToken $token)
|
||||
{
|
||||
return $token->test('endplaceholder');
|
||||
}
|
||||
|
|
@ -62,19 +62,19 @@ class PlaceholderTokenParser extends Twig_TokenParser
|
|||
$current = $stream->next();
|
||||
|
||||
switch ($current->getType()) {
|
||||
case Twig_Token::NAME_TYPE:
|
||||
case TwigToken::NAME_TYPE:
|
||||
$paramName = $current->getValue();
|
||||
$stream->expect(Twig_Token::OPERATOR_TYPE, '=');
|
||||
$stream->expect(TwigToken::OPERATOR_TYPE, '=');
|
||||
$current = $stream->next();
|
||||
$params[$paramName] = $current->getValue();
|
||||
break;
|
||||
|
||||
case Twig_Token::BLOCK_END_TYPE:
|
||||
case TwigToken::BLOCK_END_TYPE:
|
||||
$end = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Twig_Error_Syntax(
|
||||
throw new TwigErrorSyntax(
|
||||
sprintf('Invalid syntax in the placeholder tag. Line %s', $stream->getCurrent()->getLine()),
|
||||
$stream->getCurrent()->getLine(),
|
||||
$stream->getSourceContext()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a put node
|
||||
|
|
@ -9,9 +9,9 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class PutNode extends Twig_Node
|
||||
class PutNode extends TwigNode
|
||||
{
|
||||
public function __construct(Twig_Node $body, $name, $endType, $lineno, $tag = 'put')
|
||||
public function __construct(TwigNode $body, $name, $endType, $lineno, $tag = 'put')
|
||||
{
|
||||
parent::__construct(['body' => $body], ['name' => $name, 'endType' => $endType], $lineno, $tag);
|
||||
}
|
||||
|
|
@ -19,9 +19,9 @@ class PutNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
|
||||
/**
|
||||
* Parser for the `{% put %}` Twig tag.
|
||||
|
|
@ -20,33 +20,33 @@ use Twig_TokenParser;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class PutTokenParser extends Twig_TokenParser
|
||||
class PutTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
* @return Twig\Node\Node A Twig\Node\Node instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$lineno = $token->getLine();
|
||||
$stream = $this->parser->getStream();
|
||||
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$name = $stream->expect(TwigToken::NAME_TYPE)->getValue();
|
||||
$stream->expect(TwigToken::BLOCK_END_TYPE);
|
||||
$body = $this->parser->subparse([$this, 'decidePutEnd'], true);
|
||||
|
||||
$endType = null;
|
||||
if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
|
||||
if ($token = $stream->nextIf(TwigToken::NAME_TYPE)) {
|
||||
$endType = $token->getValue();
|
||||
}
|
||||
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$stream->expect(TwigToken::BLOCK_END_TYPE);
|
||||
|
||||
return new PutNode($body, $name, $endType, $lineno, $this->getTag());
|
||||
}
|
||||
|
||||
public function decidePutEnd(Twig_Token $token)
|
||||
public function decidePutEnd(TwigToken $token)
|
||||
{
|
||||
return $token->test('endput');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a "scripts" node
|
||||
|
|
@ -9,7 +9,7 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class ScriptsNode extends Twig_Node
|
||||
class ScriptsNode extends TwigNode
|
||||
{
|
||||
public function __construct($lineno, $tag = 'scripts')
|
||||
{
|
||||
|
|
@ -19,9 +19,9 @@ class ScriptsNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
|
||||
/**
|
||||
* Parser for the `{% scripts %}` Twig tag.
|
||||
|
|
@ -11,18 +11,18 @@ use Twig_TokenParser;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class ScriptsTokenParser extends Twig_TokenParser
|
||||
class ScriptsTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
* @return Twig\Node\Node A Twig\Node\Node instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$stream = $this->parser->getStream();
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$stream->expect(TwigToken::BLOCK_END_TYPE);
|
||||
return new ScriptsNode($token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a "styles" node
|
||||
|
|
@ -9,7 +9,7 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class StylesNode extends Twig_Node
|
||||
class StylesNode extends TwigNode
|
||||
{
|
||||
public function __construct($lineno, $tag = 'styles')
|
||||
{
|
||||
|
|
@ -19,9 +19,9 @@ class StylesNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace Cms\Twig;
|
||||
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
|
||||
/**
|
||||
* Parser for the `{% styles %}` Twig tag.
|
||||
|
|
@ -11,18 +11,18 @@ use Twig_TokenParser;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class StylesTokenParser extends Twig_TokenParser
|
||||
class StylesTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
* @return Twig\Node\Node A Twig\Node\Node instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$stream = $this->parser->getStream();
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$stream->expect(TwigToken::BLOCK_END_TYPE);
|
||||
return new StylesNode($token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ use Backend;
|
|||
use Request;
|
||||
use BackendMenu;
|
||||
use BackendAuth;
|
||||
use Twig_Environment;
|
||||
use Twig_Loader_String;
|
||||
use Twig\Environment as TwigEnvironment;
|
||||
use System\Classes\MailManager;
|
||||
use System\Classes\ErrorHandler;
|
||||
use System\Classes\MarkupManager;
|
||||
|
|
@ -281,7 +280,7 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
* Register system Twig environment
|
||||
*/
|
||||
App::singleton('twig.environment', function ($app) {
|
||||
$twig = new Twig_Environment(new TwigLoader, ['auto_reload' => true]);
|
||||
$twig = new TwigEnvironment(new TwigLoader, ['auto_reload' => true]);
|
||||
$twig->addExtension(new TwigExtension);
|
||||
return $twig;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ErrorHandler extends ErrorHandlerBase
|
|||
// {
|
||||
// // The Twig runtime error is not very useful
|
||||
// if (
|
||||
// $proposedException instanceof Twig_Error_Runtime &&
|
||||
// $proposedException instanceof \Twig\Error\RuntimeError &&
|
||||
// ($previousException = $proposedException->getPrevious()) &&
|
||||
// (!$previousException instanceof CmsException)
|
||||
// ) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php namespace System\Classes;
|
||||
|
||||
use Str;
|
||||
use Twig_TokenParser;
|
||||
use Twig_SimpleFilter;
|
||||
use Twig_SimpleFunction;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
use Twig\TwigFilter as TwigSimpleFilter;
|
||||
use Twig\TwigFunction as TwigSimpleFunction;
|
||||
use ApplicationException;
|
||||
|
||||
/**
|
||||
|
|
@ -243,7 +243,7 @@ class MarkupManager
|
|||
throw new ApplicationException(sprintf('The markup function for %s is not callable.', $name));
|
||||
}
|
||||
|
||||
$functions[] = new Twig_SimpleFunction($name, $callable, ['is_safe' => ['html']]);
|
||||
$functions[] = new TwigSimpleFunction($name, $callable, ['is_safe' => ['html']]);
|
||||
}
|
||||
|
||||
return $functions;
|
||||
|
|
@ -277,7 +277,7 @@ class MarkupManager
|
|||
throw new ApplicationException(sprintf('The markup filter for %s is not callable.', $name));
|
||||
}
|
||||
|
||||
$filters[] = new Twig_SimpleFilter($name, $callable, ['is_safe' => ['html']]);
|
||||
$filters[] = new TwigSimpleFilter($name, $callable, ['is_safe' => ['html']]);
|
||||
}
|
||||
|
||||
return $filters;
|
||||
|
|
@ -296,7 +296,7 @@ class MarkupManager
|
|||
|
||||
$extraParsers = $this->listTokenParsers();
|
||||
foreach ($extraParsers as $obj) {
|
||||
if (!$obj instanceof Twig_TokenParser) {
|
||||
if (!$obj instanceof TwigTokenParser) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace System\Twig;
|
||||
|
||||
use Twig_Environment;
|
||||
use Twig\Environment as TwigEnvironment;
|
||||
use Illuminate\Contracts\View\Engine as EngineInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -12,14 +12,14 @@ use Illuminate\Contracts\View\Engine as EngineInterface;
|
|||
class Engine implements EngineInterface
|
||||
{
|
||||
/**
|
||||
* @var Twig_Environment
|
||||
* @var TwigEnvironment
|
||||
*/
|
||||
protected $environment;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct(Twig_Environment $environment)
|
||||
public function __construct(TwigEnvironment $environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?php namespace System\Twig;
|
||||
|
||||
use Url;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFilter;
|
||||
use Twig\Extension\AbstractExtension as TwigExtension;
|
||||
use Twig\TwigFilter as TwigSimpleFilter;
|
||||
use System\Classes\MediaLibrary;
|
||||
use System\Classes\MarkupManager;
|
||||
|
||||
|
|
@ -12,9 +12,8 @@ use System\Classes\MarkupManager;
|
|||
* @package october\system
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class Extension extends Twig_Extension
|
||||
class Extension extends TwigExtension
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \System\Classes\MarkupManager A reference to the markup manager instance.
|
||||
*/
|
||||
|
|
@ -53,8 +52,8 @@ class Extension extends Twig_Extension
|
|||
public function getFilters()
|
||||
{
|
||||
$filters = [
|
||||
new Twig_SimpleFilter('app', [$this, 'appFilter'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFilter('media', [$this, 'mediaFilter'], ['is_safe' => ['html']]),
|
||||
new TwigSimpleFilter('app', [$this, 'appFilter'], ['is_safe' => ['html']]),
|
||||
new TwigSimpleFilter('media', [$this, 'mediaFilter'], ['is_safe' => ['html']]),
|
||||
];
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use App;
|
||||
use File;
|
||||
use Twig_Source;
|
||||
use Twig_LoaderInterface;
|
||||
use Twig\Source as TwigSource;;
|
||||
use Twig\Loader\LoaderInterface as TwigLoaderInterface;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
|
|
@ -12,7 +12,7 @@ use Exception;
|
|||
* @package october\system
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class Loader implements Twig_LoaderInterface
|
||||
class Loader implements TwigLoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string Expected file extension
|
||||
|
|
@ -52,7 +52,7 @@ class Loader implements Twig_LoaderInterface
|
|||
|
||||
public function getSourceContext($name)
|
||||
{
|
||||
return new Twig_Source(File::get($this->findTemplate($name)), $name);
|
||||
return new TwigSource(File::get($this->findTemplate($name)), $name);
|
||||
}
|
||||
|
||||
public function getCacheKey($name)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php namespace System\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Compiler;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Compiler as TwigCompiler;
|
||||
|
||||
/**
|
||||
* Represents a partial node
|
||||
|
|
@ -9,9 +9,9 @@ use Twig_Compiler;
|
|||
* @package october\cms
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class MailPartialNode extends Twig_Node
|
||||
class MailPartialNode extends TwigNode
|
||||
{
|
||||
public function __construct(Twig_Node $nodes, $paramNames, $body, $lineno, $tag = 'partial')
|
||||
public function __construct(TwigNode $nodes, $paramNames, $body, $lineno, $tag = 'partial')
|
||||
{
|
||||
$nodes = ['nodes' => $nodes];
|
||||
|
||||
|
|
@ -25,9 +25,9 @@ class MailPartialNode extends Twig_Node
|
|||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
||||
* @param TwigCompiler $compiler A TwigCompiler instance
|
||||
*/
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
public function compile(TwigCompiler $compiler)
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php namespace System\Twig;
|
||||
|
||||
use Twig_Node;
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
use Twig_Error_Syntax;
|
||||
use Twig\Node\Node as TwigNode;
|
||||
use Twig\Token as TwigToken;
|
||||
use Twig\TokenParser\AbstractTokenParser as TwigTokenParser;
|
||||
use Twig\Error\SyntaxError as TwigErrorSyntax;
|
||||
|
||||
/**
|
||||
* Parser for the `{% partial %}` Twig tag.
|
||||
|
|
@ -17,15 +17,15 @@ use Twig_Error_Syntax;
|
|||
* @package october\system
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class MailPartialTokenParser extends Twig_TokenParser
|
||||
class MailPartialTokenParser extends TwigTokenParser
|
||||
{
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param Twig_Token $token A Twig_Token instance
|
||||
* @return Twig_Node A Twig_Node instance
|
||||
* @param TwigToken $token A TwigToken instance
|
||||
* @return TwigNode A TwigNode instance
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
public function parse(TwigToken $token)
|
||||
{
|
||||
$lineno = $token->getLine();
|
||||
$stream = $this->parser->getStream();
|
||||
|
|
@ -41,26 +41,26 @@ class MailPartialTokenParser extends Twig_TokenParser
|
|||
$current = $stream->next();
|
||||
|
||||
if (
|
||||
$current->test(Twig_Token::NAME_TYPE, 'body') &&
|
||||
!$stream->test(Twig_Token::OPERATOR_TYPE, '=')
|
||||
$current->test(TwigToken::NAME_TYPE, 'body') &&
|
||||
!$stream->test(TwigToken::OPERATOR_TYPE, '=')
|
||||
) {
|
||||
$hasBody = true;
|
||||
$current = $stream->next();
|
||||
}
|
||||
|
||||
switch ($current->getType()) {
|
||||
case Twig_Token::NAME_TYPE:
|
||||
case TwigToken::NAME_TYPE:
|
||||
$paramNames[] = $current->getValue();
|
||||
$stream->expect(Twig_Token::OPERATOR_TYPE, '=');
|
||||
$stream->expect(TwigToken::OPERATOR_TYPE, '=');
|
||||
$nodes[] = $this->parser->getExpressionParser()->parseExpression();
|
||||
break;
|
||||
|
||||
case Twig_Token::BLOCK_END_TYPE:
|
||||
case TwigToken::BLOCK_END_TYPE:
|
||||
$end = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Twig_Error_Syntax(
|
||||
throw new TwigErrorSyntax(
|
||||
sprintf('Invalid syntax in the partial tag. Line %s', $lineno),
|
||||
$stream->getCurrent()->getLine(),
|
||||
$stream->getSourceContext()
|
||||
|
|
@ -71,13 +71,13 @@ class MailPartialTokenParser extends Twig_TokenParser
|
|||
|
||||
if ($hasBody) {
|
||||
$body = $this->parser->subparse([$this, 'decidePartialEnd'], true);
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$stream->expect(TwigToken::BLOCK_END_TYPE);
|
||||
}
|
||||
|
||||
return new MailPartialNode(new Twig_Node($nodes), $paramNames, $body, $token->getLine(), $this->getTag());
|
||||
return new MailPartialNode(new TwigNode($nodes), $paramNames, $body, $token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
public function decidePartialEnd(Twig_Token $token)
|
||||
public function decidePartialEnd(TwigToken $token)
|
||||
{
|
||||
return $token->test('endpartial');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue