mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Refactored last commit changes are:
To override plugin views with a themed version of the view you would create: <app_name>/views/themed/<theme_name>/plugins/<plugin_name>/<controller_name>/*.ctp To override plugin views at the app view level you would create: <app_name>/views/plugins/<plugin_name>/<controller_name>/*.ctp
This commit is contained in:
parent
21eb001a96
commit
948f6b21e5
5 changed files with 6 additions and 5 deletions
|
@ -59,9 +59,10 @@ class ThemeView extends View {
|
||||||
&& strpos($paths[$i], DS . 'libs' . DS . 'view') === false
|
&& strpos($paths[$i], DS . 'libs' . DS . 'view') === false
|
||||||
&& strpos($paths[$i], DS . $plugin . DS) === false) {
|
&& strpos($paths[$i], DS . $plugin . DS) === false) {
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS . $plugin . DS;
|
$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS . 'plugins' . DS . $plugin . DS;
|
||||||
|
} else {
|
||||||
|
$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS;
|
||||||
}
|
}
|
||||||
$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$paths = array_merge($themePaths, $paths);
|
$paths = array_merge($themePaths, $paths);
|
||||||
|
|
|
@ -939,7 +939,7 @@ class View extends Object {
|
||||||
$count = count($viewPaths);
|
$count = count($viewPaths);
|
||||||
for ($i = 0; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
if (!isset($corePaths[$viewPaths[$i]])) {
|
if (!isset($corePaths[$viewPaths[$i]])) {
|
||||||
$paths[] = $viewPaths[$i] . $plugin . DS;
|
$paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$paths[] = App::pluginPath($plugin) . 'views' . DS;
|
$paths[] = App::pluginPath($plugin) . 'views' . DS;
|
||||||
|
|
|
@ -207,11 +207,11 @@ class ThemeViewTest extends CakeTestCase {
|
||||||
$this->Controller->theme = 'test_theme';
|
$this->Controller->theme = 'test_theme';
|
||||||
|
|
||||||
$ThemeView = new TestThemeView($this->Controller);
|
$ThemeView = new TestThemeView($this->Controller);
|
||||||
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp';
|
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp';
|
||||||
$result = $ThemeView->getViewFileName('index');
|
$result = $ThemeView->getViewFileName('index');
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'test_plugin' . DS . 'layouts' . DS .'default.ctp';
|
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'layouts' . DS .'default.ctp';
|
||||||
$result = $ThemeView->getLayoutFileName();
|
$result = $ThemeView->getLayoutFileName();
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue