mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Added ability to set default view block content
This commit is contained in:
parent
07c5102de5
commit
6d98069f13
2 changed files with 6 additions and 6 deletions
|
@ -636,11 +636,11 @@ class View extends Object {
|
||||||
* empty or undefined '' will be returned.
|
* empty or undefined '' will be returned.
|
||||||
*
|
*
|
||||||
* @param string $name Name of the 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.
|
||||||
* @see ViewBlock::get()
|
* @see ViewBlock::get()
|
||||||
*/
|
*/
|
||||||
public function fetch($name) {
|
public function fetch($name, $default = '') {
|
||||||
return $this->Blocks->get($name);
|
return $this->Blocks->get($name, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -119,11 +119,11 @@ class ViewBlock {
|
||||||
* Get the content for a block.
|
* Get the content for a block.
|
||||||
*
|
*
|
||||||
* @param string $name Name of the 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])) {
|
if (!isset($this->_blocks[$name])) {
|
||||||
return '';
|
return $default;
|
||||||
}
|
}
|
||||||
return $this->_blocks[$name];
|
return $this->_blocks[$name];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue