Test limits and take actions if they have been exceeded

@param MvcEvent $event
2007
public function check(MvcEvent $event)
    {
        foreach ($this->limits as $limit) {
            if ($this->storage->check($this->remoteAddress->getIpAddress(), $limit)) {
                foreach ($limit->getActions() as $action) {
                    $action($event);
                }
            }
        }
    }
1154172
protected function __completeRequest(MvcEvent $event)
    {
        $event->setTarget($this);

        $events = $this->getEventManager();
        $events->trigger(MvcEvent::EVENT_RENDER, $event);
        $events->trigger(MvcEvent::EVENT_FINISH, $event);
    }
744863
public function routeLoad(MvcEvent $event)
    {
        $request = $event->getRequest();
        if(!(
            $request->getMethod() == \Zend\Http\Request::METHOD_GET &&
            $request->getQuery()->count() == 0
        )) {
            // We do not cache route match for requests that can produce
            // different match.
            return ;
        }
    
        $event->setParam('route-cacheable', true);
    
        // check if we have data in our cache
        $path = $request->getUri()
                        ->getPath();
    
        $cache = $event->getApplication()->getServiceManager()->get('var-cache');
        $cacheKey = $this->getCacheKey($path);
        $cachedData = $cache->getItem($cacheKey);
    
        if(!empty($cachedData)) {
            $event->setParam('route-cached', true);
    
            $cachedRoute = \Zend\Mvc\Router\Http\Literal::factory($cachedData);
            $router = $event->getRouter();
            $router->addRoute($cachedData['name'], $cachedRoute, 99999);
        }
    }
1355965
public function init(MvcEvent $event): void
    {
        if (true === $this->tracyOptions->getEnabled()) {
            Debugger::enable($this->tracyOptions->getMode());

            if (null !== $this->tracyOptions->getEmail()) {
                Debugger::$email = $this->tracyOptions->getEmail();
            }

            if (null !== $this->tracyOptions->getLogDirectory()) {
                Debugger::$logDirectory = $this->tracyOptions->getLogDirectory();
            }

            if (null !== $this->tracyOptions->getLogSeverity()) {
                Debugger::$logSeverity = $this->tracyOptions->getLogSeverity();
            }

            if (null !== $this->tracyOptions->getMaxDepth()) {
                Debugger::$maxDepth = $this->tracyOptions->getMaxDepth();
            }

            if (null !== $this->tracyOptions->getMaxLength()) {
                Debugger::$maxLength = $this->tracyOptions->getMaxLength();
            }

            if (null !== $this->tracyOptions->getShowBar()) {
                Debugger::$showBar = $this->tracyOptions->getShowBar();
            }

            if (null !== $this->tracyOptions->getShowLocation()) {
                Debugger::$showLocation = $this->tracyOptions->getShowLocation();
            }

            if (null !== $this->tracyOptions->getStrict()) {
                Debugger::$strictMode = $this->tracyOptions->getStrict();
            }
        }
    }
333081
public void fire(TestSuiteFinishedEvent event) {
        String suiteUid = event.getUid();

        TestSuiteResult testSuite = testSuiteStorage.remove(suiteUid);
        if (testSuite == null) {
            return;
        }
        event.process(testSuite);

        testSuite.setVersion(getVersion());
        testSuite.getLabels().add(AllureModelUtils.createProgrammingLanguageLabel());

        writeTestSuiteResult(testSuite);

        notifier.fire(event);
    }
215453
public function handleXmlHttpRequest(MvcEvent $event)
	{
		$request = $event->getRequest();
		if ($request->isXMLHttpRequest()) {
			$dispatchResult = $event->getResult();
			if ($dispatchResult instanceof ViewModel) {
				$dispatchResult->setTerminal(true);
			}
		}
	}
919812
public function initialize(MvcEvent $event)
    {
        $appConfig = $event->getApplication()->getServiceManager()->get('config');
        if (array_key_exists(self::CONFIG_KEY, $appConfig)) {
            $this->configure($appConfig[self::CONFIG_KEY]);
        }
        
        $event->getApplication()
            ->getServiceManager()
            ->get('controllerPluginManager')
            ->setService($this->pluginName, $this);
    }
495007
protected function performValidation(Model $model, $event)
    {
        // If the model has validating enabled, perform it.
        if ($model->getValidating()) {
            // Fire the namespaced validating event and prevent validation
            // if it returns a value.
            if ($this->fireValidatingEvent($model, $event) !== null) {
                return;
            }

            if ($model->isValid() === false) {
                // Fire the validating failed event.
                $this->fireValidatedEvent($model, 'failed');

                if ($model->getThrowValidationExceptions()) {
                    $model->throwValidationException();
                }

                return false;
            }
            // Fire the validating.passed event.
            $this->fireValidatedEvent($model, 'passed');
        } else {
            $this->fireValidatedEvent($model, 'skipped');
        }
    }
232294
@Override
    public void onProgress(final StreamingProgressEvent event) {
        assertStateConsistency(fileUploadId, event.getFileName());

        if (event.getBytesReceived() > maxSize || event.getContentLength() > maxSize) {
            LOG.error("User tried to upload more than was allowed ({}).", maxSize);
            interruptUploadDueToFileSizeExceeded(maxSize);
            return;
        }
        if (isUploadInterrupted()) {
            return;
        }

        publishUploadProgressEvent(fileUploadId, event.getBytesReceived(), event.getContentLength());
    }
49123
public function onDispatch(MvcEvent $event)
    {
        /* @var $response \Zend\Http\Response */
        $response = $event->getResponse();
        if (!method_exists($response, 'getStatusCode') || $response->getStatusCode() !== 404) {
            return;
        }
        $request        = $event->getRequest();
        $serviceManager = $event->getApplication()->getServiceManager();
        $assetManager   = $serviceManager->get(__NAMESPACE__ . '\Service\AssetManager');

        if (!$assetManager->resolvesToAsset($request)) {
            return;
        }

        $response->setStatusCode(200);

        return $assetManager->setAssetOnResponse($response);
    }
300482
public function setupLayout(MvcEvent $event)
    {
        $viewModel = $event->getResult();
        if (!$this->viewRenderer instanceof PhpRenderer
            || !$viewModel instanceof ViewModel
            || $viewModel->terminate()) {
            return;
        }
        $this->configureView();
    }
277623
protected function handleError($event)
    {
        if (error_reporting() & $event->code) {
            $this->getSentryClient()->captureException(
                $this->createErrorException($event->message, $event->code, $event->file, $event->line)
            );
        }
        parent::handleError($event);
    }
1048320
public function onFinish(MvcEvent $event)
    {
        $connection = $this->getObjectManager()->getConnection();
        
        if ($connection->isTransactionActive()) {
            $connection->commit();
        }
    }
237956
public function onDispatchController(MvcEvent $eventvent)
    {
        $controller = $eventvent->getTarget();

        // Check ACL
        if ($controller instanceof \JaztecAcl\Controller\AuthorizedController) {
            $controller->checkAcl($eventvent);
        }
    }
1114281
public function prepareLimit(RepositorySearchEvent $event)
    {
        $data = $event->getData();
        if (array_key_exists('limit', $data)) {
            if($data['limit'] > 1000){
               $data['limit'] = 1000;
            }           
            
            $event->getQueryBuilder()->setLimit($data['limit']);

            unset($data['limit']);

            $event->setData($data);
        } else {
            $event->getQueryBuilder()->setLimit(BaseRepository::DEFAULT_LIMIT);
        }
    }
1211373
public function afterScenario($event)
    {
        $this->testcaseTimer->stop();
        $code = $event->getTestResult()->getResultCode();
        $testResultString = array(
            TestResult::PASSED    => 'passed',
            TestResult::SKIPPED   => 'skipped',
            TestResult::PENDING   => 'pending',
            TestResult::FAILED    => 'failed',
            TestResult::UNDEFINED => 'undefined',
        );

        $this->testsuiteStats[$code]++;

        $this->currentTestcase->addAttribute('time', \round($this->testcaseTimer->getTime(), 3));
        $this->currentTestcase->addAttribute('status', $testResultString[$code]);
    }
370372
public function routeLoad(MvcEvent $event)
    {
        $request = $event->getRequest();
        if(!(
            $request instanceof HttpRequest &&
            $request->isGet() &&
            $request->getQuery()->count() == 0
        )) {
            // We do not cache route match for requests that can produce
            // different match.
            return;
        }

        $event->setParam('route-cacheable', true);

        // check if we have data in our cache
        $path = $request->getUri()->getPath();

        $services = $event->getApplication()->getServiceManager();

        $cacheName = $services->get(RouterCacheOptions::class)->getCache();
        $cache = $services->get($cacheName);

        $cacheKey = $this->getCacheKey($path);
        $cachedData = $cache->getItem($cacheKey);

        if($cachedData) {
            $event->setParam('route-cached', true);
            $router = $event->getRouter();
            $router->addRoute($cachedData['name'], $cachedData['spec'], round(PHP_INT_MAX/2));
        }
    }