/** * Creates a button * @param $params * @param Cell $cell * @return string */ public static function button($params, Cell $cell) { //Type $type = array_key_exists('type', $params) ? $params['type'] : 'default'; //Default href if (!array_key_exists('href', $params)) { $params['href'] = '#'; } //Default class if (!array_key_exists('class', $params)) { $params['class'] = 'btn btn-' . $type . (array_key_exists('size', $params) ? ' btn-' . $params['size'] : '') . (isset($dropdown) && $dropdown ? ' dropdown-toggle' : '') . (isset($class) ? ' ' . $class : ''); } //Default data-toggle if (array_key_exists('dropdown', $params)) { $params['data_toggle'] = 'dropdown'; } //Button caption $cell->setCurrentValue(array_key_exists('caption', $params) ? $params['caption'] : ''); //Icon if (array_key_exists('icon', $params)) { if (is_array($params['icon'])) { list($iconType, $iconParam) = $params['icon']; $cell->setCurrentValue(self::$iconType($iconParam, $cell)); } else { $cell->setCurrentValue(self::glyphicon($params['icon'], $cell)); } } //Remove remaining params foreach ($params as $key => $value) { if (!preg_match("/^(href|class|data_)/i", $key)) { unset($params[$key]); } } return self::link($params, $cell); }
/** * Apply conversion methods * * @param array $methods * @param $row * @param Cell $cell */ protected function apply(array $methods, $row, Cell $cell) { foreach ($methods as $method => $params) { if (is_numeric($method)) { $method = $params; } $cell->setCurrentValue(method_exists($this, $method) ? $this->{$method}($this->wildcards($params, $row), $cell) : CustomizeCell::$method($this->wildcards($params, $row), $cell)); } }