當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RequestStack::getMasterRequest方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\RequestStack::getMasterRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP RequestStack::getMasterRequest方法的具體用法?PHP RequestStack::getMasterRequest怎麽用?PHP RequestStack::getMasterRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\RequestStack的用法示例。


在下文中一共展示了RequestStack::getMasterRequest方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getThumbnailInfo

 /**
  * @param $path
  * @param $alias
  * @param bool|false $isAbsolute
  * @return array
  * @throws \Exception
  */
 public function getThumbnailInfo($path, $alias, $isAbsolute = false)
 {
     $filter = isset($this->settings['filters'][$alias]) ? $this->settings['filters'][$alias] : null;
     if (!$filter) {
         throw new \Exception(sprintf('Unknown thumbnail filter "%s"', $alias));
     }
     if (!$path) {
         $default = null;
         if (isset($filter['default'])) {
             $defaultAlias = explode('.', $filter['default']);
             $default = $this->settings['defaults'];
             foreach ($defaultAlias as $defaultAliasName) {
                 $default = $default[$defaultAliasName];
             }
         }
         $src = $default;
     } else {
         $src = sprintf('/%s/%s', $this->settings['url_prefix'], $alias) . $path;
     }
     if ($isAbsolute || $this->settings['absolute']) {
         $host = $this->request->getMasterRequest()->getSchemeAndHttpHost();
         $port = $this->request->getMasterRequest()->getPort();
         if ($port != 80) {
             $host .= ':' . $port;
         }
         $src = $host . $src;
     }
     $width = $filter['width'];
     $height = $filter['height'];
     return ['src' => $src, 'width' => $width, 'height' => $height];
 }
開發者ID:develoid,項目名稱:thumbnail-bundle,代碼行數:38,代碼來源:ThumbnailManager.php

示例2: vote

 /**
  * If you have failed to login too many times, a log of this will be present
  * in your session and the databse (incase session is dropped the record remains).
  *
  * @access public
  * @return int
  */
 public function vote()
 {
     $request = $this->requestStack->getMasterRequest();
     if (($this->forceAccountRecovery['enabled'] || $this->blockPages['enabled']) && $request) {
         $route = $request->get('_route');
         $ipAddress = $request->getClientIp();
         $this->blockPages['routes'][] = $this->routeLogin['name'];
         if ($this->blockPages['enabled'] && in_array($route, $this->blockPages['routes'])) {
             // Get number of failed login attempts.
             $attempts = $this->loginFailureTracker->getAttempts($ipAddress, $this->blockPages['duration_in_minutes']);
             if (count($attempts) >= $this->blockPages['after_attempts']) {
                 // You have too many failed login attempts, login access is temporarily blocked.
                 return self::ACCESS_DENIED_BLOCK;
             }
         }
         $this->forceAccountRecovery['routes'][] = $this->routeLogin['name'];
         if ($this->forceAccountRecovery['enabled'] && in_array($route, $this->forceAccountRecovery['routes'])) {
             // Get number of failed login attempts.
             $attempts = $this->loginFailureTracker->getAttempts($ipAddress, $this->forceAccountRecovery['duration_in_minutes']);
             if (count($attempts) >= $this->forceAccountRecovery['after_attempts']) {
                 // You have too many failed login attempts, login access is temporarily blocked, go recover your account.
                 return self::ACCESS_DENIED_DEFER;
             }
         }
     }
     return self::ACCESS_ALLOWED;
 }
開發者ID:nicolaskern,項目名稱:CCDNUserSecurityBundle,代碼行數:34,代碼來源:SecurityManager.php

示例3: createAndHandle

 public function createAndHandle($name, $type, IEntity $entity)
 {
     $request = $this->request_stack->getMasterRequest();
     $form = $this->form_factory->createNamed($name, $type, $entity, ['method' => 'POST']);
     $form->handleRequest($request);
     return $form;
 }
開發者ID:Zemistr,項目名稱:symfony-3-first-app,代碼行數:7,代碼來源:FormFactory.php

示例4: getCurrentRequest

 /**
  * {@inheritdoc}
  */
 public function getCurrentRequest()
 {
     if (null === $this->request) {
         $this->request = $this->requestStack->getMasterRequest();
     }
     return $this->request;
 }
開發者ID:wellcommerce,項目名稱:wellcommerce,代碼行數:10,代碼來源:RequestHelper.php

示例5: render

 /**
  * {@inheritdoc}
  */
 public function render(GridViewInterface $grid, ColumnInterface $column, $sorting)
 {
     $definition = $grid->getDefinition();
     $name = $column->getName();
     if (!$definition->hasSort($name)) {
         return;
     }
     $sort = $sorting === SorterInterface::ASC ? $name : '-' . $name;
     $routeParameters = [];
     if (($request = $this->requestStack->getMasterRequest()) !== null) {
         $routeParameters = array_merge($request->attributes->get('_route_params', []), $request->query->all());
     }
     if (!isset($routeParameters['grid']['reset']) && isset($routeParameters['grid']['sorting']) && $routeParameters['grid']['sorting'] === $sort) {
         return;
     }
     if ($definition->hasOption('persistent') && $definition->getOption('persistent')) {
         $filters = $this->filterManager->get($definition);
         if (isset($filters['sorting']) && $filters['sorting'] === $sort) {
             return;
         }
     }
     $routeParameters['grid']['sorting'] = $sort;
     unset($routeParameters['grid']['reset']);
     return $this->urlGenerator->generate($definition->getOption('grid_route'), $routeParameters);
 }
開發者ID:php-lug,項目名稱:lug,代碼行數:28,代碼來源:SorterRenderer.php

示例6: execute

 /**
  * {@inheritDoc}
  *
  * @param ObtainCreditCard $request
  */
 public function execute($request)
 {
     RequestNotSupportedException::assertSupports($this, $request);
     $httpRequest = null;
     if ($this->httpRequest instanceof Request) {
         $httpRequest = $this->httpRequest;
     } else {
         if ($this->httpRequestStack instanceof RequestStack) {
             $httpRequest = $this->httpRequestStack->getMasterRequest();
         }
     }
     if (false == $httpRequest) {
         throw new LogicException('The action can be run only when http request is set.');
     }
     $form = $this->createCreditCardForm();
     $form->handleRequest($httpRequest);
     if ($form->isSubmitted()) {
         /** @var CreditCardInterface $card */
         $card = $form->getData();
         $card->secure();
         if ($form->isValid()) {
             $request->set($card);
             return;
         }
     }
     $renderTemplate = new RenderTemplate($this->templateName, array('model' => $request->getModel(), 'firstModel' => $request->getFirstModel(), 'form' => $form->createView(), 'actionUrl' => $request->getToken() ? $request->getToken()->getTargetUrl() : null));
     $this->gateway->execute($renderTemplate);
     throw new HttpResponse(new Response($renderTemplate->getResult(), 200, array('Cache-Control' => 'no-store, no-cache, max-age=0, post-check=0, pre-check=0', 'X-Status-Code' => 200, 'Pragma' => 'no-cache')));
 }
開發者ID:payum,項目名稱:core,代碼行數:34,代碼來源:ObtainCreditCardAction.php

示例7: initializeTree

 public function initializeTree(TreeInitializedEvent $event)
 {
     if ($masterRequest = $this->requestStack->getMasterRequest()) {
         if ($node = $event->getTree()->find($masterRequest->attributes->all())) {
             $node->setActive();
         }
     }
 }
開發者ID:webfactory,項目名稱:navigation-bundle,代碼行數:8,代碼來源:ActiveNodeEventListener.php

示例8: getMasterRequest

 /**
  * @return Request
  */
 private function getMasterRequest()
 {
     $masterRequest = $this->requestStack->getMasterRequest();
     if (null === $masterRequest) {
         throw new \UnexpectedValueException('There are not any requests on request stack');
     }
     return $masterRequest;
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:11,代碼來源:ChannelContext.php

示例9: getLocale

 /**
  * Get user's locale
  *
  * @return string
  */
 protected function getLocale()
 {
     $request = $this->requestStack->getMasterRequest();
     if (null === $request) {
         return 'en';
     }
     return $request->getLocale();
 }
開發者ID:abdeldayem,項目名稱:pim-community-dev,代碼行數:13,代碼來源:TranslationsExtension.php

示例10: mergeDefaultParameters

 /**
  * {@inheritdoc}
  */
 protected function mergeDefaultParameters(array $parameters)
 {
     $parameters = parent::mergeDefaultParameters($parameters);
     $language = $this->requestStack->getMasterRequest()->headers->get('Accept-Language');
     $parameters['headers'] = isset($parameters['headers']) ? $parameters['headers'] : [];
     $parameters['headers'] = array_merge($parameters['headers'], ['Accept-Language' => $language]);
     return $parameters;
 }
開發者ID:mapado,項目名稱:rest-client-sdk-bundle,代碼行數:11,代碼來源:RequestAwareRestClient.php

示例11: getRequest

 /**
  * @return Request
  */
 public function getRequest()
 {
     if (null === $this->request) {
         return $this->requestStack->getMasterRequest();
     } else {
         return $this->request;
     }
 }
開發者ID:alcalyn,項目名稱:twig-extension-onpath,代碼行數:11,代碼來源:OnPath.php

示例12: getMasterRequest

 /**
  * @return Request
  */
 private function getMasterRequest()
 {
     $masterRequest = $this->requestStack->getMasterRequest();
     if (null === $masterRequest) {
         throw new ChannelNotFoundException();
     }
     return $masterRequest;
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:11,代碼來源:FakeChannelContext.php

示例13: addCurrent

 public function addCurrent(ItemInterface $menu)
 {
     $currentRoute = $this->stack->getMasterRequest()->get('_route');
     $route = $this->menu[$menu->getName()]['route'];
     if ($currentRoute == $route) {
         $menu->setCurrent(true);
     }
 }
開發者ID:npakai,項目名稱:enhavo,代碼行數:8,代碼來源:MenuEventListener.php

示例14: getCurrentScopeId

 /**
  * {@inheritdoc}
  */
 public function getCurrentScopeId()
 {
     if (null === $this->requestStack->getMasterRequest()) {
         return null;
     }
     $sessionBag = $this->requestStack->getMasterRequest()->getSession();
     $scope = $sessionBag->get($this->getSessionBagNamespace());
     return isset($scope['id']) ? $scope['id'] : null;
 }
開發者ID:raizeta,項目名稱:WellCommerce,代碼行數:12,代碼來源:AbstractShopContext.php

示例15: getCurrentItem

 /**
  * @return null|Structure
  */
 public function getCurrentItem()
 {
     $request = $this->requestStack->getMasterRequest();
     if (empty($this->currentItem) && $request && $request->attributes->has(Structure::ROUTING_ID_NAME)) {
         $structureId = $request->attributes->get(Structure::ROUTING_ID_NAME);
         $this->currentItem = $this->entityManger->getRepository('OctavaStructureBundle:Structure')->getById($structureId);
     }
     return $this->currentItem;
 }
開發者ID:octava,項目名稱:cms,代碼行數:12,代碼來源:StructureManager.php


注:本文中的Symfony\Component\HttpFoundation\RequestStack::getMasterRequest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。