Exemple #1
0
 function assign($spec, $value = null)
 {
     if (is_array($spec)) {
         $orig = $this->_container->getArrayCopy();
         $merged = array_merge($orig, $spec);
         $this->_container->exchangeArray($merged);
         return $this;
     }
     if (is_string($spec)) {
         $this->_container[$spec] = $value;
         return $this;
     }
     throw new Exception('Invalid values passed to assign()');
 }
 /**
  * @return void
  */
 public function testPrependPushesValueToTopOfContainer()
 {
     $this->container['foo'] = 'bar';
     $this->container->prepend('baz');
     $expected = array('baz', 'foo' => 'bar');
     $array = $this->container->getArrayCopy();
     $this->assertSame($expected, $array);
 }
 /**
  * Assign one or more layout variables
  * 
  * @param  mixed $spec Assoc array or string key; if assoc array, sets each
  * key as a layout variable
  * @param  mixed $value Value if $spec is a key
  * @return Zend_Layout
  * @throws Zend_Layout_Exception if non-array/string value passed to $spec
  */
 public function assign($spec, $value = null)
 {
     if (is_array($spec)) {
         $orig = $this->_container->getArrayCopy();
         $merged = array_merge($orig, $spec);
         $this->_container->exchangeArray($merged);
         return $this;
     }
     if (is_string($spec)) {
         $this->_container[$spec] = $value;
         return $this;
     }
     require_once 'Zend/Layout/Exception.php';
     throw new Zend_Layout_Exception('Invalid values passed to assign()');
 }