Função de processamento dos Helpers setados no controller
@param \Zend\Mvc\MvcEvent $e
11034
public static function processViewHelpersInControllers($e) {
        $viewHelperManager = $e->getApplication()->getServiceManager()->get('ViewHelperManager');

        if (isset($_SESSION['processHead'])) {
            $process = $_SESSION['processHead'];
            unset($_SESSION['processHead']);
        } else {
            $process = null;
        }
        /**
         * Definbe um novo ou adiciona outro Titulo da página
         */
        if (isset($process['headTitle']) and ! empty($process['headTitle'])) {
            $headTitle = $viewHelperManager->get('headTitle');
            $headTitle($process['headTitle']['title'], $process['headTitle']['type'])->setSeparator($process['headTitle']['separator'])->setAutoEscape(false);
        }

        /**
         * Define o Doctype da página
         */
        if (isset($process['doctype']) and ! empty($process['doctype'])) {
            $doctype = $viewHelperManager->get('doctype');
            $doctype($process['doctype']);
        }

        /**
         * Define o Content Type da página
         */
        if (isset($process['contentType']) and ! empty($process['contentType'])) {
            $contentType = $viewHelperManager->get('headMeta');
            if (($process['doctype'] == \Zend\View\Helper\Doctype::XHTML5) or ( $process['doctype'] == \Zend\View\Helper\Doctype::HTML5)) {
                $contentType()->setCharset($process['contentType'])->setSeparator(PHP_EOL);
            } else {
                $contentType()->appendHttpEquiv('Content-Type', 'text/html; charset=' . $process['contentType'])->setSeparator(PHP_EOL);
            }
        }

        /**
         * Define o Content Lang da página
         */
        if (isset($process['contentLang']) and ! empty($process['contentLang'])) {
            $contentLang = $viewHelperManager->get('headMeta');
            $contentLang()->appendHttpEquiv('Content-Language', $process['contentLang'])->setSeparator(PHP_EOL);
        }

        /**
         * Define Link de Estilo CSS ou Less da página
         */
        if (isset($process['headCssLink']) and ! empty($process['headCssLink'])) {
            $headCssLink = $viewHelperManager->get('headLink');
            foreach ($process['headCssLink'] as $key => $value) {
                if ($value['typeFile'] == 'css') {
                    $headCssLink()->appendStylesheet($value['url'], $value['media'], $value['conditional'])->setSeparator(PHP_EOL);
                } else if ($value['typeFile'] == 'less') {
                    $headCssLink()->appendStylesheet(URL_DEFAULT . 'less.php?' . $value['url'], $value['media'], $value['conditional'])->setSeparator(PHP_EOL);
                }
            }
        }

        /**
         * Define Link de Scripts JS na página
         */
        if (isset($process['headJsLink']) and ! empty($process['headJsLink'])) {
            $headJsLink = $viewHelperManager->get('headScript');
            foreach ($process['headJsLink'] as $key => $value) {
                $headJsLink()->appendFile($value['url'], $value['type'], $value['attrs'])->setSeparator(PHP_EOL);
            }
        }

        /**
         * Define Link de cabeçalho da página
         */
        if (isset($process['headLink']) and ! empty($process['headLink'])) {
            $headLink = $viewHelperManager->get('headLink');
            foreach ($process['headLink'] as $valueHeadLink) {
                $headLink($valueHeadLink, 'PREPEND')->setSeparator(PHP_EOL);
            }
        }

        /**
         * Define Estilo CSS na página
         */
        if (isset($process['headCssStyle']) and ! empty($process['headCssStyle'])) {
            $headCssLink = $viewHelperManager->get('headStyle');
            foreach ($process['headCssStyle'] as $key => $value) {
                $headCssLink()->appendStyle($value['css'], $value['conditional'])->setSeparator(PHP_EOL);
            }
        }

        /**
         * Define Scripts JS na página
         */
        if (isset($process['headJsScript']) and ! empty($process['headJsScript'])) {
            $headJsScript = $viewHelperManager->get('headScript');
            foreach ($process['headJsScript'] as $key => $value) {
                $headJsScript()->appendScript($value['script'], $value['type'], $value['conditional'])->setSeparator(PHP_EOL);
            }
        }

        /**
         * Define o Favicon da página
         */
        if (isset($process['favicon']) and ! empty($process['favicon'])) {
            $favicon = $viewHelperManager->get('headLink');
            if (($this->getDoctype() == \Zend\View\Helper\Doctype::XHTML5) or ( $this->getDoctype() == \Zend\View\Helper\Doctype::HTML5)) {
                $favicon(array('rel' => 'shortcut icon', 'href' => $process['favicon']), 'PREPEND')->setSeparator(PHP_EOL);
            } else {
                $favicon(array('rel' => 'favicon', 'href' => $process['favicon']), 'PREPEND')->setSeparator(PHP_EOL);
            }
        }

        /**
         * Define Meta Tags do tipo Name
         */
        if (isset($process['metaName']) and ! empty($process['metaName'])) {
            $metaName = $viewHelperManager->get('headMeta');
            foreach ($process['metaName'] as $key => $value) {
                $metaName()->appendName($value['key'], $value['content'])->setSeparator(PHP_EOL);
            }
        }

        /**
         * Define Meta Tags do tipo Property
         */
        if (isset($process['metaProperty']) and ! empty($process['metaProperty'])) {
            /**
             *
              $isFacebook = new \Cityware\View\Helper\IsFacebook();
              if ($isFacebook) {
              $this->getRenderer()->setDoctype(\Zend\View\Helper\Doctype::XHTML1_RDFA11);
              $this->getRenderer()->appendProperty($keyValue, $content)->setSeparator(PHP_EOL);
              }
             */
            $metaProperty = $viewHelperManager->get('headMeta');
            $doctype = $viewHelperManager->get('doctype');
            $doctype(\Zend\View\Helper\Doctype::XHTML1_RDFA11);

            foreach ($process['metaProperty'] as $key => $value) {
                $metaProperty()->appendProperty($value['key'], $value['content'])->setSeparator(PHP_EOL);
            }
        }

        /**
         * Define Meta Tags do tipo HttpEquiv
         */
        if (isset($process['metaHttpEquiv']) and ! empty($process['metaHttpEquiv'])) {
            $metaName = $viewHelperManager->get('headMeta');
            foreach ($process['metaHttpEquiv'] as $key => $value) {
                $metaName()->appendHttpEquiv($value['key'], $value['content'])->setSeparator(PHP_EOL);
            }
        }
    }
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);
                }
            }
        }
    }
664223
public function onDispatchError(MvcEvent $event)
    {
        // Do nothing if the result is a response object
        $result     = $event->getResult();
        $routeMatch = $event->getRouteMatch();
        $response   = $event->getResponse();
        $router     = $event->getRouter();
        $error      = $event->getError();
        $url        = $this->redirectUri;

        if ($result instanceof Response
            || ! $routeMatch
            || ($response && ! $response instanceof Response)
            || ! (
                Route::ERROR === $error
                || Controller::ERROR === $error
                || (
                    Application::ERROR_EXCEPTION === $error
                    && ($event->getParam('exception') instanceof UnAuthorizedException)
                )
            )
        ) {
            return;
        }

        if (null === $url) {
            $url = $router->assemble(array(), array('name' => $this->redirectRoute));
        }

        $response = $response ?: new Response();

        $response->getHeaders()->addHeaderLine('Location', $url);
        $response->setStatusCode(302);

        $event->setResponse($response);
    }
1057176
public function dispatchError(\Zend\Mvc\MvcEvent $e)
    {
        $error = $e->getError();
        if (empty($error)) {
            return;
        }

        // Do nothing if the result is a response object
        $result = $e->getResult();
        if ($result instanceof \Zend\Stdlib\ResponseInterface) {
            return;
        }

        switch ($error) {
            case \Zend\Mvc\Application::ERROR_CONTROLLER_NOT_FOUND:
            case \Zend\Mvc\Application::ERROR_CONTROLLER_INVALID:
            case \Zend\Mvc\Application::ERROR_ROUTER_NO_MATCH:
            case 'error-route-unauthorized':
                // Specifically not handling these
                return;

            case \Zend\Mvc\Application::ERROR_EXCEPTION:
                $exception = $e->getParam('exception');
                if (!($exception instanceof \Exception)) {
                    return;
                }
                $msg = '';
                $prev = $exception->getPrevious();
                while ($prev !== null) {
                    $msg .= PHP_EOL.'Previous: '.$prev->getMessage().' in '.
                             $prev->getFile().' in line '.$prev->getLine().
                             '.';
                    $prev = $prev->getPrevious();
                }
                $this->log(ErrorLogger::ERR,
                        'Dispatch: '.$exception->getMessage().' in '.
                                 $exception->getFile().' in line '.
                                 $exception->getLine().'.'.$msg.PHP_EOL.
                                 'Trace:'.PHP_EOL.
                                 $exception->getTraceAsString());
                break;
            default:
                $this->log(ErrorLogger::ERR,
                'Erro desconhecido no dispatch: '.$error);
                break;

        }
    }
720126
public function handler(MvcEvent $event)
    {
        $match = $event->getRouteMatch();

        if (!$match) { // we need a route
            return;
        }

        $role = $this->roleProvider->getUserRole();

        if (!$this->acl->isAllowed($role, $match->getMatchedRouteName())) {
            $controller = $this->config['TrascastroACL']['forbidden']['controller'];
            $action     = $this->config['TrascastroACL']['forbidden']['action'];
            $response   = $event->getResponse();

            $response->setStatusCode(Response::STATUS_CODE_403); // Forbidden
            $match->setParam('controller', $controller);
            $match->setParam('action', $action);
        }

        // we make the acl available on views
        $event->getViewModel()->setVariable('tacl', $this->acl);
    }
281790
public function onBootstrap(MvcEvent $event)
    {
        $serviceManager = $event->getApplication()->getServiceManager();

        $request = $serviceManager->get('request');

        if ($request instanceof ConsoleRequest) {
            return;
        }

        //Add Domain Checker
        $eventWrapper = $serviceManager->get(
            \Rcm\EventListener\EventWrapper::class
        );

        /** @var \Zend\EventManager\EventManager $eventManager */
        $eventManager = $event->getApplication()->getEventManager();

        // Check for redirects from the CMS
        $eventManager->attach(
            MvcEvent::EVENT_ROUTE,
            [$eventWrapper, 'routeEvent'],
            10000
        );

        // Set the sites layout.
        $eventManager->attach(
            MvcEvent::EVENT_DISPATCH,
            [$eventWrapper, 'dispatchEvent'],
            10000
        );

        // Set the custom http response checker
        $eventManager->attach(
            MvcEvent::EVENT_FINISH,
            [$eventWrapper, 'finishEvent'],
            10000
        );

        $viewEventManager = $serviceManager->get('ViewManager')
            ->getView()
            ->getEventManager();

        // Set the plugin response over-ride
        $viewEventManager->attach(
            ViewEvent::EVENT_RESPONSE,
            [$eventWrapper, 'viewResponseEvent'],
            -10000
        );

        // Use the configured session handler.
        // Should we really boot this for every request though?
        $serviceManager->get(\Rcm\Service\SessionManager::class)->start();
    }
431500
public function error(MvcEvent $event): void
    {
        if (
            true === $this->tracyOptions->getEnabled()
            && null !== $event->getParam('error')
            && null !== $event->getParam('exception')
        ) {
            ob_clean();

            throw $event->getParam('exception');
        }
    }
925637
public function setDateFormat(Event $e)
    {
        /* @var EventsForm $form */
        $form = $e->getParam('form');
        /* @var EventsHydrator $hydrator */
        $hydrator = $form->getHydrator();
        /* @var DateTime $dateTimeStrategy */
        $dateTimeStrategy = $hydrator->getStrategy('dateTime');
        $dateTimeStrategy->setHydrateFormat($this->getOptions()->getDateFormat());
    }
68362
public function onBootstrap(MvcEvent $e)
    {
        $serviceManager = $e->getApplication()->getServiceManager();

        // Don't break console routes
        if ($e->getRequest() instanceof Request) {
            return;
        }

        //Add Domain Checker
        $onDispatchListener = $serviceManager->get(
            \RcmAdmin\EventListener\DispatchListener::class
        );

        /** @var \Zend\EventManager\EventManager $eventManager */
        $eventManager = $e->getApplication()->getEventManager();

        $eventManager->attach(
            MvcEvent::EVENT_DISPATCH,
            [
                $onDispatchListener,
                'getAdminPanel'
            ],
            10001
        );
    }
984992
public function onBootstrap(MvcEvent $e)
    {
        $manager = Container::getDefaultManager();
        if (!$manager->sessionExists()) {
            return;
        }

        $app = $e->getApplication();
        /** @var \Zend\EventManager\SharedEventManagerInterface $sharedEvm */
        $sharedEvm = $app->getEventManager()->getSharedManager();

        $sharedEvm->attach(
            AbstractActionController::class,
            'dispatch',
            [$this, 'flashMessengerHandler'],
            2
        );
    }
791501
public function onBootstrap(EventInterface $e)
    {
        /* @var $e \Zend\Mvc\MvcEvent */
        $serviceManager = $e->getApplication()->getServiceManager();
        /* @var $serviceManager \Zend\ServiceManager\ServiceManager */

        $this->initPluginManagerFactory(
            $serviceManager,
            __NAMESPACE__ . '\SupervisorManager',
            'supervisor_plugin_manager'
        );

        $this->initPluginManagerFactory(
            $serviceManager,
            __NAMESPACE__ . '\ListenerManager',
            'listener_plugin_manager'
        );
    }
641089
public function onRoute(MvcEvent $e)
    {
        if (!$e->getRequest() instanceof HttpRequest || !$e->getResponse() instanceof HttpResponse) {
            return null;
        }

        /** @var HttpResponse $response */
        $response = $e->getResponse();

        $data = $this->getCacheService()->load($e);

        if ($data !== null) {
            $this->loadedFromCache = true;

            if ($this->getOptions()->getCacheResponse() === true) {
                $response = unserialize($data);
            } else {
                $response = $e->getResponse();
                $response->setContent($data);
            }

            $this->addDebugResponseHeader($response, 'Hit');

            return $response;
        }

        $this->addDebugResponseHeader($response, 'Miss');
    }
261429
public function collect(MvcEvent $mvcEvent)
    {
        /* @var $application \Zend\Mvc\Application */
        if (! $application = $mvcEvent->getApplication()) {
            return;
        }
        
        $sm = $application->getServiceManager();
        $applicationConfig = $sm->get('ApplicationConfig');
        
        // general
        $this->data = array();
        $this->data[] = array(
            'label' => 'General',
            'results' => $this->getGeneral($mvcEvent)
        );
        
        if (isset($applicationConfig['modules']) && in_array('DoctrineORMModule', $applicationConfig['modules'])) {
            $this->data[] = array(
                'label' => 'Doctrine settings',
                'results' => $this->getDoctrine($mvcEvent)
            );
        }
        
        // loaded modules
        if (isset($applicationConfig['modules'])) {
            foreach ($applicationConfig['modules'] as $moduleName) {
                $this->data[] = array(
                    'label' => $moduleName,
                    'results' => $this->getModulePerformance($moduleName, $mvcEvent)
                );
            }
        }
    }
181107
public function checkOptions(MvcEvent $e)
    {
        $matches  = $e->getRouteMatch();
        $response = $e->getResponse();
        $request  = $e->getRequest();
        $method   = $request->getMethod();

        // test if we matched an individual resource, and then test
        // if we allow the particular request method
        if ($matches->getParam('id', false)) {
            if (!in_array($method, $this->allowedResourceMethods)) {
                $response->setStatusCode(405);
                return $response;
            }
            return;
        }

        // We matched a collection; test if we allow the particular request 
        // method
        if (!in_array($method, $this->allowedCollectionMethods)) {
            $response->setStatusCode(405);
            return $response;
        }
    }
1160302
public function onDispatch(MvcEvent $e)
    {
        $request = $e->getRequest();
        if (!$request instanceof HttpRequest) {
            throw new RuntimeException('CRUD controller from CmsCommon can only handle HTTP requests');
        }

        $action = $this->params()->fromRoute('action', 'not-found');
        $method = static::getMethodFromAction($action);

        if (!method_exists($this, $method)) {
            $method = 'notFoundAction';
        }

        $object = null;
        if ($action === static::ACTION_READ ||
            $action === static::ACTION_UPDATE ||
            $action === static::ACTION_DELETE
        ) {
            $options = $this->getOptions();
            $id = $this->params()->fromRoute($options->getIdentifierKey());

            if (null === $id) {
                $this->flashMessenger()->addWarningMessage(sprintf(
                    $this->translate('An identifier must be provided to %s an object'),
                    $this->translate($action)
                ));

                return $this->redirectToBaseRoute();
            }

            if (!($object = $this->getDomainService()->getMapper()->find($id))) {
                $this->flashMessenger()->addWarningMessage($this->translate('An object cannot be found'));
                return $this->redirectToBaseRoute();
            }
        }

        $data = $this->getData($object);

        // Return early if getData method returned a response
        if ($data instanceof ResponseInterface) {
            $actionResponse = $data;
        } else {
            switch ($action) {
                case static::ACTION_READ:
                case static::ACTION_DELETE:
                    $actionResponse = $this->$method($data, $object);
                    break;
                case static::ACTION_UPDATE:
                    $actionResponse = $this->$method($data, $object);
                    break;
                default:
                    $actionResponse = $this->$method($data);
            }
        }

        $e->setResult($actionResponse);
    }
1019419
public function onDispatch(MvcEvent $e)
    {
        $routeMatch = $e->getRouteMatch();
        if (!$routeMatch) {
            /**
             * @todo Determine requirements for when route match is missing.
             *       Potentially allow pulling directly from request metadata?
             */
            throw new \Zend\Mvc\Exception\DomainException('Missing route matches; unsure how to retrieve action');
        }

        $action = $routeMatch->getParam('action', null);

        if ($action) {
            $action = strtolower($action);
        }

        switch ($action) {
            case 'process':
                $message = $routeMatch->getParam('message', null);

                if($message instanceof MessageInterface) {
                    $result = $this->process($message);
                } else {
                    throw new \InvalidArgumentException(
                        'Missing or invalid message type: must be an instace of '. MessageInterface::class
                    );
                }
                break;

            case 'send':
            case 'receive':
            case 'await':

                $queue = $routeMatch->getParam('queue', null);

                if (is_string($queue)) {
                    $queue = $this->getServiceLocator()->get($queue);
                }

                if (!$queue instanceof QueueClientInterface) {
                    throw new \InvalidArgumentException(
                        'Invalid queue param type: must be a string or an instace of '. QueueClientInterface::class
                    );
                }

                if ($action === 'send') {

                    $message = $routeMatch->getParam('message', null);
                    $parameters = $routeMatch->getParam('sendParameters', null);

                    if ($parameters === null) {
                        $params = null;
                    } else if ($parameters instanceof SendParametersInterface) {
                        $params = $parameters;
                    } else if (is_string($parameters)) {
                        $params = new SendParameters();
                        $params->fromString($parameters);
                    } else if (is_array($parameters)) {
                        $params = new SendParameters();
                        $params->fromArray($parameters);
                    } else {
                        throw new \InvalidArgumentException(
                            'Invalid sendParameters param type: must be null, an array, a string or an instace of '. SendParametersInterface::class
                        );
                    }

                    $result = $this->send($queue, $message, $params);
                } else {

                    $parameters = $routeMatch->getParam('receiveParameters', null);

                    if ($parameters === null) {
                        $params = null;
                    } else if ($parameters instanceof ReceiveParametersInterface) {
                        $params = $parameters;
                    } else if (is_string($parameters)) {
                        $params = new ReceiveParameters();
                        $params->fromString($parameters);
                    } else if (is_array($parameters)) {
                        $params = new ReceiveParameters();
                        $params->fromArray($parameters);
                    } else {
                        throw new \InvalidArgumentException(
                            'Invalid receiveParameters param type: must be null, an array, a string or an instace of '. QueueClientInterface::class
                        );
                    }

                    if ($action === 'receive') {
                        $maxMessages = (int) $routeMatch->getParam('maxMessages', 1);
                        $result = $this->receive($queue, $maxMessages, $params);
                    } else {
                        $result = $this->await($queue, $params);
                    }
                }
                break;

            default:
                throw new \InvalidArgumentException(
                    sprintf('Invalid action "%s". Only "process", "send", "receive", "await" are allowed', $action)
                );
        }


        $e->setResult($result);

        return $result;
    }
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();
            }
        }
    }