/** * Renders a command as a link tag. If it has a href, it will use the route to Route the link. * * @param ComBaseControllerToolbarCommand $command Command to render as a link * * @return string */ public function command($command) { $attributes = KConfig::unbox($command->getAttributes()); if (isset($attributes['icon'])) { $icon = 'icon-' . $attributes['icon']; $command->label = '<i class="' . $icon . '"></i> ' . $command->label; unset($attributes['icon']); } $html = $this->getService('com:base.template.helper.html'); return (string) $html->tag('a', $command->label, $attributes); }
/** * 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; }