I've created an extension with my custom function in it.
class AppExtension extends \Twig_Extension { private $_container; public function __construct($container) { $this->_container = $container; } public function getFunctions() { return [ new \Twig_SimpleFunction('autologin', [$this, 'autologin'], ['is_safe' => ['all']]) ]; } public function autologin($customer, $url) { return sprintf(''); } public function getName() { return 'xxx_app_extension'; } }
I've added it to services.yml:
xxx_opportunity.twig.helper:
class: 'OpportunityBundle\Twig\AppExtension'
public: false
arguments:
- '@service_container'
tags:
- { name: twig.extension }
When I look if it is found by ORO by doing "php bin/console debug:twig", I can see my custom function appear in the list. When I try to implement it in an email template using the email template editor in OROcrm, I get the following error:
The template for xxxx has syntax error: Unknown "autologin" function at line 18.
This has been doing my head in for way too long, anyone with a solution?
Update:
$instance = new \Oro\Bundle\EmailBundle\Provider\EmailRenderer(${($_ = isset($this->services['oro_email $instance->addExtension(${($_ = isset($this->services['oro_ui.twig.html_tag']) ? $this->services['oro_u $instance->addExtension(${($_ = isset($this->services['oro_config.twig.config_extension']) ? $this->ser $instance->addExtension(${($_ = isset($this->services['oro_ui.twig.extension.formatter']) ? $this->serv $instance->addExtension(${($_ = isset($this->services['oro_locale.twig.address']) ? $this->services['or $instance->addExtension(${($_ = isset($this->services['oro_locale.twig.date_time']) ? $this->services[' $instance->addExtension(${($_ = isset($this->services['oro_entity.twig.extension.entity']) ? $this->ser $instance->addExtension(${($_ = isset($this->services['twig.extension.intl']) ? $this->services['twig.e $instance->addExtension(${($_ = isset($this->services['oro_locale.twig.date_time_organization']) ? $thi $instance->addExtension(${($_ = isset($this->services['oro_calendar.twig.dateformat']) ? $this->service $instance->addExtension(${($_ = isset($this->services['oro_calendar.twig.recurrence']) ? $this->service $instance->addExtension(${($_ = isset($this->services['oro_currency.twig.currency']) ? $this->services[ $instance->addExtension(${($_ = isset($this->services['twig.extension.routing']) ? $this->services['twi
This is what the compiler ends up with for getOroEmail_EmailRendererService.php, it is lacking my extension as you can see. How can I fix this?
OpportunityBundle\Twig
also present in the classAppExtension
? – DarkBee