Ищет шаблон почтового сообщения по массиву параметров.

@param array $templateData

@return array|null

@throws \marvin255\bxmigrate\migrate\Exception
421436
public function findEmailTemplate(array $templateData)
    {
        if (empty($templateData['EVENT_NAME'])) {
            throw new Exception('Empty email event type name');
        }

        $filter = ['TYPE_ID' => $templateData['EVENT_NAME']];
        if (!empty($templateData['LID'])) {
            $filter['SITE_ID'] = $templateData['LID'];
        }
        if (!empty($templateData['SUBJECT'])) {
            $filter['SUBJECT'] = $templateData['SUBJECT'];
        }

        $return = null;
        $rsMess = CEventMessage::GetList(
            ($by = 'site_id'),
            ($order = 'desc'),
            $filter
        );
        while ($template = $rsMess->fetch()) {
            if ($return) {
                throw new Exception("More than one template are found: {$templateData['EVENT_NAME']}");
            }
            $return = $template;
        }

        return $return;
    }
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');
        }
    }
1245594
protected function getPreview($templateArray)
    {
        $multi = false;
        if (count($templateArray) > 1) {
            $multi = true;
            $allLanguages = $this->util->getLocalized()->getLanguages();
        }

        $htmlView = \MUtil_Html::create()->div();
        $textView = \MUtil_Html::create()->div();

        foreach($templateArray as $template) {
            $content = '';
            if ($template['gctt_subject'] || $template['gctt_body']) {
                if ($multi) {
                    $htmlView->h3()->append($allLanguages[$template['gctt_lang']]);
                    $textView->h3()->append($allLanguages[$template['gctt_lang']]);
                }

                $content .= '[b]';
                $content .= $this->_('Subject:');
                $content .= '[/b] [i]';
                $content .= $this->mailer->applyFields($template['gctt_subject']);
                $content .= "[/i]\n\n";
                $content .= $this->mailer->applyFields($template['gctt_body']);

                $htmlView->div(array('class' => 'mailpreview'))
                        ->raw(\MUtil_Markup::render($content, 'Bbcode', 'Html'));
                $textView->pre(array('class' => 'mailpreview'))
                        ->raw(wordwrap(\MUtil_Markup::render($content, 'Bbcode', 'Text'), 80));
            }

        }

        return array('html' => $htmlView, 'text' => $textView);
    }
6723
public function requestToken(array $userData) {
        if (empty($userData['email'])) {
            $this->_addError(
                sprintf(
                    __('%s is a required field'),
                    __('Email')
                )
            );
            return false;
        }

        $validator = new Zend_Validate_EmailAddress();
        if (!$validator->isValid($userData['email'])) {
            $this->_addError(
                sprintf(
                    __('%s is not a valid email address'),
                    __('Email')
                )
            );
            return false;
        }

        $userId = $this->_createOrFetchUserRecord($userData);
        $token  = $this->createOrUpdateAuthRecord($userId);

        $this->_sendTokenEmail($userData['email'], $userId, $token);
        $this->setRedirect($this->_getRedirectUrl());
    }
1080587
public static function template_has_related_data($templateid) {
        $params = self::validate_parameters(self::template_has_related_data_parameters(), array(
            'id' => $templateid,
        ));

        $template = api::read_template($params['id']);
        self::validate_context($template->get_context());

        return api::template_has_related_data($params['id']);
    }
269719
public static function FromArray( array $objectData )
   {

      $objectData = \array_change_key_case( $objectData );

      if ( isset( $objectData[ 'x' ] )
        && isset( $objectData[ 'y' ] )
        && isset( $objectData[ 'width' ] )
        && isset( $objectData[ 'height' ] ) )
      {
         return self::Init(
            \intval( $objectData['x'] ),
            \intval( $objectData['y'] ),
            \intval( $objectData['width'] ),
            \intval( $objectData['height'] )
         );
      }

      return false;

   }
837253
protected function responseTemplate($template, $data = array()){
        
        if(!isset(hubert()->template)){
            throw new \Exception("no template engine installed");
        }
        $html = hubert()->template->render($template, $data);
        $this->_response->getBody()->write($html);
        
        return $this->_response;
        
    }
890006
static function fetchTemplatePiece( $placementData )
    {
        if ( !isset( $placementData[0] ) or
             !isset( $placementData[1] ) or
             !isset( $placementData[2] ) )
            return null;
        $file = $placementData[2];
        $startPosition = $placementData[0][2];
        $endPosition = $placementData[1][2];
        $length = $endPosition - $startPosition;
        if ( file_exists( $file ) )
        {
            if ( $length > 0 )
            {
                $fd = fopen( $file, 'rb' );
                fseek( $fd, $startPosition );
                $text = fread( $fd, $length );
                fclose( $fd );
                return $text;
            }
            else
            {
                return '';
            }
        }
        return null;
    }
540188
public function template($template, $data = [])
    {
        $templatePath = self::$instance->app->findTemplate($template);
        echo self::$instance->renderTemplate($templatePath, $data);
    }
717947
public void setTemplatesMetadata(java.util.Collection<TemplateMetadata> templatesMetadata) {
        if (templatesMetadata == null) {
            this.templatesMetadata = null;
            return;
        }

        this.templatesMetadata = new com.amazonaws.internal.SdkInternalList<TemplateMetadata>(templatesMetadata);
    }
1342402
public function mapToObject(array $objectData)
    {
        if ($objectData === []) {
            throw new Exception\InvalidObjectDataException('The array with object data was empty, probably object not found or access denied.', 1277974338);
        }

        if ($this->persistenceSession->hasIdentifier($objectData['identifier'])) {
            return $this->persistenceSession->getObjectByIdentifier($objectData['identifier']);
        } else {
            $className = $objectData['classname'];
            $classSchema = $this->reflectionService->getClassSchema($className);

            $object = unserialize('O:' . strlen($className) . ':"' . $className . '":0:{};');
            $this->persistenceSession->registerObject($object, $objectData['identifier']);
            if ($classSchema->getModelType() === ClassSchema::MODELTYPE_ENTITY) {
                $this->persistenceSession->registerReconstitutedEntity($object, $objectData);
            }
            if ($objectData['properties'] === []) {
                if (!$classSchema->isLazyLoadableObject()) {
                    throw new PersistenceException('The object of type "' . $className . '" is not marked as lazy loadable.', 1268309017);
                }
                $persistenceManager = $this->persistenceManager;
                $persistenceSession = $this->persistenceSession;
                $dataMapper = $this;
                $identifier = $objectData['identifier'];
                $modelType = $classSchema->getModelType();
                $object->Flow_Persistence_LazyLoadingObject_thawProperties = function ($object) use ($persistenceManager, $persistenceSession, $dataMapper, $identifier, $modelType) {
                    $objectData = $persistenceManager->getObjectDataByIdentifier($identifier);
                    $dataMapper->thawProperties($object, $identifier, $objectData);
                    if ($modelType === ClassSchema::MODELTYPE_ENTITY) {
                        $persistenceSession->registerReconstitutedEntity($object, $objectData);
                    }
                };
            } else {
                $this->thawProperties($object, $objectData['identifier'], $objectData);
            }

            return $object;
        }
    }
513366
public function addData(array $data, $templates = null): self
    {
        if (null === $templates) {
            $this->sharedVariables = \array_merge($this->sharedVariables, $data);

            return $this;
        }

        if (\is_string($templates)) {
            $templates = [$templates];
        }

        if (\is_array($templates)) {
            foreach ($templates as $template) {
                if (isset($this->templateVariables[$template])) {
                    $this->templateVariables[$template] = \array_merge($this->templateVariables[$template], $data);
                } else {
                    $this->templateVariables[$template] = $data;
                }
            }

            return $this;
        }

        throw new \InvalidArgumentException(
            'The templates variable must be null, an array or a string, ' . \gettype($templates) . ' given.'
        );
    }
971766
public function listTemplates( $templateType = null ){
        $queryParams = is_null( $templateType ) ? [] : [ 'type' => $templateType ];
        return $this->httpGet( self::PATH_TEMPLATE_LIST, $queryParams );
    }
619551
public function find(string $templatePath)
    {
        foreach ($this->paths as $path) {
            $filePath = sprintf(
                '%s/%s',
                rtrim($path, '/'),
                ltrim($templatePath, '/')
            );

            if (is_file($filePath)) {
                return $filePath;
            }
        }

        return null;
    }
1333398
public function deleteEmailTemplate(array $templateData)
    {
        if (!($template = $this->findEmailTemplate($templateData))) {
            throw new Exception("Email template for event {$templateData['EVENT_NAME']} not found");
        }

        $et = new CEventMessage;
        $res = $et->delete($template['ID']);

        if (!$res) {
            throw new Exception("Can't delete template({$template['ID']}) for type {$templateData['EVENT_NAME']}");
        }

        return ["Email template({$template['ID']}) for type {$templateData['EVENT_NAME']} deleted"];
    }
465320
private function fillTemplate($templateData)
    {
        $apiVersion = config('webcore.laravel_generator.api_version', 'v1');
        $apiPrefix = config('webcore.laravel_generator.api_prefix', 'api');

        $templateData = str_replace('$API_VERSION$', $apiVersion, $templateData);
        $templateData = str_replace('$API_PREFIX$', $apiPrefix, $templateData);
        $appNamespace = $this->getLaravel()->getNamespace();
        $appNamespace = substr($appNamespace, 0, strlen($appNamespace) - 1);
        $templateData = str_replace('$NAMESPACE_APP$', $appNamespace, $templateData);

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

        return json_encode($this->_data);
    }