/** * Get a command by name * * @param string $name The command name * @param array $config An optional associative array of configuration settings * @return KControllerToolbarCommandInterface|boolean A toolbar command if found, false otherwise. */ public function getCommand($name, $config = array()) { if (!isset($this->_commands[$name])) { //Create the config object $command = new KControllerToolbarCommand($name, $config); //Attach the command to the toolbar $command->setToolbar($this); //Find the command function to call if (method_exists($this, '_command' . ucfirst($name))) { $function = '_command' . ucfirst($name); $this->{$function}($command); } else { //Don't set an action for GET commands if (!isset($command->href)) { $command->append(array('attribs' => array('data-action' => $command->getName()))); } } } else { $command = $this->_commands[$name]; } return $command; }
/** * Get a command by name * * @param string $name The command name * @param array $config An optional associative array of configuration settings * @return mixed ControllerToolbarCommand if found, false otherwise. */ public function getCommand($name, $config = array()) { if (!$this->getDelegate()->hasCommand($name)) { //Create the config object $command = new KControllerToolbarCommand($name, $config); //Attach the command to the toolbar $command->setToolbar($this); //Find the command function to call if (method_exists($this, '_command' . ucfirst($name))) { $function = '_command' . ucfirst($name); $this->{$function}($command); } else { $this->getDelegate()->getCommand($name, $config); } } else { $command = $this->getDelegate()->getCommand($name); } return $command; }