maj
This commit is contained in:
27
system/src/Twig/DeferredExtension/DeferredDeclareNode.php
Normal file
27
system/src/Twig/DeferredExtension/DeferredDeclareNode.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the rybakit/twig-deferred-extension package.
|
||||
*
|
||||
* (c) Eugene Leonovich <gen.work@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Twig\DeferredExtension;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Node;
|
||||
|
||||
final class DeferredDeclareNode extends Node
|
||||
{
|
||||
public function compile(Compiler $compiler) : void
|
||||
{
|
||||
$compiler
|
||||
->write("private \$deferred;\n")
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ namespace Twig\DeferredExtension;
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Node;
|
||||
|
||||
final class DeferredExtensionNode extends Node
|
||||
final class DeferredInitializeNode extends Node
|
||||
{
|
||||
public function compile(Compiler $compiler) : void
|
||||
{
|
||||
@@ -34,8 +34,9 @@ final class DeferredNodeVisitor implements NodeVisitorInterface
|
||||
public function leaveNode(Node $node, Environment $env) : ?Node
|
||||
{
|
||||
if ($this->hasDeferred && $node instanceof ModuleNode) {
|
||||
$node->setNode('constructor_end', new Node([new DeferredExtensionNode(), $node->getNode('constructor_end')]));
|
||||
$node->setNode('display_end', new Node([new DeferredNode(), $node->getNode('display_end')]));
|
||||
$node->getNode('constructor_end')->setNode('deferred_initialize', new DeferredInitializeNode());
|
||||
$node->getNode('display_end')->setNode('deferred_resolve', new DeferredResolveNode());
|
||||
$node->getNode('class_end')->setNode('deferred_declare', new DeferredDeclareNode());
|
||||
$this->hasDeferred = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,9 @@ final class DeferredNodeVisitorCompat implements NodeVisitorInterface
|
||||
public function leaveNode(\Twig_NodeInterface $node, Environment $env): ?Node
|
||||
{
|
||||
if ($this->hasDeferred && $node instanceof ModuleNode) {
|
||||
$node->setNode('constructor_end', new Node([new DeferredExtensionNode(), $node->getNode('constructor_end')]));
|
||||
$node->setNode('display_end', new Node([new DeferredNode(), $node->getNode('display_end')]));
|
||||
$node->getNode('constructor_end')->setNode('deferred_initialize', new DeferredInitializeNode());
|
||||
$node->getNode('display_end')->setNode('deferred_resolve', new DeferredResolveNode());
|
||||
$node->getNode('class_end')->setNode('deferred_declare', new DeferredDeclareNode());
|
||||
$this->hasDeferred = false;
|
||||
}
|
||||
|
||||
|
||||
27
system/src/Twig/DeferredExtension/DeferredResolveNode.php
Normal file
27
system/src/Twig/DeferredExtension/DeferredResolveNode.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the rybakit/twig-deferred-extension package.
|
||||
*
|
||||
* (c) Eugene Leonovich <gen.work@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Twig\DeferredExtension;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Node;
|
||||
|
||||
final class DeferredResolveNode extends Node
|
||||
{
|
||||
public function compile(Compiler $compiler) : void
|
||||
{
|
||||
$compiler
|
||||
->write("\$this->deferred->resolve(\$this, \$context, \$blocks);\n")
|
||||
;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user