Получает почтовый шаблон по фильтру или типу почтового события
@param $eventName
@return mixed
482211
public function getEventMessage($eventName) {
        $filter = is_array($eventName) ? $eventName : array(
            'EVENT_NAME' => $eventName,
        );

        $by = 'id';
        $order = 'asc';

        $item = \CEventMessage::GetList($by, $order, $filter)->Fetch();
        return $this->prepareEventMessage($item);
    }
376516
public function addDefaultByEvent($eventName) {
        $added = 0;
        $limit = 3;
        foreach ($this->getDefinitionsBlockGrid() as $grid) {
            if(!in_array($eventName, $grid->getParseEvents())){
                continue;
            }
            foreach ($grid->getDefaults() as $name) {
                $i = $this->addAll($grid->getType(),$name);
                $added += $i;
                if($added >= $limit){
                    break;
                }
            }
            if($added >= $limit){
                break;
            }
        }
        return $added;
    }
137860
public function exportEventTypes($eventName) {
        $exports = array();
        $items = $this->getEventTypes($eventName);
        foreach ($items as $item) {
            $exports[] = $this->prepareExportEventType($item);
        }
        return $exports;
    }
153927
public function getListeners($eventName = null)
    {

        if (empty($eventName)) return $this->listeners;
        if (!empty($eventName) && !isset($this->listeners[$eventName])) return [];

        return $this->listeners[$eventName];
    }
637861
public function getEventActions($eventName)
    {
        $events = isset($this->events[$eventName]) ? $this->events[$eventName] : [];

        return is_array($events) ? $events : [$events];
    }
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;
    }
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];

	}
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;
    }
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;
    }
1222569
public function addEventMessageIfNotExists($eventName, $fields) {
        $this->checkRequiredKeys(__METHOD__, $fields, array('SUBJECT', 'LID'));

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

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

        return $this->addEventMessage($eventName, $fields);
    }
1136302
public function getListeners( $eventName = NULL )
    {
        if ( NULL !== $eventName )
        {
            if ( !isset( $this->_sorted[ $eventName ] ) )
            {
                $this->sortListeners( $eventName );
            }

            return $this->_sorted[ $eventName ];
        }

        foreach ( array_keys( $this->listeners ) as $eventName )
        {
            if ( !isset( $this->_sorted[ $eventName ] ) )
            {
                $this->sortListeners( $eventName );
            }
        }

        return array_filter( $this->_sorted );
    }
1017533
private function sortListeners(string $eventName = ''): MediatorInterface
    {
        if (0 === \count($this->listeners)) {
            return $this;
        }
        if ('' !== $eventName) {
            if (!\array_key_exists($eventName, $this->listeners)) {
                return $this;
            }
            $eventNames = [$eventName];
        } else {
            \ksort($this->listeners);
            $eventNames = \array_keys($this->listeners);
        }
        foreach ($eventNames as $anEvent) {
            \krsort($this->listeners[$anEvent], \SORT_NUMERIC);
        }
        return $this;
    }
125224
public function getList($eventName)
    {
        $eventName = $this->cleanEventName($eventName);

        if ($eventName === '*') {
            throw new Exception('* is unsafe event name!');
        }

        $result = array();
        $ePaths = explode('.', $eventName);

        foreach ($this->_list as $eName => $eData) {

            if ($eName === $eventName) {
                $result = array_merge($result, $eData);

            } elseif (strpos($eName, '*') !== false) {
                $eNameParts = explode('.', $eName);

                if ($this->_isContainPart($eNameParts, $ePaths)) {
                    $result = array_merge($result, $eData);
                }
            }
        }

        if (count($result) > 0) {
            // Sorting
            usort($result, function ($item1, $item2) {
                return $item2[0] - $item1[0];
            });

            return array_map(function ($item) {
                return $item[1];
            }, $result);
        }

        return array();
    }
204187
public function getAccessLevelsForEvent($eventName)
    {
        if (!isset($this->items[$eventName])) {
            return false;
        }
        
        return $this->items[$eventName];
    }
1105620
private function dispatchEvent($eventName, MessageEvent $event)
    {
        if ($this->eventDispatcher) {
            return $this->eventDispatcher->dispatch($eventName, $event);
        }

        return $event;
    }
27730
public function hasListeners($eventName = null)
    {
        return ($this->symfonyDispatcher->hasListeners($eventName) ||
            $this->laravelDispatcher->hasListeners($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;
    }