当前位置: 首页>>代码示例>>PHP>>正文


PHP HttpFoundation\RequestStack类代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\RequestStack的典型用法代码示例。如果您正苦于以下问题:PHP RequestStack类的具体用法?PHP RequestStack怎么用?PHP RequestStack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RequestStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct(TranslatorInterface $translator, Router $router, LocaleManager $localeManager, RequestStack $requestStack)
 {
     $this->translator = $translator;
     $this->router = $router;
     $this->localeManager = $localeManager;
     $this->request = $requestStack->getCurrentRequest();
 }
开发者ID:szymach,项目名称:admin-translatable-bundle,代码行数:7,代码来源:TranslationLocaleMenuListener.php

示例2: createMainMenu

 public function createMainMenu(RequestStack $requestStack)
 {
     $menu = $this->_factory->createItem('root');
     $items = $this->_manager->getRepository('MenuBundle:Menu')->findAll();
     $currentRoute = $requestStack->getMasterRequest()->attributes->get('_route');
     $westItems = array_slice($items, 0, 2);
     $eastItems = array_slice($items, 2, 2);
     foreach ($westItems as $item) {
         $menu->addChild($item->getTitle(), ['route' => $item->getRoute()])->setAttribute('class', 'touch-hover');
         if ($item->getRoute() === str_replace("_default", "", $currentRoute)) {
             $menu[$item->getTitle()]->setCurrent(TRUE);
         }
     }
     // $menu
     //     ->addChild(NULL, [
     //         'route' => 'index', 'routeParameters' => [
     //             '_locale' => $requestStack->getMasterRequest()->attributes->get('_locale')
     //         ]
     //     ])
     //     ->setAttribute('class', 'logo-holder')
     //     ->setLinkAttribute('class', 'logo')
     // ;
     foreach ($eastItems as $item) {
         $menu->addChild($item->getTitle(), ['route' => $item->getRoute()])->setAttribute('class', 'touch-hover');
         if ($item->getRoute() === str_replace("_default", "", $currentRoute)) {
             $menu[$item->getTitle()]->setCurrent(TRUE);
         }
     }
     return $menu;
 }
开发者ID:Kid-Binary,项目名称:KamillNurakhmetov,代码行数:30,代码来源:MenuBuilder.php

示例3: __construct

 /**
  * @param RequestStack $requestStack
  * @param EntityManager $entityManager
  * @param $securityContext
  * @param $acl
  */
 public function __construct(RequestStack $requestStack, EntityManager $entityManager, SecurityContext $securityContext, $acl)
 {
     $this->securityContext = $securityContext;
     $this->request = $requestStack->getCurrentRequest();
     $this->em = $entityManager;
     $this->acl = $acl;
 }
开发者ID:headonkeyboard,项目名称:KunstmaanBundlesCMS,代码行数:13,代码来源:SlugSecurityListener.php

示例4: __construct

 /**
  * @DI\InjectParams({
  *     "container"       = @DI\Inject("service_container"),
  *     "httpKernel"      = @DI\Inject("http_kernel"),
  *     "requestStack"    = @DI\Inject("request_stack"),
  *     "resourceManager" = @DI\Inject("claroline.manager.resource_manager")
  * })
  */
 public function __construct(ContainerInterface $container, HttpKernelInterface $httpKernel, RequestStack $requestStack, ResourceManager $resourceManager)
 {
     $this->container = $container;
     $this->httpKernel = $httpKernel;
     $this->request = $requestStack->getCurrentRequest();
     $this->resourceManager = $resourceManager;
 }
开发者ID:claroline,项目名称:distribution,代码行数:15,代码来源:PathListener.php

示例5: __construct

 /**
  * @param IntegrationHelper            $integrationHelper
  * @param UserPasswordEncoderInterface $encoder
  * @param EventDispatcherInterface     $dispatcher
  * @param RequestStack                 $requestStack
  */
 public function __construct(IntegrationHelper $integrationHelper, UserPasswordEncoderInterface $encoder, EventDispatcherInterface $dispatcher, RequestStack $requestStack)
 {
     $this->encoder = $encoder;
     $this->dispatcher = $dispatcher;
     $this->integrationHelper = $integrationHelper;
     $this->request = $requestStack->getCurrentRequest();
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:13,代码来源:FormAuthenticator.php

示例6: __construct

 /**
  * Constructs a PageRedirect object.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin ID for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
  *   The logger factory service.
  * @param \Drupal\Core\Path\CurrentPathStack $current_path_stack
  *   The current path stack service.
  * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
  *   The request stack service.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger_factory, CurrentPathStack $current_path_stack, RequestStack $request_stack)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->logger = $logger_factory->get('rules');
     $this->currentPathStack = $current_path_stack;
     $this->request = $request_stack->getCurrentRequest();
 }
开发者ID:Progressable,项目名称:openway8,代码行数:23,代码来源:SystemPageRedirect.php

示例7:

 function it_throws_a_channel_not_found_exception_if_channel_with_given_code_was_not_found(FakeChannelCodeProviderInterface $fakeChannelCodeProvider, ChannelRepositoryInterface $channelRepository, RequestStack $requestStack, Request $request)
 {
     $requestStack->getMasterRequest()->willReturn($request);
     $fakeChannelCodeProvider->getCode($request)->willReturn('CHANNEL_CODE');
     $channelRepository->findOneByCode('CHANNEL_CODE')->willReturn(null);
     $this->shouldThrow(ChannelNotFoundException::class)->during('getChannel');
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:7,代码来源:FakeChannelContextSpec.php

示例8: setUp

 protected function setUp()
 {
     /**
      * Add the test type to the factory and
      * the form to the container
      */
     $factory = new FormFactoryBuilder();
     $factory->addExtension(new CoreExtension());
     $factory->addType(new TestType());
     /**
      * Construct the container
      */
     $container = new Container();
     $container->set("thelia.form_factory_builder", $factory);
     $container->set("thelia.translator", new Translator($container));
     $container->setParameter("thelia.parser.forms", $definition = array("test_form" => "Thelia\\Tests\\Resources\\Form\\TestForm"));
     $request = new Request();
     $requestStack = new RequestStack();
     $requestStack->push($request);
     $request->setSession(new Session(new MockArraySessionStorage()));
     $container->set("request", $request);
     $container->set("request_stack", $requestStack);
     $container->set("thelia.forms.validator_builder", new ValidatorBuilder());
     $container->set("event_dispatcher", new EventDispatcher());
     $this->factory = new TheliaFormFactory($requestStack, $container, $definition);
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:26,代码来源:TheliaFormFactoryTest.php

示例9: let

 public function let(RequestStack $requestStack, Request $request, Session $session, ParameterBag $cookies)
 {
     $requestStack->getCurrentRequest()->willReturn($request);
     $request->getSession()->willReturn($session);
     $request->cookies = $cookies;
     $this->beConstructedWith($requestStack);
 }
开发者ID:pazjacket,项目名称:pborreli-_-composer-service,代码行数:7,代码来源:ChannelAuthenticatorSpec.php

示例10: testOnPageContext

 /**
  * @covers ::onPageContext
  */
 public function testOnPageContext()
 {
     $collection = new RouteCollection();
     $route_provider = $this->prophesize(RouteProviderInterface::class);
     $route_provider->getRoutesByPattern('/test_route')->willReturn($collection);
     $request = new Request();
     $request_stack = new RequestStack();
     $request_stack->push($request);
     $data_definition = new DataDefinition(['type' => 'entity:user']);
     $typed_data = $this->prophesize(TypedDataInterface::class);
     $this->typedDataManager->getDefaultConstraints($data_definition)->willReturn([]);
     $this->typedDataManager->create($data_definition, 'banana')->willReturn($typed_data->reveal());
     $this->typedDataManager->createDataDefinition('bar')->will(function () use($data_definition) {
         return $data_definition;
     });
     $page = $this->prophesize(PageInterface::class);
     $this->executable->expects($this->once())->method('getPage')->will($this->returnValue($page->reveal()));
     $page->getPath()->willReturn('/test_route');
     $this->executable->expects($this->at(1))->method('addContext')->with('foo', $this->isInstanceOf(Context::class));
     $this->executable->expects($this->at(2))->method('addContext')->with('baz', $this->isInstanceOf(Context::class));
     $collection->add('test_route', new Route('/test_route', [], [], ['parameters' => ['foo' => ['type' => 'bar'], 'baz' => ['type' => 'bop'], 'page' => ['type' => 'entity:page']]]));
     // Set up a request with one of the expected parameters as an attribute.
     $request->attributes->add(['foo' => 'banana']);
     $route_param_context = new RouteParamContext($route_provider->reveal(), $request_stack);
     $route_param_context->onPageContext($this->event);
 }
开发者ID:pulibrary,项目名称:recap,代码行数:29,代码来源:RouteParamContextTest.php

示例11: __construct

 /**
  * @param DisplayMediaManager               $displayMediaManager
  * @param MediaRepositoryInterface          $mediaRepository
  * @param RequestStack                      $requestStack
  * @param MediaWithFormatExtractorInterface $mediaWithFormatExtractor
  */
 public function __construct(DisplayMediaManager $displayMediaManager, MediaRepositoryInterface $mediaRepository, RequestStack $requestStack, MediaWithFormatExtractorInterface $mediaWithFormatExtractor)
 {
     $this->displayMediaManager = $displayMediaManager;
     $this->mediaRepository = $mediaRepository;
     $this->request = $requestStack->getMasterRequest();
     $this->mediaWithFormatExtractor = $mediaWithFormatExtractor;
 }
开发者ID:itkg-canne,项目名称:open-orchestra-media-bundle,代码行数:13,代码来源:DisplayMediaExtension.php

示例12: handleRequestStack

 /**
  * Handle the request stack
  */
 protected function handleRequestStack()
 {
     $currentRequest = $this->requestStack->getCurrentRequest();
     if ($currentRequest) {
         $this->add('request.locale', $currentRequest->getLocale());
     }
 }
开发者ID:sumocoders,项目名称:framework-core-bundle,代码行数:10,代码来源:JsData.php

示例13: __construct

 /**
  * @DI\InjectParams({
  *     "httpKernel"   = @DI\Inject("http_kernel"),
  *     "requestStack" = @DI\Inject("request_stack"),
  *     "router"       = @DI\Inject("router"),
  *     "translator"   = @DI\Inject("translator")
  * })
  */
 public function __construct(HttpKernelInterface $httpKernel, RequestStack $requestStack, UrlGeneratorInterface $router, TranslatorInterface $translator)
 {
     $this->httpKernel = $httpKernel;
     $this->request = $requestStack->getCurrentRequest();
     $this->router = $router;
     $this->translator = $translator;
 }
开发者ID:claroline,项目名称:distribution,代码行数:15,代码来源:ChatListener.php

示例14: __construct

 /**
  * @param EntityManagerInterface $em
  * @param EngineInterface $twigEngine
  * @param TranslatorInterface $translator
  * @param RequestStack $requestStack
  */
 public function __construct(EntityManagerInterface $em, EngineInterface $twigEngine, TranslatorInterface $translator, RequestStack $requestStack)
 {
     $this->em = $em;
     $this->translator = $translator;
     $this->render = $twigEngine;
     $this->request = $requestStack->getCurrentRequest();
 }
开发者ID:oakrudi,项目名称:data-grid-bundle,代码行数:13,代码来源:StrategyGridObject.php

示例15: createRequestStack

 /**
  * @return RequestStack
  */
 private function createRequestStack()
 {
     $request = Request::create('/');
     $requestStack = new RequestStack();
     $requestStack->push($request);
     return $requestStack;
 }
开发者ID:netdudes,项目名称:IgorwFileServeBundle,代码行数:10,代码来源:SendfileResponseFactoryTest.php


注:本文中的Symfony\Component\HttpFoundation\RequestStack类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。