diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php
index 3490c7169..04102c4d9 100644
--- a/cake/libs/controller/scaffold.php
+++ b/cake/libs/controller/scaffold.php
@@ -434,10 +434,7 @@ class Scaffold extends Object {
/**
* When methods are now present in a controller
* scaffoldView is used to call default Scaffold methods if:
- *
- * var $scaffold;
- *
- * is placed in the controller's class definition.
+ * `var $scaffold;` is placed in the controller's class definition.
*
* @param array $params Parameters for scaffolding
* @return mixed A rendered view of scaffold action, or showing the error
@@ -445,23 +442,30 @@ class Scaffold extends Object {
*/
function __scaffold($params) {
$db = &ConnectionManager::getDataSource($this->ScaffoldModel->useDbConfig);
- $admin = Configure::read('Routing.admin');
-
+ $prefixes = Configure::read('Routing.prefixes');
+ $scaffoldPrefix = $this->scaffoldActions;
+
if (isset($db)) {
if (empty($this->scaffoldActions)) {
$this->scaffoldActions = array(
'index', 'list', 'view', 'add', 'create', 'edit', 'update', 'delete'
);
- } elseif (!empty($admin) && $this->scaffoldActions === $admin) {
+ } elseif (!empty($prefixes) && in_array($this->scaffoldActions, $prefixes)) {
$this->scaffoldActions = array(
- $admin .'_index', $admin .'_list', $admin .'_view', $admin .'_add',
- $admin .'_create', $admin .'_edit', $admin .'_update', $admin .'_delete'
+ $scaffoldPrefix . '_index',
+ $scaffoldPrefix . '_list',
+ $scaffoldPrefix . '_view',
+ $scaffoldPrefix . '_add',
+ $scaffoldPrefix . '_create',
+ $scaffoldPrefix . '_edit',
+ $scaffoldPrefix . '_update',
+ $scaffoldPrefix . '_delete'
);
}
if (in_array($params['action'], $this->scaffoldActions)) {
- if (!empty($admin)) {
- $params['action'] = str_replace($admin . '_', '', $params['action']);
+ if (!empty($prefixes)) {
+ $params['action'] = str_replace($scaffoldPrefix . '_', '', $params['action']);
}
switch ($params['action']) {
case 'index':
@@ -556,10 +560,15 @@ class ScaffoldView extends ThemeView {
$name = $this->action;
}
$name = Inflector::underscore($name);
- $admin = Configure::read('Routing.admin');
+ $prefixes = Configure::read('Routing.prefixes');
- if (!empty($admin) && strpos($name, $admin . '_') !== false) {
- $name = substr($name, strlen($admin) + 1);
+ if (!empty($prefixes)) {
+ foreach ($prefixes as $prefix) {
+ if (strpos($name, $prefix . '_') !== false) {
+ $name = substr($name, strlen($prefix) + 1);
+ break;
+ }
+ }
}
if ($name === 'add') {
diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php
index 3d6f5f64b..c0a4a0fcd 100644
--- a/cake/tests/cases/libs/controller/scaffold.test.php
+++ b/cake/tests/cases/libs/controller/scaffold.test.php
@@ -315,8 +315,8 @@ class ScaffoldViewTest extends CakeTestCase {
* @return void
*/
function testGetViewFilename() {
- $_admin = Configure::read('Routing.admin');
- Configure::write('Routing.admin', 'admin');
+ $_admin = Configure::read('Routing.prefixes');
+ Configure::write('Routing.prefixes', array('admin'));
$this->Controller->action = 'index';
$ScaffoldView =& new TestScaffoldView($this->Controller);
@@ -385,7 +385,7 @@ class ScaffoldViewTest extends CakeTestCase {
. DS .'test_plugin' . DS . 'views' . DS . 'tests' . DS . 'scaffold.edit.ctp';
$this->assertEqual($result, $expected);
- Configure::write('Routing.admin', $_admin);
+ Configure::write('Routing.prefixes', $_admin);
}
/**
@@ -499,7 +499,7 @@ class ScaffoldViewTest extends CakeTestCase {
new Scaffold($this->Controller, $params);
$result = ob_get_clean();
- $this->assertPattern('/