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


PHP Route::hasScheme方法代碼示例

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


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

示例1: handleRouteRequirements

 /**
  * {@inheritdoc}
  */
 protected function handleRouteRequirements($pathinfo, $name, Route $route)
 {
     // expression condition
     if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request))) {
         return array(self::REQUIREMENT_MISMATCH, null);
     }
     // check HTTP scheme requirement
     $scheme = $this->context->getScheme();
     $schemes = $route->getSchemes();
     if ($schemes && !$route->hasScheme($scheme)) {
         return array(self::ROUTE_MATCH, $this->redirect($pathinfo, $name, current($schemes)));
     }
     return array(self::REQUIREMENT_MATCH, null);
 }
開發者ID:saj696,項目名稱:pipe,代碼行數:17,代碼來源:RedirectableUrlMatcher.php

示例2: testSchemeIsBC

 public function testSchemeIsBC()
 {
     $route = new Route('/');
     $route->setRequirement('_scheme', 'http|https');
     $this->assertEquals('http|https', $route->getRequirement('_scheme'));
     $this->assertEquals(array('http', 'https'), $route->getSchemes());
     $this->assertTrue($route->hasScheme('https'));
     $this->assertTrue($route->hasScheme('http'));
     $this->assertFalse($route->hasScheme('ftp'));
     $route->setSchemes(array('hTTp'));
     $this->assertEquals('http', $route->getRequirement('_scheme'));
     $route->setSchemes(array());
     $this->assertNull($route->getRequirement('_scheme'));
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:14,代碼來源:RouteTest.php

示例3: testScheme

 public function testScheme()
 {
     $route = new Route('/');
     $this->assertEquals(array(), $route->getSchemes(), 'schemes is initialized with array()');
     $this->assertFalse($route->hasScheme('http'));
     $route->setSchemes('hTTp');
     $this->assertEquals(array('http'), $route->getSchemes(), '->setSchemes() accepts a single scheme string and lowercases it');
     $this->assertTrue($route->hasScheme('htTp'));
     $this->assertFalse($route->hasScheme('httpS'));
     $route->setSchemes(array('HttpS', 'hTTp'));
     $this->assertEquals(array('https', 'http'), $route->getSchemes(), '->setSchemes() accepts an array of schemes and lowercases them');
     $this->assertTrue($route->hasScheme('htTp'));
     $this->assertTrue($route->hasScheme('httpS'));
 }
開發者ID:saj696,項目名稱:pipe,代碼行數:14,代碼來源:RouteTest.php

示例4: testLegacySchemeRequirement

 /**
  * @group legacy
  */
 public function testLegacySchemeRequirement()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     $route = new Route('/');
     $route->setRequirement('_scheme', 'http|https');
     $this->assertEquals('http|https', $route->getRequirement('_scheme'));
     $this->assertEquals(array('http', 'https'), $route->getSchemes());
     $this->assertTrue($route->hasScheme('https'));
     $this->assertTrue($route->hasScheme('http'));
     $this->assertFalse($route->hasScheme('ftp'));
     $route->setSchemes(array('hTTp'));
     $this->assertEquals('http', $route->getRequirement('_scheme'));
     $route->setSchemes(array());
     $this->assertNull($route->getRequirement('_scheme'));
 }
開發者ID:hilmysyarif,項目名稱:sisfito,代碼行數:18,代碼來源:RouteTest.php

示例5: handleRouteRequirements

 /**
  * Handles specific route requirements.
  *
  * @param string $pathinfo The path
  * @param string $name     The route name
  * @param Route  $route    The route
  *
  * @return array The first element represents the status, the second contains additional information
  */
 protected function handleRouteRequirements(Request $request, $pathinfo, $name, Route $route)
 {
     // expression condition
     if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request))) {
         return array(self::REQUIREMENT_MISMATCH, null);
     }
     // check HTTP scheme requirement
     $scheme = $request->getScheme();
     $status = $route->getSchemes() && !$route->hasScheme($scheme) ? self::REQUIREMENT_MISMATCH : self::REQUIREMENT_MATCH;
     return array($status, null);
 }
開發者ID:voxsim,項目名稱:minima,代碼行數:20,代碼來源:UrlMatcher.php


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