Exemplo n.º 1
0
 /**
  * @covers \Magento\Email\Block\Adminhtml\Template\Edit\Form::getVariables
  */
 public function testGetVariables()
 {
     $this->variablesMock->expects($this->once())->method('toOptionArray')->willReturn(['var1', 'var2', 'var3']);
     $this->variableFactoryMock->expects($this->once())->method('create')->willReturn($this->variableMock);
     $this->variableMock->expects($this->once())->method('getVariablesOptionArray')->willReturn(['custom var 1', 'custom var 2']);
     $this->registryMock->expects($this->once())->method('registry')->willReturn($this->templateMock);
     $this->templateMock->expects($this->once())->method('getId')->willReturn(1);
     $this->templateMock->expects($this->once())->method('getVariablesOptionArray')->willReturn(['template var 1', 'template var 2']);
     $this->assertEquals([['var1', 'var2', 'var3'], ['custom var 1', 'custom var 2'], ['template var 1', 'template var 2']], $this->form->getVariables());
 }
Exemplo n.º 2
0
 /**
  * Custom Variable directive
  *
  * @param string[] $construction
  * @return string
  */
 public function customvarDirective($construction)
 {
     $customVarValue = '';
     $params = $this->_getParameters($construction[2]);
     if (isset($params['code'])) {
         $variable = $this->_variableFactory->create()->setStoreId($this->getStoreId())->loadByCode($params['code']);
         $mode = $this->isPlainTemplateMode() ? \Magento\Variable\Model\Variable::TYPE_TEXT : \Magento\Variable\Model\Variable::TYPE_HTML;
         $value = $variable->getValue($mode);
         if ($value) {
             $customVarValue = $value;
         }
     }
     return $customVarValue;
 }
Exemplo n.º 3
0
 /**
  * Retrieve variables to insert into email
  *
  * @return array
  */
 public function getVariables()
 {
     $variables = [];
     $variables[] = $this->_variables->toOptionArray(true);
     $customVariables = $this->_variableFactory->create()->getVariablesOptionArray(true);
     if ($customVariables) {
         $variables[] = $customVariables;
     }
     /* @var $template \Magento\Email\Model\Template */
     $template = $this->_coreRegistry->registry('current_email_template');
     if ($template->getId() && ($templateVariables = $template->getVariablesOptionArray(true))) {
         $variables[] = $templateVariables;
     }
     return $variables;
 }