当前位置: 首页>>代码示例>>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;未经允许,请勿转载。