Deprecating addScript() its replaced by blocks feature.

Adding View::blocks() for getting the list of blocks.
This commit is contained in:
Mark Story 2011-08-16 21:23:09 -04:00 committed by mark_story
parent 9107913c07
commit bd4ee41e24
2 changed files with 24 additions and 1 deletions

View file

@ -1013,4 +1013,16 @@ class ViewTest extends CakeTestCase {
public function testBlockAppendArrayException() {
$this->View->append('test', array(1, 2, 3));
}
/**
* Test getting block names
*
* @return void
*/
public function testBlocks() {
$this->View->append('test', 'one');
$this->View->setBlock('test1', 'one');
$this->assertEquals(array('test', 'test1'), $this->View->blocks());
}
}

View file

@ -502,6 +502,15 @@ class View extends Object {
return $this->viewVars[$var];
}
/**
* Get the names of all the existing blocks.
*
* @return array An array containing the blocks.
*/
public function blocks() {
return array_keys($this->_blocks);
}
/**
* Start capturing output for a 'block'
*
@ -509,7 +518,7 @@ class View extends Object {
* view files can implement some or all of a layout's slots.
*
* You can end capturing blocks using View::end(). Blocks can be output
* using View::output();
* using View::get();
*
* @param string $name The name of the block to capture for.
* @return void
@ -583,6 +592,8 @@ class View extends Object {
* update/replace a script element.
* @param string $content The content of the script being added, optional.
* @return void
* @deprecated Will be removed in 3.0. Supersceeded by blocks functionality.
* @see View::start()
*/
public function addScript($name, $content = null) {
if (empty($content)) {