Ejemplo n.º 1
0
 /**
  * Get a command by name
  *
  * @param string The command name
  * @param array  An optional associative array of configuration settings
  *
  * @see LibBaseTemplateObject
  *
  * @return LibBaseTemplateObject Return a template object
  */
 public function getCommand($name, $config = array())
 {
     if (!isset($this->_commands[$name])) {
         if (!is_array($config)) {
             $config = array('label' => $config);
         }
         //Create the config object
         $command = ComBaseControllerToolbarCommand::getInstance($name, $config);
         //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->attribs->href)) {
                 $command->append(array('attribs' => array('data-action' => $command->getName())));
             }
         }
     } else {
         $command = $this->_commands[$name];
     }
     return $command;
 }