Example #1
0
 /**
  * Reverse route plugin shortcut URLs. If the plugin and controller
  * are not the same the match is an auto fail.
  *
  * @param array $url Array of parameters to convert to a string.
  * @param array $context An array of the current request context.
  *   Contains information such as the current host, scheme, port, and base
  *   directory.
  * @return mixed either false or a string URL.
  */
 public function match(array $url, array $context = array())
 {
     if (isset($url['controller']) && isset($url['plugin']) && $url['plugin'] !== $url['controller']) {
         return false;
     }
     $this->defaults['controller'] = $url['controller'];
     $result = parent::match($url, $context);
     unset($this->defaults['controller']);
     return $result;
 }
Example #2
0
 protected function _underscore($url)
 {
     $url = parent::_underscore($url);
     if (!empty($url['controller'])) {
         $url['controller'] = str_replace('_', '-', $url['controller']);
     }
     if (!empty($url['plugin'])) {
         $url['plugin'] = str_replace('_', '-', $url['plugin']);
     }
     return $url;
 }
Example #3
0
 public function match(array $url, array $context = [])
 {
     if ($url['controller'] == 'Creators') {
         $url['controller'] = 'Users';
     }
     if ($url['controller'] == 'Modifiers') {
         $url['controller'] = 'Users';
     }
     /*
     		if($url['controller'] == 'Deleters') {
     			$url['controller'] = 'Users';
     		}
     */
     return parent::match($url, $context);
 }
Example #4
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']);
 }