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


PHP FilterControllerEvent::isMasterRequest方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpKernel\Event\FilterControllerEvent::isMasterRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP FilterControllerEvent::isMasterRequest方法的具体用法?PHP FilterControllerEvent::isMasterRequest怎么用?PHP FilterControllerEvent::isMasterRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpKernel\Event\FilterControllerEvent的用法示例。


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

示例1: onKernelController

 public function onKernelController(FilterControllerEvent $event)
 {
     if ($event->isMasterRequest()) {
         $route = $event->getRequest()->get('_route');
         if ($this->isExcludedRoute($route)) {
             return;
         }
         if ($this->isAsset($_SERVER['REQUEST_URI'])) {
             return;
         }
         $is_logged = $this->securityContext->isGranted('IS_AUTHENTICATED_FULLY');
         if (!$is_logged && $route != 'fos_user_security_login') {
             $redirectUrl = $this->router->generate('fos_user_security_login');
             $event->setController(function () use($redirectUrl) {
                 return new RedirectResponse($redirectUrl);
             });
         }
         if (!$is_logged && $route == 'fos_user_security_login') {
             return;
         }
         if (!$this->rolesProvider->hasRouteAccess($route)) {
             throw new AccessDeniedException();
         }
     }
 }
开发者ID:sanborino,项目名称:clinica,代码行数:25,代码来源:AccessCheckerListener.php

示例2: onKernelController

 /**
  * @param FilterControllerEvent $event
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $request = $event->getRequest();
     $this->logger->info('Attributes are logged.', ['metadata' => ['attributes' => $request->attributes->all()], 'description' => 'attributes']);
 }
开发者ID:supportyard,项目名称:monitoring-bundle,代码行数:11,代码来源:LogAttributesListener.php

示例3: onKernelController

 /**
  * @param FilterControllerEvent $event
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $route = $this->getRoute($event->getRequest());
     $this->logger->info('LOGIC START', array($route));
 }
开发者ID:ec-cube,项目名称:ec-cube,代码行数:11,代码来源:LogListener.php

示例4: registerCurrentController

 public function registerCurrentController(FilterControllerEvent $event)
 {
     // this check is needed because in Symfony a request can perform any
     // number of sub-requests. See
     // http://symfony.com/doc/current/components/http_kernel/introduction.html#sub-requests
     if ($event->isMasterRequest()) {
         $this->twigExtension->setController($event->getController());
     }
 }
开发者ID:hasstoss,项目名称:symfony-demo,代码行数:9,代码来源:ControllerListener.php

示例5: onKernelController

 /**
  * @param FilterControllerEvent $event
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $request = $event->getRequest();
     $app = $request->attributes->get('_app');
     if (!isset($app['interceptors'])) {
         return;
     }
     $this->manager->handle($request);
 }
开发者ID:supportyard,项目名称:framework-bundle,代码行数:15,代码来源:InterceptorListener.php

示例6: readControllerAnnotations

 /**
  * Read the controller annotations and change theme if the annotation indicate that need
  * @param FilterControllerEvent $event
  */
 public function readControllerAnnotations(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         // prevents calling this for controller usage within a template or elsewhere
         return;
     }
     $controller = $event->getController();
     list($controller, $method) = $controller;
     // the controller could be a proxy, e.g. when using the JMSSecuriyExtraBundle or JMSDiExtraBundle
     $controllerClassName = ClassUtils::getClass($controller);
     $this->themeEngine->changeThemeByAnnotation($controllerClassName, $method);
 }
开发者ID:Silwereth,项目名称:core,代码行数:16,代码来源:ControllerAnnotationReaderListener.php

示例7: onKernelController

 /**
  * @param \Symfony\Component\HttpKernel\Event\FilterControllerEvent $event
  *
  * @return void
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $request = $event->getRequest();
     $transactionName = $request->attributes->get('_route');
     $requestUri = $request->server->get('REQUEST_URI', 'n/a');
     $host = $request->server->get('COMPUTERNAME', $this->system->getHostname());
     $this->newRelicApi->setNameOfTransaction($transactionName);
     $this->newRelicApi->addCustomParameter('request_uri', $requestUri);
     $this->newRelicApi->addCustomParameter('host', $host);
     if ($this->ignoreTransaction($transactionName)) {
         $this->newRelicApi->markIgnoreTransaction();
     }
 }
开发者ID:spryker,项目名称:NewRelic,代码行数:21,代码来源:ControllerListener.php

示例8: insertModuleStylesheet

 /**
  * Add the module stylesheet to the page assets.
  * @param FilterControllerEvent $event
  * @throws \Twig_Error_Loader
  */
 public function insertModuleStylesheet(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $controller = $event->getController()[0];
     if ($controller instanceof AbstractController) {
         /** @var AbstractModule $module */
         $module = $this->kernel->getModule($controller->getName());
         try {
             $module->addStylesheet();
         } catch (\InvalidArgumentException $e) {
             // The module doesn't contain the default stylesheet.
         }
     }
 }
开发者ID:Silwereth,项目名称:core,代码行数:21,代码来源:ModuleStylesheetInsertListener.php

示例9: onKernelController

 public function onKernelController(FilterControllerEvent $event)
 {
     $route = $event->getRequest()->attributes->get('_route');
     if (!$event->isMasterRequest() || in_array($route, ['comunidad_select', 'comunidad_new'])) {
         return;
     }
     $user = $this->token ? $this->token->getUser() : null;
     if (!$user instanceof Usuario) {
         return;
     }
     $comunidad = $this->comunidadProvider->get();
     if (!$comunidad instanceof Comunidad) {
         $fakeRequest = $event->getRequest()->duplicate(null, null, array('_controller' => 'AppBundle:Comunidad:index'));
         $controller = $this->resolver->getController($fakeRequest);
         $event->setController($controller);
     }
 }
开发者ID:javiermadueno,项目名称:futbol,代码行数:17,代码来源:ComunidadListener.php

示例10: onKernelController

 public function onKernelController(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $controller = $event->getController();
     if (!is_array($controller)) {
         return;
     }
     $control = $controller[0];
     if ($control instanceof LangController) {
         $url = $control->checkLang($event->getRequest());
         if (!is_null($url)) {
             $event->setController(function () use($url) {
                 return new RedirectResponse($url);
             });
         }
     }
 }
开发者ID:kimerikal,项目名称:util-bundle,代码行数:19,代码来源:LocaleListener.php

示例11: setUpThemePathOverrides

 /**
  * Add ThemePath to searchable paths when locating templates using name-spaced scheme
  * @param FilterControllerEvent $event
  * @throws \Twig_Error_Loader
  */
 public function setUpThemePathOverrides(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     // add theme path to template locator
     $controller = $event->getController()[0];
     if ($controller instanceof AbstractController) {
         $theme = $this->themeEngine->getTheme();
         $bundleName = $controller->getName();
         if ($theme) {
             $overridePath = $theme->getPath() . '/Resources/' . $bundleName . '/views';
             if (is_readable($overridePath)) {
                 $paths = $this->loader->getPaths($bundleName);
                 // inject themeOverridePath before the original path in the array
                 array_splice($paths, count($paths) - 1, 0, array($overridePath));
                 $this->loader->setPaths($paths, $bundleName);
             }
         }
     }
 }
开发者ID:Silwereth,项目名称:core,代码行数:26,代码来源:TemplatePathOverrideListener.php

示例12: onKernelController

 /**
  * @author Krzysztof Bednarczyk
  * @param FilterControllerEvent $event
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $controller = $event->getController()[0];
     if (!$controller instanceof Controller) {
         //do nothing when is other controller;
         return;
     }
     $request = $event->getRequest();
     /**
      * Validate CSRF token
      */
     $isXVRequest = (int) $request->headers->get('X-XV-Request', 0);
     if ($isXVRequest) {
         if (!$this->checkCsrfToken($request)) {
             throw new CsrfHttpException("Invalid CSRF token. Please turn on cookies and reload page.");
         }
         $request->headers->set("X-XV-{$this->uniqueKey}", 1);
         return;
     }
     $controller = $event->getController()[0];
     if (!$controller instanceof Controller) {
         return;
     }
     /**
      * Prevent posting data directly form other post
      */
     if ($request->getMethod() !== Request::METHOD_GET) {
         $event->setController(function () use($request) {
             return new RedirectResponse($request->getRequestUri());
         });
         return;
     }
     $request->headers->set("X-XV-First-Request", 1);
     $request->headers->set("X-XV-Source", "bootstrap");
 }
开发者ID:xvengine,项目名称:symfony-bridge,代码行数:42,代码来源:KernelListener.php

示例13: onKernelController

 public function onKernelController(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     if (!$this->maintenance) {
         return;
     }
     $this->customRoutesExclusion();
     foreach ($this->routesExclusion as $routePattern) {
         if (preg_match($routePattern, $event->getRequest()->get('_route'))) {
             return;
         }
     }
     $this->isAdmin = $this->container->get('security.authorization_checker')->isGranted('ROLE_ADMIN');
     if (!$this->isAdmin) {
         $controller = new MaintenanceController();
         $controller->setContainer($this->container);
         $event->setController([$controller, 'maintenanceAction']);
         //            dump($event->getController());
         //            die();
     }
 }
开发者ID:kokmok,项目名称:SKCMS-Core,代码行数:23,代码来源:MaintenanceListener.php

示例14: onKernelRequestAddGlobalJS

 /**
  * Add mauticForms in js script tag for Froala.
  *
  * @param FilterControllerEvent $event
  */
 public function onKernelRequestAddGlobalJS(FilterControllerEvent $event)
 {
     if (defined('MAUTIC_INSTALLER') || $this->userHelper->getUser()->isGuest || !$event->isMasterRequest()) {
         return;
     }
     $list = $this->em->getRepository('MauticFormBundle:Form')->getSimpleList();
     $mauticForms = json_encode($list, JSON_FORCE_OBJECT | JSON_PRETTY_PRINT);
     $this->assetsHelper->addScriptDeclaration("var mauticForms = {$mauticForms};");
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:14,代码来源:CoreSubscriber.php

示例15: onKernelController

 public function onKernelController(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $request = $event->getRequest();
     if (!$request->attributes->has('_api')) {
         return;
     }
     /** @var Api $api */
     $api = $request->attributes->get('_api');
     $subRequests = $this->getSubRequests($request);
     $bulk = $api->isBulkable() && $subRequests;
     $stream = ($api->isStreamable() || $bulk) && $this->shouldStream($request);
     if (!$bulk && !$stream) {
         $request->attributes->set('stream', $this->noop);
         return;
     }
     // This listener will unwind/spread the calls, so don't trigger other Api listeners.
     $request->attributes->remove('_api');
     if ($stream) {
         $headers = ['content-type' => 'application/json; boundary=NL', 'x-accel-buffering' => 'no'];
     } else {
         $headers = ['content-type' => 'application/json'];
     }
     if ($subRequests) {
         $event->setController(function () use($request, $headers, $subRequests, $stream) {
             return new StreamedResponse(function () use($request, $subRequests, $stream) {
                 $promises = [];
                 foreach ($subRequests as $i => $requestParams) {
                     // Forward the query string without the 'payload', and put all the parameters in the body.
                     $query = $request->query->all();
                     if (isset($query['payload'])) {
                         unset($query['payload']);
                     }
                     $subRequest = $request->duplicate([], $requestParams);
                     // Also force-make it a POST request, so it can contain a body.
                     $subRequest->setMethod('POST');
                     $subRequest->attributes->set('stream', $stream ? $this->createStreamer($i) : $this->noop);
                     /* @var PromiseInterface $promise */
                     $promises[] = $promise = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true, false);
                     if ($stream) {
                         $streamer = $this->createStreamer($i);
                         $promise->then(function (Response $response) use($streamer) {
                             $streamer($response->getContent(), true);
                         });
                     }
                 }
                 $responses = \GuzzleHttp\Promise\all($promises)->wait();
                 if (!$stream) {
                     echo '[';
                     for (reset($responses); $response = current($responses); next($responses)) {
                         echo $response->getContent();
                         if (current($responses)) {
                             echo ',';
                         }
                     }
                     echo ']';
                 }
             }, 200, $headers);
         });
     } else {
         $event->setController(function () use($request, $headers) {
             return new StreamedResponse(function () use($request) {
                 $request->attributes->set('stream', $this->createStreamer());
                 // We duplicate the request because the profiler component's token keeps a reference to the parent request's token,
                 // creating an infinite loop when attempting to display profiler info.
                 $response = $this->httpKernel->handle($request->duplicate(), HttpKernelInterface::SUB_REQUEST, true, true);
                 // The streamer outputs a new line as the ending delimiter. In single action calls, the ending line should be
                 // the actual response without a new line at the end. That's why streaming single calls have a resulting
                 // response, but bulk calls don't have one.
                 echo $response->getContent();
             }, 200, $headers);
         });
     }
 }
开发者ID:Briareos,项目名称:Undine,代码行数:76,代码来源:ApiListener.php


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