Beispiel #1
0
 /**
  * Add command as last in the list of callbacks
  *
  * @param Mage_Backend_Model_Menu_Builder_CommandAbstract $command
  * @return Mage_Backend_Model_Menu_Builder_CommandAbstract
  * @throws InvalidArgumentException
  */
 public function chain(Mage_Backend_Model_Menu_Builder_CommandAbstract $command)
 {
     if ($command instanceof Mage_Backend_Model_Menu_Builder_Command_Add) {
         throw new InvalidArgumentException("Two 'add' commands cannot have equal id (" . $command->getId() . ")");
     }
     return parent::chain($command);
 }
Beispiel #2
0
 /**
  * Process provided command object
  *
  * @param Mage_Backend_Model_Menu_Builder_CommandAbstract $command
  * @return Mage_Backend_Model_Menu_Builder
  */
 public function processCommand(Mage_Backend_Model_Menu_Builder_CommandAbstract $command)
 {
     if (!isset($this->_commands[$command->getId()])) {
         $this->_commands[$command->getId()] = $command;
     } else {
         $this->_commands[$command->getId()]->chain($command);
     }
     return $this;
 }
 public function testExecuteCallsNextCommandInChain()
 {
     $itemParams = array();
     $this->_model->expects($this->once())->method('_execute')->with($this->equalTo($itemParams))->will($this->returnValue($itemParams));
     $command1 = $this->getMock('Mage_Backend_Model_Menu_Builder_Command_Update', array(), array(array('id' => 1)));
     $command1->expects($this->once())->method('execute')->with($this->equalTo($itemParams))->will($this->returnValue($itemParams));
     $this->_model->chain($command1);
     $this->assertEquals($itemParams, $this->_model->execute($itemParams));
 }
Beispiel #4
0
 /**
  * Execute command and pass control to chained commands
  *
  * @param array $itemParams
  * @return array
  */
 public function execute(array $itemParams = array())
 {
     $itemParams = $this->_execute($itemParams);
     if (!is_null($this->_next)) {
         $itemParams = $this->_next->execute($itemParams);
     }
     return $itemParams;
 }