示例#1
0
 /**
  * Parses a string URL into an array. If a plugin key is found, it will be copied to the
  * controller parameter
  *
  * @param string $url The URL to parse
  * @return mixed false on failure, or an array of request parameters
  */
 public function parse($url)
 {
     $params = parent::parse($url);
     if (!$params) {
         return false;
     }
     $params['controller'] = $params['plugin'];
     return $params;
 }
示例#2
0
 /**
  * @return void
  */
 public function testMatchThenParse()
 {
     $route = new InflectedRoute('/plugin/:controller/:action', ['plugin' => 'Vendor/PluginName']);
     $url = $route->match(['plugin' => 'Vendor/PluginName', 'controller' => 'ControllerName', 'action' => 'action_name']);
     $expectedUrl = '/plugin/controller_name/action_name';
     $this->assertEquals($expectedUrl, $url);
     $result = $route->parse($expectedUrl);
     $this->assertEquals('ControllerName', $result['controller']);
     $this->assertEquals('action_name', $result['action']);
     $this->assertEquals('Vendor/PluginName', $result['plugin']);
 }