<?phprequire_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(),
useMaba\Bundle\TwigTemplateModificationBundle\Service\TwigNodeReplacerInterface;
useMaba\Bundle\TwigTemplateModificationBundle\Entity\TemplateContext;
useTwig_NodeasNode;
classMyNodeReplacerimplementsTwigNodeReplacerInterface{
/**
* @param Node $node
* @param TemplateContext $context
*
* @return null|string string if this node should be replaced with given twig code
*/publicfunctionreplace(Node $node, TemplateContext $context){
if ($node instanceof NameExpression && $node->getAttribute('name') === 'my_var') {
return'123';
}
returnnull;
}
}
$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.