Добавляет почтовый шаблон
@param $eventName
@param $fields , обязательные параметры - id сайта, тема сообщения
@return bool|int
@throws \Sprint\Migration\Exceptions\HelperException
492245
public function addEventMessage($eventName, $fields) {
        $this->checkRequiredKeys(__METHOD__, $fields, array('LID', 'SUBJECT'));

        $default = array(
            'ACTIVE' => 'Y',
            'EMAIL_FROM' => '#DEFAULT_EMAIL_FROM#',
            'EMAIL_TO' => '#EMAIL_TO#',
            'BCC' => '',
            'BODY_TYPE' => 'text',
            'MESSAGE' => '',
        );

        $fields = array_merge($default, $fields);
        $fields['EVENT_NAME'] = $eventName;

        $event = new \CEventMessage;
        $id = $event->Add($fields);

        if ($id) {
            return $id;
        }

        $this->throwException(__METHOD__, 'Event message %s not added, error: %s', $eventName, $event->LAST_ERROR);
    }
536939
protected function passes($fieldname = null) {
		
		$helper = new StringToArray();
		return true === Request :: isPost() && null === $helper -> execute($fieldname, null, Message :: getErrors(true));
	}
1247264
public function addEventListener($eventName, array $listeners)
    {
        if (!array_key_exists($eventName, $this->options['events'])) {
            $this->options['events'][$eventName] = [
                'object' =>BaseEvent::class,
                'listeners' => $listeners,
            ];
        }

        $this->options['events'][$eventName]['listeners'] = array_merge(
            $this->options['events'][$eventName]['listeners'],
            $listeners
        );

        return $this;
    }
1177643
public static function run(String $eventName, Array $parameters = []) : Bool
    {
        return Run::event($eventName, $parameters);
    }
1320005
public function saveEventType($eventName, $fields) {
        $this->checkRequiredKeys(__METHOD__, $fields, array('LID'));

        $exists = $this->getEventType(array(
            'EVENT_NAME' => $eventName,
            'LID' => $fields['LID']
        ));

        $exportExists = $this->prepareExportEventType($exists);
        $fields = $this->prepareExportEventType($fields);

        if (empty($exists)) {
            $ok = $this->getMode('test') ? true : $this->addEventType($eventName, $fields);
            $this->outNoticeIf($ok, 'Тип почтового события %s:%s: добавлен', $eventName, $fields['LID']);
            return $ok;
        }

        if ($this->hasDiff($exportExists, $fields)) {
            $ok = $this->getMode('test') ? true : $this->updateEventTypeById($exists['ID'], $fields);
            $this->outNoticeIf($ok, 'Тип почтового события %s:%s: обновлен', $eventName, $fields['LID']);
            $this->outDiffIf($ok, $exportExists, $fields);
            return $ok;
        }

        $ok = $this->getMode('test') ? true : $eventName;
        if ($this->getMode('out_equal')) {
            $this->outIf($ok, 'Тип почтового события %s:%s: совпадает', $eventName, $fields['LID']);
        }
        return $ok;
    }
688843
protected function wildcardContainsEvent($wildcard, $eventName)
    {
        $patterns = Arr::wrap($wildcard);

        if (empty($patterns)) {
            return false;
        }

        foreach ($patterns as $pattern) {
            // If the given event is an exact match we can of course return true right
            // from the beginning. Otherwise, we will translate asterisks and do an
            // actual pattern match against the two strings to see if they match.
            if ($pattern == $eventName) {
                return true;
            }

            $pattern = preg_quote($pattern, '#');

            // Asterisks are translated into zero-or-more regular expression wildcards
            // to make it convenient to check if the strings starts with the given
            // pattern such as "library/*", making any string check convenient.
            $pattern = str_replace('\*', '.*', $pattern);

            if (preg_match('#^'.$pattern.'\z#u', $eventName) === 1) {
                return true;
            }
        }

        return false;
    }
850518
protected function _log($eventName)
    {
        if (isset($this->_log[$eventName])) {
            $this->_log[$eventName]++;
        } else {
            $this->_log[$eventName] = 1;
        }
    }
897940
protected function triggerMethod($eventName, Event $event)
    {
        $method = sprintf('on%s', Container::camelize(str_replace('.', '_', $eventName)));

        if(is_callable([$this, $method])) {
            call_user_func_array([$this, $method], [$event]);
        }

        if($event->isPropagationStopped()){
            return $event;
        }

        $this->getDispatcher()->dispatch($eventName, $event);

        return $event;
    }
1302231
public function triggerEvent($eventName, Event $event = null)
    {
        if (!$event) {
            $event = new Event;
        }

        $event->setTarget($this);

        return $this->eventDispatcher->dispatch($eventName, $event);
    }
603634
public function removeListener($eventName, $listener = null)
    {
        $eventName = $this->cleanEventName($eventName);

        if (!array_key_exists($eventName, $this->_list)) {
            return false;
        }

        foreach ($this->_list[$eventName] as $index => $eventData) {

            if ($eventData[1] === $listener) {
                unset($this->_list[$eventName][$index]);
                return true;
            }
        }

        return false;
    }
1126005
protected function assertHasStepForEvent($eventName)
    {
        if (!isset($this->eventBindings[$eventName])) {
            throw new NoStepForEventFoundException(
                sprintf('No step handling event %s in scenario %s.', $eventName, get_class($this->scenario))
            );
        }
    }
168089
public function contains($eventName)
    {
        foreach ($this->events as $event) {
            if ((string) new EventName($event) === $eventName) {
                return true;
            }
        }

        return false;
    }
204187
public function getAccessLevelsForEvent($eventName)
    {
        if (!isset($this->items[$eventName])) {
            return false;
        }
        
        return $this->items[$eventName];
    }
443286
public function saveEventMessage($eventName, $fields) {
        $this->checkRequiredKeys(__METHOD__, $fields, array('SUBJECT', 'LID'));

        $exists = $this->getEventMessage(array(
            'EVENT_NAME' => $eventName,
            'SUBJECT' => $fields['SUBJECT'],
        ));

        $exportExists = $this->prepareExportEventMessage($exists);
        $fields = $this->prepareExportEventMessage($fields);

        if (empty($exists)) {
            $ok = $this->getMode('test') ? true : $this->addEventMessage($eventName, $fields);
            $this->outNoticeIf($ok, 'Почтовый шаблон %s:%s: добавлен', $eventName, $fields['SUBJECT']);
            return $ok;
        }

        if ($this->hasDiff($exportExists, $fields)) {
            $ok = $this->getMode('test') ? true : $this->updateEventMessageById($exists['ID'], $fields);
            $this->outNoticeIf($ok, 'Почтовый шаблон %s:%s: обновлен', $eventName, $fields['SUBJECT']);
            $this->outDiffIf($ok, $exportExists, $fields);
            return $ok;
        }

        $ok = $this->getMode('test') ? true : $eventName;
        if ($this->getMode('out_equal')) {
            $this->outIf($ok, 'Почтовый шаблон %s:%s: совпадает', $eventName, $fields['SUBJECT']);
        }
        return $ok;
    }
1014453
public function findByField($fieldName, $value) {
    $dataConnection = $this->app->getDataConnection($this->connection);
    if ($fieldName == $this->idColumn) {
      $value = $dataConnection->convertToNativeId($value);
    }
    $result = $dataConnection->findOneByField($fieldName, $value, $this->table, $this->readFields);
    if ($result == NULL) {
      return FALSE;
    }
    $this->load($result);
    return TRUE;
  }
165863
public function execute($eventName, $object)
    {
        if (isset($this->events[$eventName]) && is_array(($this->events[$eventName]))) {
            foreach ($this->events[$eventName] as $method) {
                call_user_func([$object, $method]);
            }
        }
    }
480980
public function addField($fieldName, Field $field)
    {
        $this->fieldNames[ $fieldName ] = $fieldName;
        $this->fields[ $fieldName ]     = $field;

        return $fieldName;
    }