Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #305 from majna/2.0-prefixed-actions

Make View task use prefixed template before falling back to generic one
  • Loading branch information...
commit bab613652ae9e2f3d0d31c57eab6a7620a48eb79 2 parents 6fd69b0 + 57afa18
José Lorenzo Rodríguez lorenzo authored
4 lib/Cake/Console/Command/Task/ViewTask.php
View
@@ -393,6 +393,10 @@ public function getTemplate($action) {
if (!empty($this->template) && $action != $this->template) {
return $this->template;
}
+ $themePath = $this->Template->getThemePath();
+ if (file_exists($themePath . 'views' . DS . $action . '.ctp')) {
+ return $action;
+ }
$template = $action;
$prefixes = Configure::read('Routing.prefixes');
foreach ((array)$prefixes as $prefix) {
13 lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php
View
@@ -230,6 +230,7 @@ public function setUp() {
$this->Task->path = TMP;
$this->Task->Template->params['theme'] = 'default';
+ $this->Task->Template->templatePaths = array('default' => CAKE . 'Console' . DS . 'Templates' . DS . 'default' .DS);
}
/**
@@ -563,7 +564,7 @@ public function testExecuteWithControllerVariations($name) {
}
/**
- * test `cake bake view $controller -admin`
+ * test `cake bake view $controller --admin`
* Which only bakes admin methods, not non-admin methods.
*
* @return void
@@ -701,7 +702,7 @@ public function testExecuteInteractiveWithAdmin() {
}
/**
- * test getting templates, make sure noTemplateActions works
+ * test getting templates, make sure noTemplateActions works and prefixed template is used before generic one.
*
* @return void
*/
@@ -716,6 +717,14 @@ public function testGetTemplate() {
$result = $this->Task->getTemplate('admin_add');
$this->assertEqual($result, 'form');
+
+ $this->Task->Template->templatePaths = array(
+ 'test' => CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Templates' . DS . 'test' .DS
+ );
+ $this->Task->Template->params['theme'] = 'test';
+
+ $result = $this->Task->getTemplate('admin_edit');
+ $this->assertEqual($result, 'admin_edit');
}
}
1  lib/Cake/Test/test_app/Console/Templates/test/views/admin_edit.ctp
View
@@ -0,0 +1 @@
+admin_edit template
Please sign in to comment.
Something went wrong with that request. Please try again.