Evaluates the guard for the given event.

@param EventInterface $event

@return bool

@since Method available since Release 2.0.0
543875
private function evaluateGuard(EventInterface $event)
    {
        foreach ((array) $this->guardEvaluators as $guardEvaluator) {
            $result = call_user_func([$guardEvaluator, 'evaluate'], $event, $this->getPayload(), $this);
            if (!$result) {
                return false;
            }
        }

        return true;
    }
89185
public function handle(EventInterface $event)
    {
        try {
            $this->getApplicationServer()->getSystemLogger()->info($event->getName());
        } catch (\Exception $e) {
             $this->getApplicationServer()->getSystemLogger()->error($e->__toString());
        }
    }
1313616
public function distributeExpire(EventInterface $event)/*# : bool */
    {
        $dist = $this->distribution;
        $item = $event->getParam('item');

        if ($item instanceof CacheItemExtendedInterface) {
            // expire ttl
            $ttl = $item->getExpiration()->getTimestamp() - time();

            // percentage
            $percent = (rand(0, $dist * 2) - $dist) * 0.001;

            // new expire ttl
            $new_ttl = (int) round($ttl + $ttl * $percent);
            $item->expiresAfter($new_ttl);
        }

        return true;
    }
1272361
public function autoRotate(EventInterface $event) {
        $event->getTransformationManager()
            ->getTransformation('autoRotate')
            ->setImage($event->getRequest()->getImage())
            ->transform([]);
    }
1080053
public function stampedeProtect(EventInterface $event)/*# : bool */
    {
        /* @var CachePool $pool */
        $pool = $event->getTarget();
        /* @var CacheItem $item */
        $item = $event->getParam('item');

        if ($item instanceof CacheItemExtendedInterface) {
            $left = $item->getExpiration()->getTimestamp() - time();
            if ($left < $this->time_left && rand(1, 1000) <= $this->probability) {
                return $pool->setError(
                    Message::get(Message::CACHE_EXT_STAMPEDE, $item->getKey()),
                    Message::CACHE_EXT_STAMPEDE
                );
            }
        }

        return true;
    }
707959
public function getRules(EventInterface $event) {
        $request = $event->getRequest();
        $publicKey = $request->getRoute()->get('publickey');

        $accessControl = $event->getAccessControl();
        $keyExists = $accessControl->publicKeyExists($publicKey);

        if (!$keyExists) {
            throw new RuntimeException('Public key not found', 404);
        }

        $accessList = $accessControl->getAccessListForPublicKey($publicKey);

        if ($request->query->has('expandGroups')) {
            foreach ($accessList as &$rule) {
                if (!isset($rule['group'])) {
                    continue;
                }

                $rule['resources'] = $accessControl->getGroup($rule['group']);
            }
        }

        $model = new AccessRulesModel();
        $model->setRules($accessList);

        $event->getResponse()->setModel($model);
    }
1041035
public function redirectIt(EventInterface $event)/*# : bool */
    {
        /* @var ResultInterface $result */
        $result = $event->getParam('result');

        if (!isset($_SERVER['HTTPS'])) {
            $result->setStatus(Status::MOVED_PERMANENTLY);
            return false;
        }
        return true;
    }
775270
public function save(EventInterface $event)
    {
        $this->events[(string) $event->uuid()][] = new $event(
            $event->uuid(),
            $event->type(),
            $event->body(),
            $this->count($event->uuid()),
            $event->occurredOn()->format('Y-m-d H:i:s.u')
        );
    }
284078
public function handle(EventInterface $event)
    {

        try {
            // load the application server and the naming directory instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();
            /** @var \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory */
            $namingDirectory = $applicationServer->getNamingDirectory();

            // write a log message that the event has been invoked
            $applicationServer->getSystemLogger()->info($event->getName());

            // deploy the applications for all containers
            /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */
            foreach ($applicationServer->getSystemConfiguration()->getContainers() as $containerNode) {
                // load the container instance to deploy the applications for
                /** @var \AppserverIo\Psr\ApplicationServer\ContainerInterface $container */
                $container = $namingDirectory->search(
                    sprintf(
                        'php:services/%s/%s',
                        $applicationServer->runlevelToString(ApplicationServerInterface::NETWORK),
                        $containerNode->getName()
                    )
                );

                // load the containers deployment
                /** @var \AppserverIo\Psr\Deployment\DeploymentInterface $deployment */
                $deployment = $container->getDeployment();
                $deployment->injectContainer($container);

                // deploy and initialize the container's applications
                $deployment->deploy();
            }

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
53728
public function captureStop(EventInterface $event)
    {
        $time = microtime(true);

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

            return;
        }
        $this->timers[$this->index]['stop'] = $time;
    }
646709
public function handle(EventInterface $event)
    {
        $dir = yii::getAlias('@runtime');

        FileHelper::createDirectory($dir);
        file_put_contents($dir . DIRECTORY_SEPARATOR . 'events.log', $this->serializeEvent($event) . PHP_EOL, FILE_APPEND | LOCK_EX);
    }
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];
    }
1202418
public function handle(ActionInterface $event)
    {
        $data = $event->getAction();

        $action = [
            'class_name'  => get_class($event),
            'user_id'     => $data['user']->id,
            'username'    => $data['user']->username,
            'description' => $data['description'],
        ];

        if (isset($data['information'])) {
            $action['information'] = $data['information'];
        }

        Action::create($action);
    }
1345350
public function delete(EventInterface $event) {
        $event->getManager()->trigger('db.metadata.delete');
        $event->getResponse()->setModel(new Model\Metadata());
    }
998842
public function remove(EventInterface $event)
    {
        $index = $this->computeIndex($event);
        if (isset($this->events[$index])) {
            foreach ($this->events[$index] as $key => $internalEvent) {
                if ($event->getUid() == $internalEvent->getUid()) {
                    unset($this->events[$index][$key]);
                    --$this->count;
                }
            }
        }
    }
636156
protected function getTriggers(EventInterface $event)
    {
        $eventName  = $event->getName();
        $eventClass = get_class($event);

        $search = [];

        if (isset($this->events[$eventName])) {
            $search[] = $this->events[$eventName];
        }
        if (isset($this->events[$eventClass])) {
            $search[] = $this->events[$eventClass];
        }

        $parent = $event;
        while ($parent = get_parent_class($parent)) {
            if (isset($this->events[$parent])) {
                $search[] = $this->events[$parent];
            }
        }

        if (empty($search)) {
            return $search;
        }

        $triggers = call_user_func_array('array_merge_recursive', $search);

        krsort($triggers);

        return call_user_func_array('array_merge', $triggers);
    }
1143383
public function handle(EventInterface $event)
    {
        if ($event instanceof StatsEvent) {
            $this->writeProgressionLine('');
            $this->style->success('Phar creation successful');
            $this->style->table([], [
                ['Path', '<info>' . $event->getStats()->getFinalPath() . '</info>'],
                ['File size', '<info>' . $event->getSize() . '</info>'],
                ['Process duration', '<info>' . $event->getDuration() . '</info>']
            ]);
        }

        if ($event instanceof BuilderAddEvent) {
            $this->writeProgressionLine('Adding <comment>' . $event->getPath() . '</comment>');
        }

        if ($event instanceof CompressorEvent) {
            $this->writeProgressionLine('<info>Compressing...</info>');
        }

        if (0 === strpos($event->getName(), 'options.')) {
            $this->writeProgressionLine(
                '<comment>Read options...</comment> (' . ucfirst(substr($event->getName(), \strlen('options.'))) . ')',
                true
            );
        }
    }