Make a CLIArgument from config

@param string $name
@param string $config
@return \Orpheus\InputController\CLIArgument
557414
public static function make($name, $config) {
		$required = false;
		if( $config[0] === '+' ) {
			$required = true;
			$config = substr($config, 1);
		}
		list($shortName, $type) = explodeList(':', $config, 2);
		return new static($name, $shortName, $type, $required);
	}
760018
protected function createRuntimeDriver(string $name): ProviderContract
    {
        $config = $this->config['runtime'][$name] ?? [];

        return $this->createProvider(new Runtime($name, $config));
    }
279217
protected function wireReference(string $name, string $reference, array $config)
    {
        $service = $this->get($reference);
        $reflection = new ReflectionClass(get_class($service));
        $config = $this->config->get($name);
        $service = $this->prepareService($name, $service, $reflection, $config);

        return $service;
    }
596673
public function model($name, $config = [])
    {
        $config["class"] = $this->modelClasses[ucfirst($name)];
        return Yii::createObject($config);
    }
371868
public function createBatchActionForm($name)
    {
        /** @var AbstractAdmin $admin */
        $admin = $this->getAdmin();

        $container = $admin->getContainer();

        return $container->get('form.factory')->createNamedBuilder($name, 'form', [], [
            'label_format' => 'form.label_%name%',
            'translation_domain' => $admin->getTranslationDomain(),
        ]);
    }
1028437
public static function makeProxy(string $name, array $config)
    {
        $mode = $config['mode'];
        if ($mode == Macro::MASTER_SLAVE) {
            return new MysqlProxyMasterSlave($name, $config);
        } else {
            return false;
        }
    }
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;
    }
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;
    }
1242781
protected function makeFormField($name, $config = [])
    {
        $label = $config['label'] ?? null;
        list($fieldName, $fieldContext) = $this->getFieldName($name);

        $field = new FormField($fieldName, $label);

        if ($fieldContext) {
            $field->context = $fieldContext;
        }

        $field->arrayName = $this->arrayName;
        $field->idPrefix = $this->getId();

        /*
         * Simple field type
         */
        if (is_string($config)) {
            if ($this->isFormWidget($config) !== false) {
                $field->displayAs('widget', ['widget' => $config]);
            }
            else {
                $field->displayAs($config);
            }
        }
        /*
         * Defined field type
         */
        else {
            $fieldType = $config['type'] ?? null;
            if (!is_string($fieldType) && $fieldType !== null) {
                throw new ApplicationException(Lang::get(
                    'backend::lang.field.invalid_type',
                    ['type' => gettype($fieldType)]
                ));
            }

            /*
             * Widget with configuration
             */
            if ($this->isFormWidget($fieldType) !== false) {
                $config['widget'] = $fieldType;
                $fieldType = 'widget';
            }

            $field->displayAs($fieldType, $config);
        }

        /*
         * Set field value
         */
        $field->value = $this->getFieldValue($field);

        /*
         * Apply the field name to the validation engine
         */
        $attrName = implode('.', HtmlHelper::nameToArray($field->fieldName));

        if ($this->model && method_exists($this->model, 'setValidationAttributeName')) {
            $this->model->setValidationAttributeName($attrName, $field->label);
        }

        /*
         * Check model if field is required
         */
        if ($field->required === null && $this->model && method_exists($this->model, 'isAttributeRequired')) {
            // Check nested fields
            if ($this->isNested) {
                // Get the current attribute level
                $nameArray = HtmlHelper::nameToArray($this->arrayName);
                unset($nameArray[0]);

                // Convert any numeric indexes to wildcards
                foreach ($nameArray as $i => $value) {
                    if (preg_match('/^[0-9]*$/', $value)) {
                        $nameArray[$i] = '*';
                    }
                }

                // Recombine names for full attribute name in rules array
                $attrName = implode('.', $nameArray) . ".{$attrName}";
            }

            $field->required = $this->model->isAttributeRequired($attrName);
        }

        /*
         * Get field options from model
         */
        $optionModelTypes = ['dropdown', 'radio', 'checkboxlist', 'balloon-selector'];
        if (in_array($field->type, $optionModelTypes, false)) {

            /*
             * Defer the execution of option data collection
             */
            $field->options(function () use ($field, $config) {
                $fieldOptions = $config['options'] ?? null;
                $fieldOptions = $this->getOptionsFromModel($field, $fieldOptions);
                return $fieldOptions;
            });
        }

        return $field;
    }
1114058
public static function fromConfig(Config $config)
    {
        $message = sprintf(
            'Could not instantiate OptionRepository from Config with starting key "%1$s".',
            empty($config->getKeys())
                ? '<none>'
                : $config->getKeys()[0]
        );

        return new static($message);
    }
357510
protected function createFileDriver(string $name, Prop $config)
	{
		return new FileStore(
			Filesystem::getInstance(),
			$name,
			$config->getOr("directory", "cache"),
			$config->getOr("life", 0)
		);
	}
455561
public static function getInstance($name, $config = array())
    {
        static $instance;

        if (!$instance) {
            $instance = new static();
        }

        $object = clone $instance;

        $config['name'] = $name;

        $object->append($config)
        ->append(array(
            'attribs' => array(
            'id' => null,
            ),
        ));

        return $object;
    }
1192149
protected function loadExtension($name, $useSettings, Config $config)
    {
        if ($config->hasItem('_loaded', $name)) {
            return $this;
        }

        if (!is_array($useSettings)) {
            $useSettings = [];
        }

        $namespaces = $config->get('namespaces', []);

        if (!is_array($namespaces)) {
            $namespaces = [];
        }

        $namespaces[] = "Itq\\Dev";

        $found = false;

        foreach ($namespaces as $namespace) {
            $pattern = sprintf('%s\\Extension\\{Name}\\{Name}Extension', $namespace);
            $class = str_replace('{Name}', str_replace(' ', '', ucwords(str_replace('-', ' ', $name))), $pattern);
            if (!class_exists($class)) {
                continue;
            }
            $found = $class;
        }

        if (false === $found) {
            throw new \RuntimeException(sprintf("Unknown extension '%s'", $name), 412);
        }

        /** @var ExtensionInterface $extension */
        $extension = new $found($useSettings);

        if (!($extension instanceof ExtensionInterface)) {
            throw new \RuntimeException(
                sprintf("%s must be a valid extension (found: %s)", $name, get_class($extension)),
                412
            );
        }

        $this->addExtension($extension);

        $available = $extension->isAvailable($config);

        if ($available) {
            $r = new \ReflectionClass($extension);
            $config->setDefaultItem('_shell_scripts_dirs', $name, dirname($r->getFileName()).'/Resources/shell-scripts');
            foreach ($extension->getConfigLoaders() as $loader) {
                $loader->load($config);
            }
        }

        $config->setItem('_loaded', $name, $available);

        $this->loadExtensions($config);

        return $this;
    }
823939
public static function create(Config $config)
    {
        if (php_sapi_name() === 'cli' || !(self::$instance instanceof self)) {
            self::$instance = new self($config);
        }

        return self::$instance;
    }
1123118
protected function createManipulator(string $name, array $config): Manipulator
    {
        $class = $this->getManipulatorClass($name);
        that($class)->notBlank()->subclassOf(Manipulator::class);

        return new $class($config);
    }
1223360
public static function make($name, array $config): ServiceContainer
    {
        $namespace = self::studly($name);
        $application = "\\Liqunx\\Baidu\\{$namespace}\\Application";

        return new $application($config);
    }
1088306
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;
    }