mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
Corrected view tests.
Added fix for Ticket #2245 Refactored loading of components and helpers to allow for use of dot notation with plugins. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4659 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
7cc6185076
commit
c20a8c80f3
4 changed files with 14 additions and 10 deletions
|
@ -353,6 +353,8 @@ class Dispatcher extends Object {
|
|||
$controller->output =& $output;
|
||||
|
||||
foreach($controller->components as $c) {
|
||||
$path = preg_split('/\/|\./', $c);
|
||||
$c = $path[count($path) - 1];
|
||||
if (isset($controller->{$c}) && is_object($controller->{$c}) && is_callable(array($controller->{$c}, 'shutdown'))) {
|
||||
if (!array_key_exists('enabled', get_object_vars($controller->{$c})) || $controller->{$c}->enabled == true) {
|
||||
$controller->{$c}->shutdown($controller);
|
||||
|
@ -385,6 +387,8 @@ class Dispatcher extends Object {
|
|||
$controller->beforeFilter();
|
||||
|
||||
foreach($controller->components as $c) {
|
||||
$path = preg_split('/\/|\./', $c);
|
||||
$c = $path[count($path) - 1];
|
||||
if (isset($controller->{$c}) && is_object($controller->{$c}) && is_callable(array($controller->{$c}, 'startup'))) {
|
||||
if (!array_key_exists('enabled', get_object_vars($controller->{$c})) || $controller->{$c}->enabled == true) {
|
||||
$controller->{$c}->startup($controller);
|
||||
|
|
|
@ -85,13 +85,13 @@ class Component extends Object {
|
|||
$components[] = 'Session';
|
||||
|
||||
foreach($components as $component) {
|
||||
$pos = strpos($component, '/');
|
||||
if ($pos === false) {
|
||||
$parts = preg_split('/\/|\./', $component);
|
||||
|
||||
if(count($parts) === 1) {
|
||||
$plugin = $this->controller->plugin;
|
||||
} else {
|
||||
$parts = explode('/', $component);
|
||||
$plugin = Inflector::underscore($parts['0']);
|
||||
$component = $parts['1'];
|
||||
$component = $parts[count($parts) - 1];
|
||||
}
|
||||
|
||||
$componentCn = $component . 'Component';
|
||||
|
|
|
@ -373,7 +373,7 @@ class View extends Object {
|
|||
* @return string Rendered output
|
||||
*/
|
||||
function renderElement($name, $params = array(), $loadHelpers = false) {
|
||||
|
||||
|
||||
if(isset($params['plugin'])) {
|
||||
$this->plugin = $params['plugin'];
|
||||
$this->pluginPath = 'plugins' . DS . $this->plugin . DS;
|
||||
|
@ -824,13 +824,13 @@ class View extends Object {
|
|||
$helpers[] = 'Session';
|
||||
|
||||
foreach($helpers as $helper) {
|
||||
$pos = strpos($helper, '/');
|
||||
if ($pos === false) {
|
||||
$parts = preg_split('/\/|\./', $helper);
|
||||
|
||||
if(count($parts) === 1) {
|
||||
$plugin = $this->plugin;
|
||||
} else {
|
||||
$parts = explode('/', $helper);
|
||||
$plugin = Inflector::underscore($parts['0']);
|
||||
$helper = $parts['1'];
|
||||
$helper = $parts[count($parts) - 1];
|
||||
}
|
||||
$helperCn = $helper . 'Helper';
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class ViewTest extends UnitTestCase {
|
|||
}
|
||||
|
||||
function testViewVars() {
|
||||
$this->assertTrue($this->view->viewVars, array('testData' => 'Some test data', 'test2' => 'more data', 'test3' => 'even more data'));
|
||||
$this->assertEqual($this->view->viewVars, array('testData' => 'Some test data', 'test2' => 'more data', 'test3' => 'even more data'));
|
||||
}
|
||||
|
||||
function testUUIDGeneration() {
|
||||
|
|
Loading…
Add table
Reference in a new issue