This topic contains 4 replies, has 2 voices, and was last updated by mathijs 5 years, 7 months ago.
- Topic
I’ve created an extension with my custom function in it.
1234567891011121314151617181920212223242526class 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:
1234567xxx_opportunity.twig.helper:class: 'OpportunityBundle\Twig\AppExtension'public: falsearguments:- '@service_container'tags:- { name: twig.extension }When I look if it is found by ORO/Symfony 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:
1The template for xxxx has syntax error: Unknown "autologin" function at line 18.After a while I figured I should check out what the compiler did, and noticed the getOroEmail_EmailRendererService.php file(s) did not contain my extension.
12345678910111213$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['twiI’ve tried manually adding them to the generated file just to see what happens, and resaving the template, which went without errors this time. Yet, when I try to send it using my notificationrules, nothing gets sent. To make sure it wasn’t just a mail server error, I updated the template with nothing but “hello”, which did arrive in my inbox this time.
So right now I’m probably facing 2 issues, one is that Oro/Symfony doesn’t add the extension to getOroEmail_EmailRendererService.php, and the other is that even if I add it manually just for testing purposes, it still won’t send the email.
I’ve been stuck on this issue for a few days now and it’s really doing my head in. Anyone got the solution to this problem?
The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.