mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Make View task use prefixed template before falling back to generic one. It is possible now to create view templates for different prefixes.
This commit is contained in:
parent
6fd69b022d
commit
57afa1873e
3 changed files with 16 additions and 2 deletions
|
@ -393,6 +393,10 @@ class ViewTask extends BakeTask {
|
|||
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) {
|
||||
|
|
|
@ -230,6 +230,7 @@ class ViewTaskTest extends CakeTestCase {
|
|||
|
||||
$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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
|
||||
$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');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
admin_edit template
|
Loading…
Reference in a new issue