Permalink
Browse files

Deprecating addScript() its replaced by blocks feature.

Adding View::blocks() for getting the list of blocks.
  • Loading branch information...
markstory committed Aug 17, 2011
1 parent 9107913 commit bd4ee41e249da010654443aaca7e9fe122398d1c
Showing with 24 additions and 1 deletion.
  1. +12 −0 lib/Cake/Test/Case/View/ViewTest.php
  2. +12 −1 lib/Cake/View/View.php
@@ -1013,4 +1013,16 @@ public function testBlockSetArrayException() {
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
@@ -502,14 +502,23 @@ public function get($var) {
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'
*
* Blocks allow you to create slots or blocks of dynamic content in the layout.
* 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 @@ public function end() {
* 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)) {

0 comments on commit bd4ee41

Please sign in to comment.