Skip to content
Permalink
Browse files

Fixing interactions with Routing.prefixes in Controller and View task.

  • Loading branch information...
markstory committed Oct 7, 2009
1 parent 1110f3e commit 4b862de085162e602827061c4b7149172f09efb4
@@ -88,15 +88,15 @@ function execute() {
} elseif (!empty($this->args[1]) && $this->args[1] == 'admin') {
$admin = $this->Project->getPrefix();
if ($admin) {
$this->out('Adding ' . Configure::read('Routing.admin') .' methods');
$actions= $this->bakeActions($controller, $admin);
$this->out(sprintf(__('Adding %s methods', true), $admin));
$actions = $this->bakeActions($controller, $admin);
}
}
if (!empty($this->args[2]) && $this->args[2] == 'admin') {
$admin = $this->Project->getPrefix();
if ($admin) {
$this->out('Adding ' . Configure::read('Routing.admin') .' methods');
$this->out(sprintf(__('Adding %s methods', true), $admin));
$actions .= "\n" . $this->bakeActions($controller, $admin);
}
}
@@ -156,13 +156,13 @@ function _methodsToBake() {
$scaffoldActions = true;
$methods = $this->scaffoldActions;
}
$adminRoute = Configure::read('Routing.admin');
$adminRoute = $this->Project->getPrefix();
foreach ($methods as $i => $method) {
if ($adminRoute && isset($this->params['admin'])) {
if ($scaffoldActions) {
$methods[$i] = $adminRoute . '_' . $method;
$methods[$i] = $adminRoute . $method;
continue;
} elseif (strpos($method, $adminRoute . '_') === false) {
} elseif (strpos($method, $adminRoute) === false) {
unset($methods[$i]);
}
}
@@ -403,9 +403,11 @@ function getTemplate($action) {
return $this->template;
}
$template = $action;
$adminRoute = Configure::read('Routing.admin');
if (!empty($adminRoute) && strpos($template, $adminRoute) !== false) {
$template = str_replace($adminRoute . '_', '', $template);
$prefixes = Configure::read('Routing.prefixes');
foreach ((array)$prefixes as $prefix) {
if (strpos($template, $prefix) !== false) {
$template = str_replace($prefix . '_', '', $template);
}
}
if (in_array($template, array('add', 'edit'))) {
$template = 'form';
@@ -181,8 +181,8 @@ function testGetContent() {
* @return void
**/
function testGetContentWithAdminAction() {
$_back = Configure::read('Routing.admin');
Configure::write('Routing.admin', 'admin');
$_back = Configure::read('Routing');
Configure::write('Routing.prefixes', array('admin'));
$vars = array(
'modelClass' => 'TestViewModel',
'schema' => array(),
@@ -206,7 +206,7 @@ function testGetContentWithAdminAction() {
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'name\'\]/', $result);
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'body\'\]/', $result);
Configure::write('Routing.admin', $_back);
Configure::write('Routing', $_back);
}
/**
@@ -347,10 +347,11 @@ function testExecuteWithController() {
* @return void
**/
function testExecuteWithControllerAndAdminFlag() {
$_back = Configure::read('Routing.admin');
Configure::write('Routing.admin', 'admin');
$_back = Configure::read('Routing');
Configure::write('Routing.prefixes', array('admin'));
$this->Task->args[0] = 'ViewTaskArticles';
$this->Task->params['admin'] = 1;
$this->Task->Project->setReturnValue('getPrefix', 'admin_');
$this->Task->expectCallCount('createFile', 4);
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_articles' . DS . 'admin_index.ctp', '*'));
@@ -359,7 +360,7 @@ function testExecuteWithControllerAndAdminFlag() {
$this->Task->expectAt(3, 'createFile', array(TMP . 'view_task_articles' . DS . 'admin_edit.ctp', '*'));
$this->Task->execute();
Configure::write('Routing.admin', $_back);
Configure::write('Routing', $_back);
}
/**
@@ -423,7 +424,7 @@ function testExecuteWithAlternateTemplates() {
* @return void
**/
function testExecuteInteractiveWithAdmin() {
Configure::write('Routing.admin', 'admin');
Configure::write('Routing.prefixes', array('admin'));
$this->Task->connection = 'test_suite';
$this->Task->args = array();

0 comments on commit 4b862de

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