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


PHP HTTPRequest::match方法代码示例

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


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

示例1: testMatch

 function testMatch()
 {
     $request = new HTTPRequest("GET", "admin/crm/add");
     /* When a rule matches, but has no variables, array("_matched" => true) is returned. */
     $this->assertEquals(array("_matched" => true), $request->match('admin/crm', true));
     /* Becasue we shifted admin/crm off the stack, just "add" should be remaining */
     $this->assertEquals("add", $request->remaining());
     $this->assertEquals(array("_matched" => true), $request->match('add', true));
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:9,代码来源:HTTPRequestTest.php

示例2: handleRequest

	public function handleRequest($request) {
		self::$is_at_root = true;
		$this->pushCurrent();
		
		$this->init();

		$controller = new ModelAsController();
		
		$request = new HTTPRequest("GET", self::get_homepage_urlsegment().'/', $request->getVars(), $request->postVars());
		$request->match('$URLSegment//$Action', true);
			
		$result = $controller->handleRequest($request);

		$this->popCurrent();
		return $result;
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:16,代码来源:RootURLController.php

示例3: testFindOldPage

 public function testFindOldPage()
 {
     $page = new Page();
     $page->Title = 'Test Page';
     $page->URLSegment = 'test-page';
     $page->write();
     $page->publish('Stage', 'Live');
     $page->URLSegment = 'test';
     $page->write();
     $page->publish('Stage', 'Live');
     $router = new ModelAsController();
     $request = new HTTPRequest('GET', 'test-page/action/id/otherid');
     $request->match('$URLSegment/$Action/$ID/$OtherID');
     $response = $router->handleRequest($request);
     $this->assertEquals($response->getHeader('Location'), Controller::join_links(Director::baseURL() . 'test/action/id/otherid'));
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:16,代码来源:ModelAsControllerTest.php

示例4: handleRequest

 public function handleRequest($request)
 {
     self::$is_at_root = true;
     $this->pushCurrent();
     $this->init();
     // If the basic database hasn't been created, then build it.
     if (!DB::isActive() || !ClassInfo::hasTable('SiteTree')) {
         $this->response = new HTTPResponse();
         $this->redirect("dev/build?returnURL=");
         return $this->response;
     }
     $controller = new ModelAsController();
     $request = new HTTPRequest("GET", self::get_homepage_urlsegment() . '/', $request->getVars(), $request->postVars());
     $request->match('$URLSegment//$Action', true);
     $result = $controller->handleRequest($request);
     $this->popCurrent();
     return $result;
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:18,代码来源:RootURLController.php

示例5: handleRequest

 /**
  * Handle an HTTP request, defined with a HTTPRequest object.
  *
  * @return HTTPResponse|string
  */
 protected static function handleRequest(HTTPRequest $request, Session $session)
 {
     krsort(Director::$rules);
     if (isset($_REQUEST['debug'])) {
         Debug::show(Director::$rules);
     }
     foreach (Director::$rules as $priority => $rules) {
         foreach ($rules as $pattern => $controllerOptions) {
             if (is_string($controllerOptions)) {
                 if (substr($controllerOptions, 0, 2) == '->') {
                     $controllerOptions = array('Redirect' => substr($controllerOptions, 2));
                 } else {
                     $controllerOptions = array('Controller' => $controllerOptions);
                 }
             }
             if (($arguments = $request->match($pattern, true)) !== false) {
                 // controllerOptions provide some default arguments
                 $arguments = array_merge($controllerOptions, $arguments);
                 // Find the controller name
                 if (isset($arguments['Controller'])) {
                     $controller = $arguments['Controller'];
                 }
                 // Pop additional tokens from the tokeniser if necessary
                 if (isset($controllerOptions['_PopTokeniser'])) {
                     $request->shift($controllerOptions['_PopTokeniser']);
                 }
                 // Handle redirections
                 if (isset($arguments['Redirect'])) {
                     return "redirect:" . Director::absoluteURL($arguments['Redirect'], true);
                 } else {
                     /*
                     if(isset($arguments['Action'])) {
                     	$arguments['Action'] = str_replace('-','',$arguments['Action']);
                     }
                     
                     if(isset($arguments['Action']) && ClassInfo::exists($controller.'_'.$arguments['Action']))
                     	$controller = $controller.'_'.$arguments['Action'];
                     */
                     if (isset($arguments['URLSegment'])) {
                         self::$urlSegment = $arguments['URLSegment'] . "/";
                     }
                     Director::$urlParams = $arguments;
                     $controllerObj = new $controller();
                     $controllerObj->setSession($session);
                     return $controllerObj->handleRequest($request);
                 }
             }
         }
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:55,代码来源:Director.php


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