Added ability to set default view block content

This commit is contained in:
Tigran Gabrielyan 2012-09-13 12:42:15 -07:00
parent 07c5102de5
commit 6d98069f13
2 changed files with 6 additions and 6 deletions

View file

@ -636,11 +636,11 @@ class View extends Object {
* empty or undefined '' will be returned.
*
* @param string $name Name of the block
* @return The block content or '' if the block does not exist.
* @return string The block content or $default if the block does not exist.
* @see ViewBlock::get()
*/
public function fetch($name) {
return $this->Blocks->get($name);
public function fetch($name, $default = '') {
return $this->Blocks->get($name, $default);
}
/**

View file

@ -119,11 +119,11 @@ class ViewBlock {
* Get the content for a block.
*
* @param string $name Name of the block
* @return The block content or '' if the block does not exist.
* @return string The block content or $default if the block does not exist.
*/
public function get($name) {
public function get($name, $default = '') {
if (!isset($this->_blocks[$name])) {
return '';
return $default;
}
return $this->_blocks[$name];
}