Skip to content
Permalink
Browse files

Fix loading of controller with nested prefix.

  • Loading branch information...
ADmad authored and markstory committed Jan 30, 2016
1 parent 954c6fd commit ce29d385604e6e40d3a06df91c41dfbdeb7b247b
@@ -69,7 +69,7 @@ protected function _getController($request, $response)
$controller = $request->params['controller'];
}
if (!empty($request->params['prefix'])) {
if (strpos('/', $request->params['prefix']) === false) {
if (strpos($request->params['prefix'], '/') === false) {
$namespace .= '/' . Inflector::camelize($request->params['prefix']);
} else {
$prefixes = array_map(
@@ -48,5 +48,14 @@ public function testBeforeDispatch()
'TestApp\Controller\Admin\PostsController',
get_class($event->data['controller'])
);
$request->addParams(['prefix' => 'admin/sub', 'controller' => 'Posts', 'action' => 'index']);
$event = new Event(__CLASS__, $this, compact('request', 'response'));
$filter->beforeDispatch($event);
$this->assertEquals(
'TestApp\Controller\Admin\Sub\PostsController',
get_class($event->data['controller'])
);
}
}
@@ -0,0 +1,43 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 3.2.1
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace TestApp\Controller\Admin\Sub;
use Cake\Controller\Controller;
/**
* Posts Controller class.
*
* For testing nested prefix routing / controller loading.
*/
class PostsController extends Controller
{
/**
* index action
*
* @return void
*/
public function index()
{
}
/**
* index action
*
* @return void
*/
public function add()
{
}
}

0 comments on commit ce29d38

Please sign in to comment.
You can’t perform that action at this time.