Pull the triggers.

@param EventInterface $event The event

@return EventInterface
338614
protected function pullTriggers(EventInterface $event)
    {
        $event->stopPropagation(false);

        foreach ($this->getTriggers($event) as $trigger) {
            $trigger($event);

            if ($event->propagationIsStopped()) {
                break;
            }
        }

        return $event;
    }
1258445
public function process(EventInterface $event)
    {
        $mapper = $this->getMapper();
        $optionsProvider = $this->getOptionsProvider();
        $translator = $this->getTranslator();
        $pane = $event->getParam('pane');
        if (! $optionsProvider->hasIdentifier($pane)) {
            return;
        }

        $options = $optionsProvider->getOptions($pane);
        if ($options->getType() == 'search') {
            $this->error(self::ReorderSearch);
            return $this->redirect($event);
        }
        if ($options->getRoot() == 'trash') {
            $this->error(self::ReorderTrash);
            return $this->redirect($event);
        }
        if ($options->getOrderBy() != 'natural') {
            $this->error(self::UnmanagedOrder);
            return $this->redirect($event);
        }

        $posNew = $event->getParam('position');
        $posOld = $event->getParam('old_position');
        if (empty($posNew) || empty($posOld)) {
            return;
        }
        $positions = array_diff_assoc($posNew, $posOld);
            foreach ($positions as $id => $position) {
                try {
                    $mapper->beginTransaction();
                    $tid = $mapper->getTransactionIdentifier();
                    $this->mapper->reorder($id, $position, $tid);
                    $mapper->commit();
                } catch (UnavailableSourceException $e) {
                    $mapper->rollBack();
                    $this->setValue($id)->error(self::SourceNotFound);
                } catch (UnavailableDestinationException $e) {
                    $mapper->rollBack();
                    $this->error(self::DestinationNotFound);

                    // the destination is not available for all elements
                    break;
                } catch (Exception $e) {
                    $mapper->rollBack();
                    if (DEBUG_MODE) {
                        throw new DebugException(
                            $translator->translate('Error: ') . $e->getMessage(),
                            $e->getCode(),
                            $e
                        );
                    }
                    $meta = $mapper->findMetaById($id);
                    $name = isset($meta['title']) ? $meta['title'] : $id;
                    $this->setValue($name)->error(self::UnexpectedError);
                    break;
                }
            }

        return $this->redirect($event);
    }
570296
public function handle(EventInterface $event)
    {

        try {
            // load the application server instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();

            // unbind the loggers from the naming directory
            foreach (array_keys($applicationServer->getLoggers()) as $name) {
                $applicationServer->getNamingDirectory()->unbind(sprintf('php:global/log/%s', $name));
            }

            // set the initialized loggers finally
            $applicationServer->setLoggers(array());

        } catch (\Exception $e) {
            error_log($e->__toString());
        }
    }
1198680
public function captureStart(EventInterface $event)
    {
        ++$this->index;

        $time = microtime(true);

        $eventName = $event->getName();
        if ($eventName) {
            $this->timers[$eventName] = ['start' => $time, 'stop' => $time];

            return;
        }
        $this->timers[$this->index] = ['start' => $time, 'stop' => $time];
    }
1106622
public function get(EventInterface $event) {
        $request = $event->getRequest();
        $response = $event->getResponse();

        $redirectUrl = $event->getConfig()['indexRedirect'];

        if ($redirectUrl) {
            $response->setStatusCode(307);
            $response->headers->set('Location', $redirectUrl);
            return;
        }

        $response->setStatusCode(200, 'Hell Yeah');

        $baseUrl = $request->getSchemeAndHttpHost() . $request->getBaseUrl();

        $model = new Model\ArrayModel();
        $model->setData([
            'site' => 'http://imbo.io',
            'source' => 'https://github.com/imbo/imbo',
            'issues' => 'https://github.com/imbo/imbo/issues',
            'docs' => 'http://docs.imbo.io',
        ]);

        $response->setModel($model);

        // Prevent caching
        $response->setMaxAge(0)
                 ->setPrivate();
        $response->headers->addCacheControlDirective('no-store');
    }
665686
public function loadImage(EventInterface $event) {
        $request = $event->getRequest();
        $response = $event->getResponse();

        $event->getDatabase()->load(
            $request->getUser(),
            $request->getImageIdentifier(),
            $response->getModel()
        );
    }
1008384
private function handleListenersForEvent(EventInterface $event, $listeners)
    {
        $return = array();

        foreach ($listeners as $listener) {
            $return[] = $listener->handle($event);
        }

        return $return;
    }
202975
public function onUpdate(EventInterface $event)
    {
        $values = $event->getParam('values');

        $now = new DateTime();
        $values['last_updated_at'] = $now->format('Y-m-d h:i:s');

        $event->setParam('values', $values);
    }
362284
public function getTriggerByEvent($event) {
        $data = [ ];
        $data['event'] = $event;

        $result = $this->apiGet('trigger', $data);
        return $result;
    }
687354
public function handle(EventInterface $event)
    {

        try {
            // load the application server and system configuration instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();
            /** @var \AppserverIo\Psr\ApplicationServer\Configuration\SystemConfigurationInterface $systemConfiguration */
            $systemConfiguration = $applicationServer->getSystemConfiguration();

            // load the initial context configuration
            /** @var \AppserverIo\Psr\ApplicationServer\Configuration\InitialContextConfigurationInterface $initialContextNode */
            $initialContextNode = $systemConfiguration->getInitialContext();
            $reflectionClass = new \ReflectionClass($initialContextNode->getType());
            /** @var \AppserverIo\Psr\ApplicationServer\ContextInterface $initialContext */
            $initialContext = $reflectionClass->newInstanceArgs(array($systemConfiguration));

            // attach the registered loggers to the initial context
            $initialContext->setLoggers($applicationServer->getLoggers());
            $initialContext->setSystemLogger($applicationServer->getSystemLogger());

            // set the initial context and flush it initially
            $applicationServer->setInitialContext($initialContext);

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
427747
public function publish(EventInterface $event)
    {
        $commandsToDispatch = $this->eventBus->publish($event);

        $commands = $this->extractCommands($commandsToDispatch);
        foreach ($commands as $command) {
            $this->dispatch($command);
        }
    }
952273
public function subscribe(EventInterface $event) {
        $events = [];

        // Enable the event listener only for resources and methods specified
        foreach ($this->params['allowedMethods'] as $resource => $methods) {
            foreach ($methods as $method) {
                $eventName = $resource . '.' . strtolower($method);
                $events[$eventName] = ['invoke' => 1000];
            }

            // Always enable the listener for the OPTIONS method
            $eventName = $resource . '.options';
            $events[$eventName] = ['options' => 20];
        }

        $manager = $event->getManager();
        $manager->addCallbacks($event->getHandler(), $events);

        // Add OPTIONS to the Allow header
        $event->getResponse()->headers->set('Allow', 'OPTIONS', false);
    }
896185
public function handle(EventInterface $event)
    {
        $params = $event->getParams();

        if (count($params) < 1) {
            return;
        }

        // 初始化
        $spanid = 0;
        $logid = uniqid();

        $processName = $params[0];
        $uri = 'process-' . $processName;
        $flushInterval = 1;

        $contextData = [
            'logid'       => $logid,
            'spanid'      => $spanid,
            'uri'         => $uri,
            'requestTime' => microtime(true)
        ];

        App::getLogger()->setFlushInterval($flushInterval);
        RequestContext::setContextData($contextData);

        // 日志初始化
        App::getLogger()->initialize();
    }
401054
public function containsEvent(EventInterface $event)
    {
        return
            $event->containsPeriod($this) ||
            $event->isDuring($this) ||
            $this->contains($event->getBegin()) ||
            ($event->getEnd() && $this->contains($event->getEnd())  && $event->getEnd()->format('c') !== $this->begin->format('c'))
        ;
    }
821996
public function remove(EventInterface $event)
    {
        foreach ($this->events as $key => $internalEvent) {
            if ($event->getUid() === $internalEvent->getUid()) {
                unset($this->events[$key]);
            }
        }
    }
631242
public function loadUser(EventInterface $event) {
        $request = $event->getRequest();
        $response = $event->getResponse();
        $user = $request->getUser();
        $database = $event->getDatabase();

        $numImages = $database->getNumImages($user);
        $lastModified = $database->getLastModified([$user]);

        $userModel = new Model\User();
        $userModel->setUserId($user)
                  ->setNumImages($numImages)
                  ->setLastModified($lastModified);

        $response->setModel($userModel)
                 ->setLastModified($lastModified);
    }
1044237
public function injectActionHandles(EventInterface $event)
    {
        $handles = $this->getActionHandles($event);
        foreach ($handles as $handle) {
            $this->updater->addHandle($handle);
        }
    }