public function mergeUserTypeConfig($config = array(), $component = '') { $userTypes =& Module::getInstance()->userTypes; if (isset($userTypes->{$component})) { if (!empty($config)) { $userTypes->{$component} = ArrayHelper::merge($config, $userTypes->{$component}); } else { $config = $userTypes->{$component}; } } return $config; }
/** * Generates an action button * * @param string $key the button identification key * @param array $params the parameters to pass to the button action. * @param array $config the button configuration options to override. You can additionally set the `label` or * `icon` here. * * @return string */ public function button($key, $params = [], $config = []) { $m = Module::getInstance(); $btn = ArrayHelper::getValue($this->buttons, $key, []); if (empty($btn)) { return ''; } $labelNew = ArrayHelper::remove($config, 'label', ''); $iconNew = ArrayHelper::remove($config, 'icon', ''); $label = $icon = $action = $type = ''; $options = []; $iconOptions = ['style' => 'margin-right:5px']; extract($btn); if (!empty($iconNew)) { $icon = $iconNew; } if (!empty($icon)) { Html::addCssClass($iconOptions, explode(' ', $m->icons->prefix . $icon)); $icon = Html::tag('i', '', $iconOptions); } if (!empty($labelNew)) { $label = $labelNew; } $label = $icon . $label; $options = array_replace_recursive($options, $config); if (!empty($options['disabled'])) { $action = null; } if (!empty($action)) { $action = ArrayHelper::getValue($m->actions, $action, $action); $action = Url::to([$action] + $params); return Html::a($label, $action, $options); } if (!empty($type) && $type === 'submit' || $type === 'reset') { $type .= 'Button'; } else { $type = 'button'; } return Html::$type($label, $options); }