Создание анонса материала через модуль anonsCategory.
@param $event
@return bool|Feed|null
@throws \Exception
182584
protected function attachAnonsModule($event)
    {
        if (! $event->request->has('_jsvalidation') && ($event->request->has('anons_merge') || ! empty($event->request->get('anons_description')))) {
            if (! config('larrock.feed.anonsCategory')) {
                MessageLarrock::danger('larrock.feed.anonsCategory не задан. Анонс создан не будет');

                return true;
            }
            /** @var Feed $anons */
            $anons = LarrockFeed::getModel();
            $anons->title = $event->request->get('title');
            $anons->url = 'anons_'.$event->model->id.''.random_int(1, 9999);
            $anons->category = LarrockFeed::getConfig()->settings['anons_category'];
            $anons->user_id = \Auth::id();
            $anons->active = 1;
            $anons->position = LarrockFeed::getModel()->whereCategory(LarrockFeed::getConfig()->settings['anons_category'])->max('position') + 1;

            if ($event->request->has('anons_merge')) {
                $original = LarrockFeed::getModel()->whereId($event->request->get('id_connect'))->first();
                $anons->short = '<a href="'.$original->full_url.'">'.$event->request->get('title').'</a>';
            } else {
                $anons->short = $event->request->get('anons_description');
            }

            if ($anons->save()) {
                MessageLarrock::success('Анонс добавлен');

                return $anons;
            }
            MessageLarrock::danger('Анонс не добавлен');
        }

        return null;
    }
703850
protected function fireEvent($event, $data)
    {
        $fireableEvent = isset($this->fireEvents[$event]) ? $this->fireEvents[$event] : null;

        if (! is_null($fireableEvent)) {
            return $this->event->fire($fireableEvent, $data);
        }

        return null;
    }
1139123
public function triggerEvent($event)
	{
		if (!($event instanceof EventInterface))
		{
			if (isset($this->events[$event]))
			{
				$event = $this->events[$event];
			}

			else
			{
				$event = new Event($event);
			}
		}

		if (isset($this->listeners[$event->getName()]))
		{
			foreach ($this->listeners[$event->getName()] as $listener)
			{
				if ($event->isStopped())
				{
					return $event;
				}

				if ($listener instanceof Closure)
				{
					call_user_func($listener, $event);
				}

				else
				{
					call_user_func(array($listener, $event->getName()), $event);
				}
			}
		}

		return $event;
	}
217054
public function getListeners($event = null){
        if (!$event){
            return $this->listeners;
        }
        return isset($this->listeners[$event]) ? $this->listeners[$event] : null;
    }
1082221
protected function convertEvent($event)
    {
        if ($event instanceof OriginalCallbackEvent) {
            return new CallbackEvent($event);
        }

        if ($event instanceof OriginalEvent) {
            return new Event($event);
        }

        return $event;
    }
268391
public static function onPostLoad(Event $event)
    {
        $revision = $event->getTarget();
        $dispatcher = $event->getDispatcher();
        $application = $dispatcher->getApplication();

        if (null !== $application) {
            $em = $application->getEntityManager();
            $revision
                ->setEntityManager($em)
                ->setToken($application->getBBUserToken())
            ;

            if (null === $revision->getContent()) {
                $db = $em->getConnection();
                $stmt = $db->executeQuery(
                    'SELECT `content_uid`, `classname` FROM `revision` WHERE `uid` = ?',
                    [$revision->getUid()]
                );

                $items = $stmt->fetchAll();
                if ($items) {
                    foreach ($items as $item) {
                        $content = $em->find(Revision::getFullClassname($item['classname']), $item['content_uid']);
                        if ($content) {
                            $revision->setContent($content);
                        }
                    }
                }
            }
        }

        $revision->postLoad();
    }
254816
public function beforeDispatch(Event $event) {
		/** @var \Cake\Http\ServerRequest $request */
		$request = $event->data['request'];
		$ip = $request->clientIp();
		$Maintenance = new Maintenance();
		if (!$Maintenance->isMaintenanceMode($ip)) {
			return null;
		}

		$body = $this->_body();

		/** @var \Cake\Http\Response $response */
		$response = $event->data['response'];

		$response->header('Retry-After', HOUR);
		$response->statusCode(503);
		$response->body($body);
		$event->stopPropagation();

		return $response;
	}
1006508
public function getRepositoryForEvent($event)
    {
        $repository = null;

        if ($event instanceof DownVoteEvent) {
            $repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\UpDown\DownVote');
        }

        if ($event instanceof UpVoteEvent) {
            $repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\UpDown\UpVote');
        }

        if ($event instanceof LinkedInShareEvent) {
            $repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\LinkedIn\LinkedInShare');
        }

        if ($event instanceof FacebookLikeEvent) {
            $repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\Facebook\FacebookLike');
        }

        if ($event instanceof FacebookSendEvent) {
            $repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\Facebook\FacebookSend');
        }

        return $repository;
    }
1214871
public function onEvent(Event $event = null)
    {
        while (!empty($this->messages)) {
            $message = array_shift($this->messages);

            $this->handle($message, $this->dispatcher);
        }
    }
45742
public function deserialize(array $data, Event $event = null)
    {
        $this->sipe('title', 'setTitle', $data, $event);
        $this->sipe('color', 'setPriority', $data, $event);
        $this->sipe('allDay', 'setAllDay', $data, $event);
        $this->sipe('description', 'setDescription', $data, $event);
        $this->sipe('meta.task', 'setIsTask', $data, $event);
        $this->sipe('isTaskDone', 'setIsTaskDone', $data, $event);
        $this->sipe('isEditable', 'setIsEditable', $data, $event);

        if (isset($data['workspace'])) {
            $workspace = $this->_om->getObject($data['workspace'], Workspace::class);
            if ($workspace->getId()) {
                $event->setWorkspace($workspace);
            }
        }
        //owner set in crud create

        if (isset($data['start'])) {
            $event->setStart(DateNormalizer::denormalize($data['start']));
        }

        if (isset($data['end'])) {
            $event->setEnd(DateNormalizer::denormalize($data['end']));
        }

        return $event;
    }
24108
public function beforeRender(Event $event)
    {
        parent::beforeRender($event);

        $this->response->getStatusCode($this->httpStatusCode);

        if (200 != $this->httpStatusCode) {
            $this->responseStatus = $this->responseFormat['statusNokText'];
        }

        $response = [
            $this->responseFormat['statusKey'] => $this->responseStatus
        ];

        if (!empty($this->apiResponse)) {
            $response[$this->responseFormat['resultKey']] = $this->apiResponse;
        }

        $this->set('response', $response);
        $this->set('responseFormat', $this->responseFormat);

        return null;
    }
40574
public function unregister($event=null)
    {
        if(!empty($event) && $event != '*')
            $this->_handlers[$event] = array();
        else
            $this->_handlers = array();

        return $this;
    }
1140200
public function handleApiEvent($event)
    {
        $eventName = str_replace('.queued', null, $event->name);
        $ckey = 'event:' . $eventName;
        $records = Cache::remember($ckey, Config::get('df.default_cache_ttl'), function () use ($eventName) {
            return ServiceEventMap::whereEvent($eventName)->get()->all();
        });
        if (empty($records)) {
            // Look for wildcard events by service (example: user.*)
            $serviceName = substr($eventName, 0, strpos($eventName, '.'));
            $wildcardEvent = $serviceName . '.*';
            $ckey = 'event:' . $wildcardEvent;
            $records = Cache::remember($ckey, Config::get('df.default_cache_ttl'), function () use ($wildcardEvent) {
                return ServiceEventMap::whereEvent($wildcardEvent)->get()->all();
            });
        }

        /** @var BaseModel $record */
        foreach ($records as $record) {
            Log::debug('Service event handled: ' . $eventName);
            /** @var BaseRestService $service */
            $service = \ServiceManager::getServiceById($record->service_id);
            Event::fire(new ServiceAssignedEvent($service, $event, $record->toArray()));
        }
    }
182658
public function resolve($event)
    {
        if ($event instanceof UserEvent) {
            return $this->getEventDetailsArray($event->getUser()->getUsername());
        }

        return null;
    }
154732
public function clearListeners($event = null)
	{
		if ($event)
		{
			$event = $this->resolveEventName($event);

			if (isset($this->listeners[$event]))
			{
				unset($this->listeners[$event]);
			}
		}
		else
		{
			$this->listeners = array();
		}

		return $this;
	}
1329317
public function setTaskAsNotDone(Event $event)
    {
        $this->checkPermission($event);
        if (!$event->isTaskDone()) {
            throw new \Exception('This task is already mark as not done.');
        }

        $event->setIsTaskDone(false);
        $om = $this->getDoctrine()->getManager();
        $om->flush();

        return new Response();
    }
905392
public function trigger($event = null)
    {
        //argument 1 must be string
        Argument::i()->test(1, 'string', 'null');

        if (is_null($event)) {
            $trace = debug_backtrace();
            $event = $trace[1]['function'];
            if (isset($trace[1]['class']) && trim($trace[1]['class'])) {
                $event = str_replace('\\', '-', $trace[1]['class']).'-'.$event;
            }
        }

        //get the arguments
        $args = func_get_args();
        //shift out the event
        array_shift($args);

        //for each observer
        foreach ($this->observers as $observer) {
            //if this is the same event, call the method, if the method returns false
            if ($event == $observer[0] && call_user_func_array($observer[2], $args) === false) {
                //break out of the loop
                break;
            }
        }

        return $this;
    }