Skip to content
Permalink
Browse files

First attempt at lazy loading helpers done. Plugin support not complete.

  • Loading branch information...
markstory committed Jul 3, 2010
1 parent ab815a5 commit 98982a6f7a84f4e21db5e1331f695f3ee64f7ac5
Showing with 31 additions and 1 deletion.
  1. +19 −0 cake/libs/view/helper.php
  2. +12 −1 cake/tests/cases/libs/view/helper.test.php
@@ -142,6 +142,13 @@ class Helper extends Object {
*/
private $__cleaned = null;
/**
* undocumented class variable
*
* @var string
*/
public $View;
/**
* Default Constructor
*
@@ -161,6 +168,18 @@ public function __call($method, $params) {
trigger_error(sprintf(__('Method %1$s::%2$s does not exist'), get_class($this), $method), E_USER_WARNING);
}
/**
* Lazy loads helpers
*
* @return void
*/
public function __get($name) {
if (!empty($this->helpers) && in_array($name, $this->helpers)) {
$this->{$name} = $this->View->Helpers->load($name, array(), false);
return $this->{$name};
}
}
/**
* Parses tag templates into $this->tags.
*
@@ -771,7 +771,7 @@ function testWebrootPaths() {
* @return void
*/
function testParseAttributeCompact() {
$helper =& new TestHelper($this->View);
$helper = new TestHelper($this->View);
$compact = array('compact', 'checked', 'declare', 'readonly', 'disabled',
'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize');
@@ -783,4 +783,15 @@ function testParseAttributeCompact() {
}
}
}
/**
* test lazy loading helpers is seamless
*
* @return void
*/
function testLazyLoadingHelpers() {
$this->Helper->helpers = array('Test', 'Html');
$result = $this->Helper->Test;
$this->assertType('TestHelper', $result);
}
}

0 comments on commit 98982a6

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