Обновляет шаблон почтового сообщения.

@param array $templateData
@param array $search

@return array

@throws \marvin255\bxmigrate\migrate\Exception
501150
public function updateEmailTemplate(array $search, array $templateData)
    {
        if (!($template = $this->findEmailTemplate($search))) {
            throw new Exception("Email template for event {$templateData['EVENT_NAME']} not found");
        }

        $et = new CEventMessage;
        unset($templateData['EVENT_NAME'], $templateData['LID']);
        $res = $et->update($template['ID'], $templateData);
        if (!$res) {
            throw new Exception("Can't update template for event {$templateData['EVENT_NAME']}: {$et->LAST_ERROR}");
        }

        return ["Email template({$template['ID']}) for event {$template['EVENT_NAME']} updated"];
    }
636576
public function compile($templatePath, array $data, TemplateCompiler $compiler)
    {
        return $compiler->compile($this->file->get($templatePath), $data);
    }
799964
private function findConfig(array $config, $search) {
        $filteredConfig = [];
        $search = preg_quote($search);
        $search = str_replace('\*', '(.*)', $search);

        foreach ($config as $key => $value) {
            if (preg_match("#^$search#", $key) === 1) {
                $filteredConfig[$key] = $value;
            }
        }

        return $filteredConfig;
    }
221803
public function render($templateName = null, $data = [])
    {
        $this->setTemplate($templateName, $data);

        if (empty($this->_templateName)) {
            if (defined('FOCUS_DEBUG') && FOCUS_DEBUG) {
                $this->getLogger()->debug('template name is null');
            }

            throw new \RuntimeException('TEMPLATE_IS_NULL');
        }
        $buffer = $this->_parseTemplate($this->_templateName, $this->_data);
        if (!empty($this->_layout)) {
            if (defined('FOCUS_DEBUG') && FOCUS_DEBUG) {
                $this->getLogger()->debug('loading layout: '.$this->_layout);
            }

            $buffer = $this->_parseTemplate(
                $this->_layout,
                array_merge($this->_data, ['__body__' => $buffer])
            );
        }

        return $buffer;
    }
732036
public function apply(&$templateString) {

		$application	= Application::getInstance();
		$config			= $application->getConfig();

		$locale = $application->getCurrentLocale();

		// without locale replace placeholders with their identifier

		if(empty($locale)) {

			$templateString = preg_replace(
				array(
					'@\{![a-z0-9_]+\}@i',
					'@\{![a-z0-9_]+:(.*?)\}@i'
				),
				array(
					'',
					'$1'
				),
				$templateString
			);
			return;

		}

		$this->getPhrases($locale);

		$templateString = preg_replace_callback(
			'@\{!([a-z0-9_]+)(:(.*?))?\}@i',
			array($this, 'translatePhraseCallback'),
			$templateString
		);
	}
1205237
public function createSurveyFromTemplate($templateId, array $data = [])
	{
		return $this->sendRequest(
			$this->createRequest('POST', 'surveys', [], array_merge($data, [ 'from_template_id' => $templateId ]))
		);
	}
1035998
public function compile($template, $data)
    {
        foreach ($data as $key => $value) {
            $key = strtoupper($key);

            if(is_bool($value))
                $value = $value ? 'true' : 'false';

            $template = preg_replace("#\\$$key\\$#i", $value, $template);
        }

        return $template;
    }
160435
public function generateTemplate(&$templateHtml)
    {
        // Добавим путь к ресурсам для браузера
        $headHtml = "\n" . '<base href="' . url()->base() . '">';
        // Добавим отметку времени для JavaScript
        $headHtml .= "\n" . '<script type="text/javascript">var __SAMSONPHP_STARTED = new Date().getTime();</script>';

        // Добавим поддержку HTML для старых IE
        $headHtml .= "\n" . '<!--[if lt IE 9]>';
        $headHtml .= "\n" . '<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>';
        $headHtml .= "\n" . '<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>';
        $headHtml .= "\n" . '<![endif]-->';

        // Выполним вставку главного тега <base> от которого зависят все ссылки документа
        // также подставим МЕТА-теги для текущего модуля и сгенерированный минифицированный CSS
        $templateHtml = str_ireplace('<head>', '<head>' . $headHtml, $templateHtml);

        // Вставим указатель JavaScript ресурсы в конец HTML документа
        $templateHtml = str_ireplace('</html>', '</html>' . __SAMSON_COPYRIGHT, $templateHtml);

        return $templateHtml;
    }
1280854
public function render($templates, array $data = array())
    {
        $templates = (array) $templates;

        foreach ($templates as $template) {
            if (!is_readable($template) || !is_file($template)) {
                throw new \Shade\Exception('Template file "'.$template.'" does not exists');
            }
            $content = str_replace(array_keys($data), $data, file_get_contents($template));
            $data[$this->layoutContentPlaceholder] = $content;
        }

        return $content;
    }
559235
public function htmlTemplate($template, $data=[]) {
		$data['message'] = $this;
		$res = $this->buildTemplate($template, $data);
		return $this->html($res);
	}
137659
protected function parserSearchData($search)
    {
        $searchData = [];

        if (stripos($search, ':')) {
            $fields = explode(';', $search);

            foreach ($fields as $row) {
                try {
                    list($field, $value) = explode(':', $row);
                    $searchData[$field] = $value;
                } catch (\Exception $e) {
                    //Surround offset error
                }
            }
        }

        return $searchData;
    }
637928
public static function data($searchData, $cleanWord)
    {
        if( length($cleanWord) > length($searchData) )
        {
            throw new LogicException('[Cleaner::data()] -> 3.($cleanWord) parameter not be longer than 2.($searchData) parameter!');
        }

        if( ! is_array($searchData) )
        {
            $result = str_replace($cleanWord, '', $searchData);
        }
        else
        {
            if( ! is_array($cleanWord) )
            {
                $cleanWordArray[] = $cleanWord;
            }
            else
            {
                $cleanWordArray = $cleanWord;
            }

            $result = array_diff($searchData, $cleanWordArray);
        }

        return $result;
    }
1011983
private function compileTemplate($templatePath, $destinationPath, $data = null)
    {
        if ($data == null) {
            $data = $destinationPath;
            $destinationPath = null;
        }
        
        if (! isset($this->templates[$templatePath])) {
            $this->templates[$templatePath] = file_get_contents($templatePath);
        }
        
        $compiled = preg_replace_callback('/{{\s*([A-z0-9_-]+)\s*}}/', function ($matches) use ($data) {
            if (isset($data[$matches[1]])) {
                return $data[$matches[1]];
            }
            
            return $matches[0];
        }, $this->templates[$templatePath]);
        
        if ($destinationPath) {
            file_put_contents($destinationPath, $compiled);
        }
        
        return $compiled;
    }
1231421
public function readTemplate($templatePath)
    {
        if(!is_readable($templatePath)) {
            throw new Exception("No permissons to read template: ".$templatePath);
        }
        if($templateData = file_get_contents($templatePath)) {
            return $templateData;
        }
        else {
            throw new Exception("Can not read template: ".$templatePath);
        }
    }
1131757
protected function view(string $template, array $data = []) : string
    {
        if (!$this->mustacheInstance) {
            $viewsRoute = $this->config('paths.view');
            $options = ['extension' => '.hbs'];

            $this->mustacheInstance = new Mustache_Engine(array(
                'loader' => new Mustache_Loader_FilesystemLoader($viewsRoute, $options),
                'partials_loader' => new Mustache_Loader_FilesystemLoader($viewsRoute, $options),
                'charset' => 'UTF-8',
            ));
        }

        $tpl = $this->mustacheInstance->loadTemplate($template);
        $data = array_merge($this->getData(), $data);

        return $tpl->render($this->mapData($data));
    }
176836
protected function compile($template, $data)
    {
        foreach($data as $key => $value)
        {
            $template = preg_replace("/\\$$key\\$/i", $value, $template);
        }
        return $template;
    }
303983
private function validateArray($templateVersionData)
    {
        $isValid = true;
        $isValid = $isValid && is_array($templateVersionData);
        if ($isValid) {
            $keys = array_keys($templateVersionData);
            $isValid = $isValid &&
                in_array('id', $keys) &&
                in_array('template_id', $keys) &&
                in_array('active', $keys) &&
                in_array('name', $keys) &&
                in_array('updated_at', $keys);
        }

        if (!$isValid) {
            throw new \InvalidArgumentException('Template Version data must be an array and contain valid keys');
        }
    }