<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
maba / twig-template-modification-bundle example snippets
new Maba\Bundle\WebpackBundle\MabaTwigTemplateModificationBundle(),
use Maba\Bundle\TwigTemplateModificationBundle\Service\TwigNodeReplacerInterface;
use Maba\Bundle\TwigTemplateModificationBundle\Entity\TemplateContext;
use Twig_Node as Node;
class MyNodeReplacer implements TwigNodeReplacerInterface
{
/**
* @param Node $node
* @param TemplateContext $context
*
* @return null|string string if this node should be replaced with given twig code
*/
public function replace(Node $node, TemplateContext $context)
{
if ($node instanceof NameExpression && $node->getAttribute('name') === 'my_var') {
return '123';
}
return null;
}
}
$factory = $container->get('maba_twig_template_modification.factory.files_replacer');
$replacer = $factory->createFilesReplacer(new MyNodeReplacer());
// both arguments (closures) are optional
$replacer->replace(function($filePath, $contents, $notices) {
// log or write to output before replacing file in $filePath with $contents
}, function (array $notices) use ($output) {
// log or write to output notices
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.