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


PHP Request::isMethodSafe方法代码示例

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


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

示例1: itemAction

    /**
     * @Tag(expression="'item-'~id")
     */
    public function itemAction(Request $request, $id)
    {
        if (!$request->isMethodSafe()) {
            $this->container->get('fos_http_cache.cache_manager')->invalidateTags(array('all-items'));
        }

        return new Response('Item ' . $id . ' invalidated');
    }
开发者ID:ataxel,项目名称:tp,代码行数:11,代码来源:TagController.php

示例2: setIntent

 /**
  * @param Request $request
  * @param bool $override
  */
 public function setIntent(Request $request, $override = false)
 {
     if ($request->hasSession() && $request->isMethodSafe() && !$request->isXmlHttpRequest()) {
         if ($override || false === $this->hasIntent($request)) {
             $request->getSession()->set(self::SESSION_INTENT_KEY, $request->getUri());
         }
     }
 }
开发者ID:redelivre,项目名称:login-cidadao,代码行数:12,代码来源:IntentManager.php

示例3: setTargetPath

 protected function setTargetPath(Request $request)
 {
     if ($request->isXmlHttpRequest()) {
         return;
     }
     if ($request->hasSession() && ($request->isMethodSafe() || $request->get('_route') == 'engishop_front_cart_add')) {
         $request->getSession()->set('_security.' . $this->providerKey . '.target_path', $request->getUri());
     }
 }
开发者ID:khelle,项目名称:EngiShop,代码行数:9,代码来源:ExceptionListener.php

示例4: loginAction

 public function loginAction(Request $request)
 {
     if (!$this->hasRole('ROLE_USER')) {
         if ($request->hasSession() && $request->isMethodSafe()) {
             $referer = $request->headers->get('referer');
             if (null !== $referer) {
                 $request->getSession()->set('ddr.gitki.manuallogin.targetpath', $referer);
             }
         }
         throw new AuthenticationException();
     }
     if ($request->hasSession() && $request->isMethodSafe()) {
         $targetPath = $request->getSession()->get('ddr.gitki.manuallogin.targetpath');
         $request->getSession()->remove('ddr.gitki.manuallogin.targetpath');
         if (null !== $targetPath) {
             return $this->redirect($targetPath);
         }
     }
     return $this->redirect($this->generateUrl('ddr_gitki_wiki_file', array('path' => '/index.md')));
 }
开发者ID:terretta,项目名称:gitki.php,代码行数:20,代码来源:DefaultController.php

示例5: handle

 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     // Forbid direct AUTHENTICATE requests to get user hash
     if ($request->headers->get('X-HTTP-Override') === 'AUTHENTICATE' && $request->headers->get('Accept') === Kernel::USER_HASH_ACCEPT_HEADER) {
         return new Response('', 405);
     }
     if ($request->isMethodSafe()) {
         $request->headers->set('X-User-Hash', $this->kernel->generateUserHash($request));
     }
     return parent::handle($request, $type, $catch);
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:11,代码来源:HttpCache.php

示例6: validateRequest

 protected function validateRequest(Request $request)
 {
     // is the Request safe?
     if (!$request->isMethodSafe()) {
         throw new AccessDeniedHttpException();
     }
     // is the Request signed?
     // we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering)
     if ($this->signer->check($request->getSchemeAndHttpHost() . $request->getBaseUrl() . $request->getPathInfo() . (null !== ($qs = $request->server->get('QUERY_STRING')) ? '?' . $qs : ''))) {
         return;
     }
     throw new AccessDeniedHttpException();
 }
开发者ID:RuntyCybin,项目名称:csymfony,代码行数:13,代码来源:FragmentListener.php

示例7: getContext

 /**
  * Gets the base Twig context.
  *
  * @param Request $request
  *
  * @return array
  */
 private function getContext(Request $request) : array
 {
     $context = ['title' => $this->title, 'description' => $this->description, 'formats' => $this->formats, 'shortName' => null, 'operationId' => null];
     if (!$request->isMethodSafe() || null === ($resourceClass = $request->attributes->get('_api_resource_class'))) {
         return $context;
     }
     $metadata = $this->resourceMetadataFactory->create($resourceClass);
     $context['shortName'] = $metadata->getShortName();
     if (null !== ($collectionOperationName = $request->attributes->get('_api_collection_operation_name'))) {
         $context['operationId'] = sprintf('%s%sCollection', $collectionOperationName, $context['shortName']);
     } elseif (null !== ($itemOperationName = $request->attributes->get('_api_item_operation_name'))) {
         $context['operationId'] = sprintf('%s%sItem', $itemOperationName, $context['shortName']);
     }
     return $context;
 }
开发者ID:soyuka,项目名称:core,代码行数:22,代码来源:SwaggerUiAction.php

示例8: validateRequest

 protected function validateRequest(Request $request)
 {
     // is the Request safe?
     if (!$request->isMethodSafe()) {
         throw new AccessDeniedHttpException();
     }
     // does the Request come from a trusted IP?
     $trustedIps = array_merge($this->getLocalIpAddresses(), $request->getTrustedProxies());
     $remoteAddress = $request->server->get('REMOTE_ADDR');
     if (IpUtils::checkIp($remoteAddress, $trustedIps)) {
         return;
     }
     // is the Request signed?
     // we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering)
     if ($this->signer->check($request->getSchemeAndHttpHost() . $request->getBaseUrl() . $request->getPathInfo() . (null !== ($qs = $request->server->get('QUERY_STRING')) ? '?' . $qs : ''))) {
         return;
     }
     throw new AccessDeniedHttpException();
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:19,代码来源:FragmentListener.php

示例9: setTargetPath

 /**
  * @param Request $request
  */
 protected function setTargetPath(Request $request)
 {
     // session isn't required when using HTTP basic authentication mechanism for example
     if ($request->hasSession() && $request->isMethodSafe()) {
         $request->getSession()->set('_security.' . $this->providerKey . '.target_path', $request->getUri());
     }
 }
开发者ID:tahermarkos,项目名称:Transport,代码行数:10,代码来源:ExceptionListener.php

示例10: testMethodSafe

 /**
  * @dataProvider methodSafeProvider
  */
 public function testMethodSafe($method, $safe)
 {
     $request = new Request();
     $request->setMethod($method);
     $this->assertEquals($safe, $request->isMethodSafe());
 }
开发者ID:joelwurtz,项目名称:symfony,代码行数:9,代码来源:RequestTest.php

示例11: setTargetPath

 /**
  * @param Request $request
  */
 protected function setTargetPath(Request $request)
 {
     // session isn't required when using HTTP basic authentication mechanism for example
     if ($request->hasSession() && $request->isMethodSafe() && !$request->isXmlHttpRequest()) {
         $this->saveTargetPath($request->getSession(), $this->providerKey, $request->getUri());
     }
 }
开发者ID:alekitto,项目名称:symfony,代码行数:10,代码来源:ExceptionListener.php

示例12: handle

 /**
  * Handles a Request.
  *
  * @param Request $request A Request instance
  * @param integer $type    The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
  * @param Boolean $raw     Whether to catch exceptions or not (this is NOT used in this context)
  *
  * @return Symfony\Component\HttpFoundation\Response A Response instance
  */
 public function handle(Request $request = null, $type = HttpKernelInterface::MASTER_REQUEST, $raw = false)
 {
     // FIXME: catch exceptions and implement a 500 error page here? -> in Varnish, there is a built-in error page mechanism
     if (null === $request) {
         $request = new Request();
     }
     if (HttpKernelInterface::MASTER_REQUEST === $type) {
         $this->traces = array();
         $this->request = $request;
     }
     $this->traces[$request->getMethod() . ' ' . $request->getPathInfo()] = array();
     if (!$request->isMethodSafe($request)) {
         $response = $this->invalidate($request);
     } elseif ($request->headers->has('expect')) {
         $response = $this->pass($request);
     } else {
         $response = $this->lookup($request);
     }
     $response->isNotModified($request);
     if ('head' === strtolower($request->getMethod())) {
         $response->setContent('');
     } else {
         $this->restoreResponseBody($response);
     }
     if (HttpKernelInterface::MASTER_REQUEST === $type && $this->options['debug']) {
         $response->headers->set('X-Symfony-Cache', $this->getLog());
     }
     return $response;
 }
开发者ID:netixpro,项目名称:symfony,代码行数:38,代码来源:Cache.php

示例13: isRequestSafe

 /**
  * Decide whether to even look for matching rules with the current request.
  *
  * @param Request $request
  *
  * @return bool True if the request is safe and headers can be set
  */
 protected function isRequestSafe(Request $request)
 {
     return $request->isMethodSafe();
 }
开发者ID:wickedOne,项目名称:FOSHttpCacheBundle,代码行数:11,代码来源:CacheControlSubscriber.php

示例14: testMethodSafeChecksCacheable

 /**
  * @group legacy
  * @expectedDeprecation Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since version 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.
  */
 public function testMethodSafeChecksCacheable()
 {
     $request = new Request();
     $request->setMethod('OPTIONS');
     $this->assertFalse($request->isMethodSafe());
 }
开发者ID:symfony,项目名称:symfony,代码行数:10,代码来源:RequestTest.php

示例15: check

 /**
  * {@inheritdoc}
  */
 public function check(Request $request)
 {
     if ($this->isCli() || !$request->isMethodSafe()) {
         return static::DENY;
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:9,代码来源:CommandLineOrUnsafeMethod.php


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