@param EventInterface $e

@return array|void
@throws \Zend\ServiceManager\Exception\ServiceNotFoundException
434714
public function onBootstrap(EventInterface $e)
    {
        /** @var MvcEvent $e */
        $eventManager        = $e->getApplication()->getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener->attach($eventManager);

        $sl = $e->getApplication()->getServiceManager();
        EntityManagerFactory::setDefaultServiceLocator($sl);
    }
665686
public function loadImage(EventInterface $event) {
        $request = $event->getRequest();
        $response = $event->getResponse();

        $event->getDatabase()->load(
            $request->getUser(),
            $request->getImageIdentifier(),
            $response->getModel()
        );
    }
444634
public function dispatch(EventInterface $event) : void
    {
        $eventName = $event->getName();
        $listeners = $this->dispatcher->getListeners($eventName);
        foreach ($listeners as $listener) {
            if (is_callable($listener)) {
                try {
                    $listener($event);
                } catch (\Throwable $e) {
                    throw new \InvalidArgumentException(
                        "Invalid callable as listener provided for event '{$eventName}',"
                        ." and it cannot be executed",
                        null,
                        $e
                    );
                }
            } else {
                try {
                    $listenerInstance = $this->getResolver()->get($listener);
                } catch (\Throwable $e) {
                    throw new ContainerServiceNotFound(
                        "Invalid service as listener '{$listener}' provided for event"
                        ." '{$eventName}', and it cannot be resolved",
                        null,
                        $e
                    );
                }
                if (!$listenerInstance instanceof ListenerInterface) {
                    throw new \InvalidArgumentException(
                        "Invalid service as listener '{$listener}' provided for event"
                        ." '{$eventName}', expected \Duktig\Core\Event\ListenerInterface"
                    );
                }
                $listenerInstance->handle($event);
            }
        }
    }
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());
        }
    }
202233
public function onBootstrap(EventInterface $e)
    {
        /** @var ServiceManager $serviceManager */
        $serviceManager = $e->getApplication()->getServiceManager();

        /** @var Environment $environment */
        $environment = $serviceManager->get(Environment::class);

        if ($environment->is(\Admin42\Module::ENVIRONMENT_ADMIN)) {
            $serviceManager
                ->get(PageEventListener::class)
                ->attach($e->getApplication()->getServiceManager()->get('Frontend42\Page\EventManager'));
        }

        if (!$environment->is(\Admin42\Module::ENVIRONMENT_ADMIN)) {
            $e->getApplication()
                ->getEventManager()
                ->attach(MvcEvent::EVENT_DISPATCH_ERROR, function ($e) use ($serviceManager){
                    /** @var Localization $localization */
                    $localization = $serviceManager->get(Localization::class);
                    $localization->acceptLocale($localization->getDefaultLocale());
                    $serviceManager->get(TranslatorInterface::class)->setLocale($localization->getActiveLocale());
                }, 100);
        }
    }
1223725
protected function afterSave(EntityInterface $entity): void
    {
        $argv = compact('entity');
        $argv = $this->getEventManager()->prepareArgs($argv);

        $this->getEventManager()->trigger("{$this->event_prefix}_save_after", $this, $argv);
        if ($this->entity_event_prefix) {
            $this->getEventManager()->trigger("{$this->entity_event_prefix}_save_after", $this, $argv);
        }
    }
249959
public function handle(EventInterface $event)
    {

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

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

            // load the service instance and switch the umask
            /** @var \AppserverIo\Appserver\Core\Api\DeploymentService $service */
            $service = $applicationServer->newService('AppserverIo\Appserver\Core\Api\DeploymentService');
            $service->initUmask($applicationServer->getSystemConfiguration()->getUmask());

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
901792
public function dispatch(EventInterface $event)
    {
        if (array_key_exists($event->getName(), $this->listeners)) {
            foreach ($this->listeners[$event->getName()] as $listener) {
                $listener($event);
            }
        }

        return $event;
    }
1238636
public function onBootstrap( EventInterface $event )
    {
        /* @var $event          \Zend\Mvc\MvcEvent */
        /* @var $application    \Zend\Mvc\Application */
        /* @var $serviceManager \Zend\ServiceManager\ServiceManager */

        $application    = $event->getApplication();
        $serviceManager = $application->getServiceManager();

        $application->getEventManager()
                    ->getSharedManager()
                    ->attach(
                        'Zend\Mvc\Application',
                        MvcEvent::EVENT_DISPATCH_ERROR,
                        array( $this, 'onDispatchError' )
                    );

        $response = $event->getResponse();

        if ( $response instanceof HttpResponse &&
             $serviceManager->has( 'RedirectToDomain' ) )
        {
            $redirect   = $serviceManager->get( 'RedirectToDomain' );
            $path       = '';
            $request    = $event->getRequest();

            if ( $request instanceof HttpRequest && $redirect->getUsePath() )
            {
                $path = $request->getRequestUri();
            }

            $url = $redirect->getUrl( $path );

            $response->setStatusCode( 302 )
                     ->getHeaders()
                     ->addHeaders( array(
                         'Location'          => $url,
                         'X-Redirect-Reason' => $redirect->getReason(),
                     ) );

            $this->response = $response->setContent( sprintf(
                '<meta http-equiv="refresh" content="0;url=%1$s">'
                    . '<a href="%1$s">%1$s</a>',
                htmlspecialchars( $url )
            ) );
        }
    }
1164474
protected function triggerHandlers(EventInterface $event)
    {
        foreach ($this->getHandlers($event->getName()) as $handler) {
            call_user_func($handler, $event);
            if ($event->isPropagationStopped()) {
                break;
            }
        }
    }
156195
public function attach(EventManagerInterface $events)
    {
        $this->listeners[] = $events->attach('configureService', array($this, 'handleExcludeAnnotation'));
        $this->listeners[] = $events->attach('configureService', array($this, 'handleContextAnnotation'));
        $this->listeners[] = $events->attach('configureService', array($this, 'handleExcludePatternAnnotation'));
        $this->listeners[] = $events->attach('configureService', array($this, 'handleVersionAnnotation'));
    }
120259
public function deleteImage(EventInterface $event) {
        $event->getManager()->trigger('db.image.delete');
        $event->getManager()->trigger('storage.image.delete');

        $model = new Model\ArrayModel();
        $model->setData([
            'imageIdentifier' => $event->getRequest()->getImageIdentifier(),
        ]);

        $event->getResponse()->setModel($model);
    }
258374
public function onBootstrap(EventInterface $event)
    {
        /** @var Application $application */
        $application        = $event->getApplication();
        $serviceManager = $application->getServiceManager();
        $eventManager       = $application->getEventManager();
        $sharedEventManager = $eventManager->getSharedManager();

        $eventManager->attach(
            $serviceManager->get('ZfcRbac\View\Strategy\UnauthorizedStrategy')
        );

        $sharedEventManager->attach(
            'Zend\View\Helper\Navigation\AbstractHelper',
            'isAllowed',
            [$serviceManager->get('KmbPermission\Listener\NavigationRbacListener'), 'isAllowed']
        );
    }
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);
    }
1001697
public function subscribe(EventInterface $event) {
        $resources = Resource::getAllResources();

        if ($this->params['additionalResources']) {
            $resources = array_merge($resources, $this->params['additionalResources']);
        }

        $events = [];
        foreach ($resources as $resource) {
            $events[$resource] = ['checkAccess' => 500];
        }

        $manager = $event->getManager();
        $manager->addCallbacks($event->getHandler(), $events);
    }
1044237
public function injectActionHandles(EventInterface $event)
    {
        $handles = $this->getActionHandles($event);
        foreach ($handles as $handle) {
            $this->updater->addHandle($handle);
        }
    }
1155145
public function onBootstrap(EventInterface $e)
    {
        if (!$e instanceof MvcEvent) {
            $errMsg = sprintf('Event not implement %s', MvcEvent::class);
            throw new Exception\InvalidArgumentException($errMsg);
        }

        $app = $e->getApplication();

        $eventManager        = $app->getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener->attach($eventManager);

        $sl = $app->getServiceManager();
        /** @var ParamsFromDoctrineModuleListener $paramsFromDoctrineModuleListener */
        $paramsFromDoctrineModuleListener = $sl->get(ParamsFromDoctrineModuleListener::class);
        $paramsFromDoctrineModuleListener->attach($eventManager);


        /** @var ResolverManagerRegistryResourceListener $resolverManagerRegistryResourceListener */
        $resolverManagerRegistryResourceListener = $sl->get(ResolverManagerRegistryResourceListener::class);
        $resolverManagerRegistryResourceListener->attach($eventManager);

        /** @var ManagerRegistryListener $managerRegistryListener */
        $managerRegistryListener = $sl->get(ManagerRegistryListener::class);
        $managerRegistryListener->attach($eventManager);

    }