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

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

        if ($item) {
            return $item['ID'];
        }

        return $this->addEventType($eventName, $fields);
    }
891507
public function cleanEventName($eventName)
    {
        $eventName = strtolower($eventName);
        $eventName = str_replace('..', '.', $eventName);
        $eventName = trim($eventName, '.');
        $eventName = trim($eventName);

        if (!$eventName) {
            throw new Exception('Event name is empty!');
        }

        return $eventName;
    }
232644
public function dispatchUntil($eventName, Event $event)
    {
        // skip dispatching because event is already dispatched
        if ($event->isProcessed()) {
            return $event;
        }

        // skip dispatching because event hasn't listeners
        if (!$this->hasListeners($eventName)) {
            return $event;
        }

        $event->setName($eventName);

        foreach ($this->getListeners($event->getName()) as $listener) {
            if (call_user_func($listener, $event)) {
                $event->setProcessed(true);
                break;
            }
        }

        return $event;
    }
712069
private function getSortedRegistry($eventName) {
		
		if(!isset($this->sortedRegistry[$eventName])) {
			
			$this->sortedRegistry[$eventName] = [];
			
			if (isset($this->registry[$eventName])) {
				
				// sort reverse by priority key

				krsort($this->registry[$eventName]);
				
				// merge the sorted arrays into one

				$this->sortedRegistry[$eventName] = call_user_func_array('array_merge', $this->registry[$eventName]);
			}
		}

		return $this->sortedRegistry[$eventName];

	}
949591
public function add($eventName, $eventHandler, $key = null) {
        if (!is_callable($eventHandler)) {
            throw new \Exception('Function is expected.');
        }

        if ($key !== null) {
            $this->{$eventName}[$key] = $eventHandler;
        }
        else {
            $this->{$eventName}[] = $eventHandler;
        }
    }
1326370
public function getFieldNum($fieldName)
    {
        foreach( $this->_fields as $field ) {
            if( $field->name == $fieldName ) {
                return $field->number;
            }
        }

        return -1;
    }
1177643
public static function run(String $eventName, Array $parameters = []) : Bool
    {
        return Run::event($eventName, $parameters);
    }
1224592
public static function getFieldKey($fieldName, $fieldId)
    {
        if (isset(get_field_objects($fieldId)[$fieldName]['key'])) {
            return get_field_objects($fieldId)[$fieldName]['key'];
        }

        return false;
    }
682314
public function subscribeEvent($eventName)
    {
        if (!isset($this->subscribedEvents[$eventName])) {
            throw new InvalidArgumentException("Event $eventName doesn't exists in client context");
        }

        $this->subscribedEvents[$eventName] = true;
    }
397885
protected function getEventLogInfo(Event $event, $eventName)
    {
        if ($event instanceof EmbeddedEventResolverInterface) {
            return $event->getEventLogInfo($eventName);
        }

        if (null === $eventResolver = $this->getResolver($eventName)) {
            return null;
        }

        return $eventResolver->getEventLogInfo($event, $eventName);
    }
480980
public function addField($fieldName, Field $field)
    {
        $this->fieldNames[ $fieldName ] = $fieldName;
        $this->fields[ $fieldName ]     = $field;

        return $fieldName;
    }
137860
public function exportEventTypes($eventName) {
        $exports = array();
        $items = $this->getEventTypes($eventName);
        foreach ($items as $item) {
            $exports[] = $this->prepareExportEventType($item);
        }
        return $exports;
    }
419570
protected function dispatchEvent($eventName, \Symfony\Component\EventDispatcher\Event $event)
    {
        if (!$event->isPropagationStopped()) {
            $dispatcher = $this->getEventDispatcher();
            $dispatcher->dispatch($eventName, $event);
        }
        return !$event->isPropagationStopped();
    }
1186894
public function sortSubscribers($eventName)
    {
        $this->sorted[$eventName] = array();
        if (isset($this->eventList[$eventName])) {
            krsort($this->eventList[$eventName]);
            $this->sorted[$eventName] = call_user_func_array('array_merge', $this->eventList[$eventName]);
        }

        return $this->sorted[$eventName];
    }
566717
protected function getActualPriority(string $eventName, $priority): int
    {
        if (\is_int($priority)) {
            return $priority;
        }
        if (!\in_array($priority, ['first', 'last'], \true)) {
            $mess = 'Unknown priority was given only "first", "last", or integer may be used';
            throw new \InvalidArgumentException($mess);
        }
        $listenerM = parent::getActualPriority($eventName, $priority);
        if ($priority === 'first') {
            $serviceM = \array_key_exists($eventName, $this->serviceListeners)
                ? \max(\array_keys($this->serviceListeners[$eventName])) + 1 : 1;
            return ($listenerM > $serviceM) ? $listenerM : $serviceM;
        }
        $serviceM = \array_key_exists($eventName, $this->serviceListeners)
            ? \min(\array_keys($this->serviceListeners[$eventName])) - 1 : -1;
        return ($listenerM < $serviceM) ? $listenerM : $serviceM;
    }
739502
public function dispatch($eventName = null)
    {
        // Tries to fetch the event by the given eventname
        $event = null;
        if (null !== $eventName) {
            $event = $this->fetchEvent($eventName);
        }

        // Fetches the last saved event
        if (null === $event && !empty($this->events)) {
            $eventNames = array_keys($this->events);
            $events = array_values($this->events);
            $elemens = count($events) - 1;
            $event = $events[$elemens];
            $eventName = $eventNames[$elemens];
        }

        if (null === $event) {
            throw new RuntimeException('exception_no_events');
        }

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

        return $this;
    }
544095
public function dispatch($eventName, sfEvent $event = null)
    {
        if (null !== $this->application) {
            $this->application->debug(sprintf('Dispatching `%s` event.', $eventName));
        }

        return parent::dispatch($eventName, $event);
    }