Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 /**
  * @return array
  */
 protected function getSystemVariableValues()
 {
     if (null === $this->systemVariables) {
         $this->systemVariables = $this->variablesProvider->getSystemVariableValues();
     }
     return $this->systemVariables;
 }
Exemplo n.º 3
0
 /**
  * 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);
 }