Skip to content
Permalink
Browse files

Rename View::addHelper() to View::loadHelper().

  • Loading branch information...
ADmad committed Sep 17, 2014
1 parent a7b44e5 commit 333ffccd2dab907aae045aa0a14f82eda1a040d4
@@ -145,7 +145,7 @@ public function __call($method, $params) {
public function __get($name) {
if (isset($this->_helperMap[$name]) && !isset($this->{$name})) {
$config = ['enabled' => false] + (array)$this->_helperMap[$name]['config'];
$this->{$name} = $this->_View->addHelper($this->_helperMap[$name]['class'], $config);
$this->{$name} = $this->_View->loadHelper($this->_helperMap[$name]['class'], $config);
}
if (isset($this->{$name})) {
return $this->{$name};
@@ -672,7 +672,7 @@ public function loadHelpers() {
$registry = $this->helpers();
$helpers = $registry->normalizeArray($this->helpers);
foreach ($helpers as $properties) {
$this->addHelper($properties['class'], $properties['config']);
$this->loadHelper($properties['class'], $properties['config']);
}
}
@@ -752,6 +752,22 @@ public function helpers() {
return $this->_helpers;
}
/**
* Alias for loadHelper() for backwards compatibility.
*
* @param string $helperName Name of the helper to load.
* @param array $config Settings for the helper
* @return Helper a constructed helper object.
* @deprecated 3.0.0 Use loadHelper() instead.
*/
public function addHelper($helperName, array $config = []) {
trigger_error(
'addHelper() is deprecated, use loadHelper() instead.',
E_USER_DEPRECATED
);
return $this->loadHelper($helperName, $config);
}
/**
* Loads a helper. Delegates to the `HelperRegistry::load()` to load the helper
*
@@ -760,7 +776,7 @@ public function helpers() {
* @return Helper a constructed helper object.
* @see HelperRegistry::load()
*/
public function addHelper($helperName, array $config = []) {
public function loadHelper($helperName, array $config = []) {
list(, $class) = pluginSplit($helperName);
return $this->{$class} = $this->helpers()->load($helperName, $config);
}
@@ -906,14 +906,14 @@ public function testViewEvent() {
}
/**
* Test loading helper using addHelper().
* Test loading helper using loadHelper().
*
* @return void
*/
public function testAddHelper() {
public function testLoadHelper() {
$View = new View();
$View->addHelper('Html', ['foo' => 'bar']);
$View->loadHelper('Html', ['foo' => 'bar']);
$this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $View->Html);
$config = $View->Html->config();
@@ -1,5 +1,5 @@
<?php
$this->addHelper('Html');
$this->loadHelper('Html');
$cakeDescription = 'CakePHP: the rapid development php framework';
?>

0 comments on commit 333ffcc

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