public function testGetSystemVariableValues() { $provider1 = $this->getMock('Oro\\Bundle\\EmailBundle\\Provider\\SystemVariablesProviderInterface'); $provider1->expects($this->once())->method('getVariableValues')->will($this->returnValue(['var1' => 'val1'])); $provider2 = $this->getMock('Oro\\Bundle\\EmailBundle\\Provider\\SystemVariablesProviderInterface'); $provider2->expects($this->once())->method('getVariableValues')->will($this->returnValue(['var2' => 'val2'])); $this->provider->addSystemVariablesProvider($provider1); $this->provider->addSystemVariablesProvider($provider2); $result = $this->provider->getSystemVariableValues(); $this->assertEquals(['var1' => 'val1', 'var2' => 'val2'], $result); }
/** * @return array */ protected function getSystemVariableValues() { if (null === $this->systemVariables) { $this->systemVariables = $this->variablesProvider->getSystemVariableValues(); } return $this->systemVariables; }
/** * Compile email message * * @param EmailTemplateInterface $template * @param array $templateParams * * @return array first element is email subject, second - message */ public function compileMessage(EmailTemplateInterface $template, array $templateParams = array()) { $templateParams['system'] = $this->variablesProvider->getSystemVariableValues(); $subject = $template->getSubject(); $content = $template->getContent(); if (isset($templateParams['entity'])) { $subject = $this->processDateTimeVariables($subject, $templateParams['entity']); $content = $this->processDateTimeVariables($content, $templateParams['entity']); } $templateRendered = $this->render($content, $templateParams); $subjectRendered = $this->render($subject, $templateParams); return array($subjectRendered, $templateRendered); }