If the method is called with one of the standard Joomla toolbar buttons translate the label correctly

@param string $name   The command name
@param array  $config The command configuration options

@return $this
517598
public function addCommand($name, $config = array())
    {
        if (!isset($config['label']) && in_array($name, self::$_default_buttons)) {
            $config['label'] = 'JTOOLBAR_'.$name;
        }

        return parent::addCommand($name, $config);
    }
651227
public function command($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'id'      => '',
            'href'    => '',
            'icon'    => '',
            'allowed' => true,
            'disabled'=> false,
            'data'    => array(),
            'attribs' => array(
                'href'  => '#',
                'class' => array('toolbar')
            )
        ));

        $translator = $this->getObject('translator');

        if ($config->allowed === false)
        {
            $config->attribs->title = $translator->translate('You are not allowed to perform this action');
            $config->attribs->class->append(array('k-is-disabled', 'k-is-unauthorized'));
        }

        //Create the id
        $config->attribs['id'] = 'command-'.$config->id;

        $config->attribs->class->append(array('k-button', 'k-button--default', 'k-button-'.$config->id));

        if ($config->id === 'new' || $config->id === 'save') {
            $config->attribs->class->append(array('k-button--success'));
        }

        //Add the data attributes
        foreach($config->data as $key => $value) {
            $config->attribs['data-'.$key] = (string) $value;
        }

        //Create the href
        if(!empty($config->href)) {
            $config->attribs['href'] = $config->href;
        }

        $attribs = clone $config->attribs;
        $attribs->class = implode(" ", ObjectConfig::unbox($attribs->class));

        $html = '<a '.$this->buildAttributes($attribs).'>';

        $html .= '<span class="'.$config->icon.'" aria-hidden="true"></span> ';
        $html .= '<span class="k-button__text">';
        $html .= $translator->translate($config->label);
        $html .= '</span>';
        $html .= '</a>';

        return $html;
    }
527614
public function attachPort(string $name, $config): void
    {
        if (isset($this->attachedNames[strtolower($name)])) {
            throw new \InvalidArgumentException("The add listen port server [$name] has been exists!");
        }

        if (\is_array($config)) {
            $class = Arr::remove($config, 'listener');

            if (!$class) {
                throw new \InvalidArgumentException("Please setting the 'listener' class for the port server: $name");
            }

            $cb = new $class($config);

            if (!$cb instanceof PortListenerInterface) {
                throw new \InvalidArgumentException(
                    'The event handler must implement of ' . PortListenerInterface::class
                );
            }
        } elseif ($config instanceof \Closure || $config instanceof PortListenerInterface) {
            $cb = $config;

        } else {
            throw new \InvalidArgumentException('The 2th argument type only allow [array|\Closure|InterfacePortListener].');
        }

        $this->attachedNames[$name]     = true;
        $this->attachedListeners[$name] = $cb;
    }
877824
public function configureHook(Config\Hook $config, string $name) : void
    {
        $answer = $this->io->ask('  <info>Enable \'' . $name . '\' hook?</info> <comment>[y,n]</comment> ', 'n');
        $enable = IOUtil::answerToBool($answer);

        $config->setEnabled($enable);

        if ($enable) {
            $addAction = $this->io->ask('  <info>Add a validation action?</info> <comment>[y,n]</comment> ', 'n');

            while (IOUtil::answerToBool($addAction)) {
                $config->addAction($this->getActionConfig());
                // add another action?
                $addAction = $this->io->ask(
                    '  <info>Add another validation action?</info> <comment>[y,n]</comment> ',
                    'n'
                );
            }
        }
    }
912633
public static function getCriticalCssTags(array $config, $name = null): string
    {
        // Resolve the template name
        $template = Craft::$app->getView()->resolveTemplate($name ?? Twigpack::$templateName);
        if ($template) {
            $name = self::combinePaths(
                pathinfo($template, PATHINFO_DIRNAME),
                pathinfo($template, PATHINFO_FILENAME)
            );
            $dirPrefix = 'templates/';
            if (\defined('CRAFT_TEMPLATES_PATH')) {
                $dirPrefix = CRAFT_TEMPLATES_PATH;
            }
            $name = strstr($name, $dirPrefix);
            $name = str_replace($dirPrefix, '', $name);
            $path = self::combinePaths(
                $config['localFiles']['basePath'],
                $config['localFiles']['criticalPrefix'],
                $name
            ).$config['localFiles']['criticalSuffix'];

            return self::getCssInlineTags($path);
        }

        return '';
    }
408120
public function getCommand($name, $config = array())
    {
        if(!$this->getDelegate()->hasCommand($name))
        {
            //Create the config object
            $command = new ControllerToolbarCommand($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, $config);

        return $command;
    }
923280
public function addCommand($name, $config = array())
    {
        $command = parent::addCommand($name, $config);

        $controller = $this->getController();

        if($controller->isEditable() && KStringInflector::isSingular($controller->getView()->getName())) {
            $command->disabled = true;
        }

        return $this;
    }
636439
public function title($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'command' => NULL,
        ));

        $title = $this->getObject('translator')->translate($config->command->title);
        $html  = '';

        if (!empty($title))
        {
            $html = parent::title($config);

            if (JFactory::getApplication()->isAdmin())
            {
                $app = JFactory::getApplication();
                $app->JComponentTitle = $title;

                JFactory::getDocument()->setTitle($app->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION') . ' - ' . $title);
            }
        }

        return $html;
    }
666681
public function addCommand($command, $config = array())
    {
        if (!($command instanceof KControllerToolbarCommandInterface)) {
            $command = $this->getCommand($command, $config);
        }

        //Set the command parent
        $command->setParent($this);

        $this->_commands[$command->getName()] = $command;
        return $command;
    }
534912
protected function makePlugin($name, array $config)
    {
        $className = $name;
        if (strpos($className, '\\') === false) {
            $className = str_replace('/', '\\', $className) . '\\' . 'Plugin';
        }
        if (class_exists($className)) {
            return new $className($config);
        }

        if (!isset($config['path'])) {
            $config['path'] = $this->plugins->findPath($name);
        }
        $config['name'] = $name;

        return new BasePlugin($config);
    }
617276
public function with($name, array $options = [])
    {
        /*
         * The current implementation should work with the following workflow:
         *
         *     $formMapper
         *        ->with('group1')
         *            ->add('username')
         *            ->add('password')
         *        ->end()
         *        ->with('tab1', ['tab' => true])
         *            ->with('group1')
         *                ->add('username')
         *                ->add('password')
         *            ->end()
         *            ->with('group2', ['collapsed' => true])
         *                ->add('enabled')
         *                ->add('createdAt')
         *            ->end()
         *        ->end();
         *
         */
        $defaultOptions = [
            'collapsed' => false,
            'class' => false,
            'description' => false,
            'label' => $name, // NEXT_MAJOR: Remove this line and uncomment the next one
//            'label' => $this->admin->getLabelTranslatorStrategy()->getLabel($name, $this->getName(), 'group'),
            'translation_domain' => null,
            'name' => $name,
            'box_class' => 'box box-primary',
        ];

        // NEXT_MAJOR: remove this code
        if ($this->admin instanceof AbstractAdmin && $pool = $this->admin->getConfigurationPool()) {
            if ($pool->getContainer()->getParameter('sonata.admin.configuration.translate_group_label')) {
                $defaultOptions['label'] = $this->admin->getLabelTranslatorStrategy()->getLabel($name, $this->getName(), 'group');
            }
        }

        $code = $name;

        // Open
        if (\array_key_exists('tab', $options) && $options['tab']) {
            $tabs = $this->getTabs();

            if ($this->currentTab) {
                if (isset($tabs[$this->currentTab]['auto_created']) && true === $tabs[$this->currentTab]['auto_created']) {
                    throw new \RuntimeException('New tab was added automatically when you have added field or group. You should close current tab before adding new one OR add tabs before adding groups and fields.');
                }

                throw new \RuntimeException(sprintf('You should close previous tab "%s" with end() before adding new tab "%s".', $this->currentTab, $name));
            } elseif ($this->currentGroup) {
                throw new \RuntimeException(sprintf('You should open tab before adding new group "%s".', $name));
            }

            if (!isset($tabs[$name])) {
                $tabs[$name] = [];
            }

            $tabs[$code] = array_merge($defaultOptions, [
                'auto_created' => false,
                'groups' => [],
            ], $tabs[$code], $options);

            $this->currentTab = $code;
        } else {
            if ($this->currentGroup) {
                throw new \RuntimeException(sprintf('You should close previous group "%s" with end() before adding new tab "%s".', $this->currentGroup, $name));
            }

            if (!$this->currentTab) {
                // no tab define
                $this->with('default', [
                    'tab' => true,
                    'auto_created' => true,
                    'translation_domain' => $options['translation_domain'] ?? null,
                ]); // add new tab automatically
            }

            // if no tab is selected, we go the the main one named '_' ..
            if ('default' !== $this->currentTab) {
                $code = $this->currentTab.'.'.$name; // groups with the same name can be on different tabs, so we prefix them in order to make unique group name
            }

            $groups = $this->getGroups();
            if (!isset($groups[$code])) {
                $groups[$code] = [];
            }

            $groups[$code] = array_merge($defaultOptions, [
                'fields' => [],
            ], $groups[$code], $options);

            $this->currentGroup = $code;
            $this->setGroups($groups);
            $tabs = $this->getTabs();
        }

        if ($this->currentGroup && isset($tabs[$this->currentTab]) && !\in_array($this->currentGroup, $tabs[$this->currentTab]['groups'], true)) {
            $tabs[$this->currentTab]['groups'][] = $this->currentGroup;
        }

        $this->setTabs($tabs);

        return $this;
    }
1140707
protected function buildTask($name, $config)
    {
        $container = $this->container;
        $command   = new Command($name);
        $command->setApplication($container->get('application'));
        $command->setDescription($config['description']);
        $command->setCode(function (InputInterface $input, OutputInterface $output) use ($name, $config, $container) {
            $formatter = $container->get('application')->getHelperSet()->get('formatter');
            $output->writeln(
                $formatter->formatBlock(array(sprintf('Running Task "%s"', $name)), 'info')
            );
            $successful = 0;
            foreach ($config['requires'] as $task) {
                $output->writeln(
                    $formatter->formatBlock(array(sprintf('Running Required Task "%s"', $task)), 'info')
                );
                $service = $container->get(sprintf('task.'.$task));
                $code = $service->run($input, $output);
                if (0 !== $code) {
                    $successful = -1;
                }
            }

            foreach ($config['commands'] as $cmd => $cmdConfig) {
                $output->writeln(
                    $formatter->formatBlock(array(sprintf('Running Command "%s"', $cmd)), 'info')
                );
                $serviceId = sprintf('command.%s', $cmdConfig['command']);
                if (!$container->has($serviceId)) {
                    $output->writeln(
                        $formatter->formatSection(
                            '<error>ERROR</error>',
                            sprintf('Command "%s" does not exist', $cmdConfig['command'])
                        )
                    );
                    $successful = -1;
                    continue;
                }

                $serviceConfig = array('command' => $cmdConfig['command']);
                $service       = $container->get($serviceId);
                $service->setApplication($container->get('application'));

                foreach ($cmdConfig['arguments'] as $arg => $value) {
                    $serviceConfig[$arg] = $value;
                }

                foreach ($cmdConfig['options'] as $opt => $value) {
                    $serviceConfig['--'.$opt] = $value;
                }

                $code = $service->run(new ArrayInput($serviceConfig), $output);

                if (0 !== $code) {
                    $successful = -1;
                    $output->writeln(
                        $formatter->formatBlock(array(sprintf('Command "%s" failure', $cmd)), 'error')
                    );
                } else {
                    $output->writeln(
                        $formatter->formatBlock(array(sprintf('Command "%s" success', $cmd)), 'info')
                    );
                }
            }

            return $successful;
        });

        return $command;
    }
518927
public static function addConfig($name, array $config)
    {
        $nameSplit = explode('.', $name);

        $first = array_shift($nameSplit);
        if(!isset(static::$configs[$first]))
        {
            static::$configs[$first] = new ArrayData([]);
        }

        if(isset($nameSplit[0]))
        {
            $configName = implode('.', $nameSplit);
            static::$configs[$first]->set($configName, $config);
            if(false !== ($configs = static::$configs[$first]->get($configName . '.configs')))
            {
                static::load($name, $configs);
            }
        }
        else
        {
            static::$configs[$first]->set($config);
            if(static::$configs[$first]->exists('configs'))
            {
                static::load($name, static::$configs[$first]->get('configs', []));
            }
        }

        return true;
    }
1232660
public function setLabel( $name )
	{
		if ( $name == $this->getLabel() ) { return; }

		$this->_values['label'] = (string) $name;
		$this->setModified();
	}
1049412
public function addConnection(array $config, $name = 'default')
	{
		$connections = $this->prop['database.connections'];
		$connections[$name] = $config;
		$this->prop['database.connections'] = $connections;
	}
423188
public function label($name)
    {
        $path = $this->path.'.attributes.'.$name;

        return $this->translator->get($path);
    }
838130
public function setDriver($name, array $config)
    {
        if (!isset($config['connector'])) {
            $config['connector'] = NullConnector::class;
        }

        $this->drivers[strtolower($name)] = $config;

        return $this;
    }