getRequest() публичный Метод

Get the request of the controller
public getRequest ( ) : Neos\Flow\Mvc\RequestInterface
Результат Neos\Flow\Mvc\RequestInterface
 /**
  * Build a list of sites
  *
  * @param ControllerContext $controllerContext
  * @return array
  */
 public function buildSiteList(ControllerContext $controllerContext)
 {
     $requestUriHost = $controllerContext->getRequest()->getHttpRequest()->getUri()->getHost();
     $domainsFound = false;
     $sites = array();
     foreach ($this->siteRepository->findOnline() as $site) {
         $uri = null;
         $active = false;
         /** @var $site Site */
         if ($site->hasActiveDomains()) {
             $activeHostPatterns = $site->getActiveDomains()->map(function ($domain) {
                 return $domain->getHostPattern();
             })->toArray();
             $active = in_array($requestUriHost, $activeHostPatterns, true);
             if ($active) {
                 $uri = $controllerContext->getUriBuilder()->reset()->setCreateAbsoluteUri(true)->uriFor('index', array(), 'Backend\\Backend', 'Neos.Neos');
             } else {
                 $uri = $controllerContext->getUriBuilder()->reset()->uriFor('switchSite', array('site' => $site), 'Backend\\Backend', 'Neos.Neos');
             }
             $domainsFound = true;
         }
         $sites[] = array('name' => $site->getName(), 'nodeName' => $site->getNodeName(), 'uri' => $uri, 'active' => $active);
     }
     if ($domainsFound === false) {
         $uri = $controllerContext->getUriBuilder()->reset()->setCreateAbsoluteUri(true)->uriFor('index', array(), 'Backend\\Backend', 'Neos.Neos');
         $sites[0]['uri'] = $uri;
     }
     return $sites;
 }
Пример #2
0
 /**
  * Get variables from configuration that should be set in the context by default.
  * For example Eel helpers are made available by this.
  *
  * @return array Array with default context variable objects.
  */
 protected function getDefaultContextVariables()
 {
     if ($this->defaultContextVariables === null) {
         $this->defaultContextVariables = array();
         if (isset($this->settings['defaultContext']) && is_array($this->settings['defaultContext'])) {
             $this->defaultContextVariables = EelUtility::getDefaultContextVariables($this->settings['defaultContext']);
         }
         $this->defaultContextVariables['request'] = $this->controllerContext->getRequest();
     }
     return $this->defaultContextVariables;
 }
 /**
  * @param ControllerContext $controllerContext
  */
 public function setControllerContext($controllerContext)
 {
     $this->controllerContext = $controllerContext;
     $request = $controllerContext->getRequest();
     if (!$this->templatePaths instanceof TemplatePaths || !$request instanceof ActionRequest) {
         return;
     }
     $this->templatePaths->setPatternReplacementVariables(['packageKey' => $request->getControllerPackageKey(), 'subPackageKey' => $request->getControllerSubpackageKey(), 'controllerName' => $request->getControllerName(), 'action' => $request->getControllerActionName(), 'format' => $request->getFormat() ?: 'html']);
 }
 /**
  * @param ControllerContext $controllerContext
  * @param Site $site
  * @return string
  * @throws NeosException
  */
 public function createSiteUri(ControllerContext $controllerContext, Site $site)
 {
     $primaryDomain = $site->getPrimaryDomain();
     if ($primaryDomain === null) {
         throw new NeosException(sprintf('Cannot link to a site "%s" since it has no active domains.', $site->getName()), 1460443524);
     }
     $requestUri = $controllerContext->getRequest()->getHttpRequest()->getUri();
     $baseUri = $controllerContext->getRequest()->getHttpRequest()->getBaseUri();
     $port = $primaryDomain->getPort() ?: $requestUri->getPort();
     return sprintf('%s://%s%s%s', $primaryDomain->getScheme() ?: $requestUri->getScheme(), $primaryDomain->getHostPattern(), $port && !in_array($port, [80, 443], true) ? ':' . $port : '', rtrim($baseUri->getPath(), '/'));
 }