Configures.

@param array $configuration The configuration for commands

@author Benjamin Carl <opensource@clickalicious.de>

@return $this Instance for chaining.
12506
protected function configure(array $configuration)
    {
        // Force colors
        \cli\Colors::enable();

        foreach ($configuration as $key => $values) {
            if ($values['type'] === 'short') {
                $this->getFlags()->{$values['type']}($key, $values['info']);
            } else {
                $this->getFlags()->{$values['type']}($key, $values['value'], $values['info']);
            }
        }

        return $this;
    }
1235572
final public static function getInstance(?array $configurations = null): self
    {
        if (is_null(self::$instance)) {
            self::$instance = new self($configurations);
        }
        return self::$instance;
    }
123565
public static function enable($configuration = array())
	{
		self::setConfiguration($configuration);

		if (!self::initialize()) {
			return;
		}

		error_reporting(self::$configuration->getErrorReportingLevel());
	}
550878
public function configure(array $options = array())
    {
        if (isset($options['host'])) {
            $this->host = $options['host'];
        }
        if (isset($options['port'])) {
            if (!is_numeric($options['port']) || is_float($options['port']) || $options['port'] < 0 || $options['port'] > 65535) {
                throw new ConfigurationException($this, 'Port is out of range');
            }
            $this->port = $options['port'];
        }

        if (isset($options['namespace'])) {
            $this->namespace = $options['namespace'];
        }

        if (isset($options['timeout'])) {
            $this->timeout = $options['timeout'];
        }

        if (isset($options['throwConnectionExceptions'])) {
            $this->throwConnectionExceptions = $options['throwConnectionExceptions'];
        }

        if (isset($options['tags'])) {
            $this->tags = $options['tags'];
        }

        return $this;
    }
1313644
protected function addConfigurations($configurations = array())
    {
        foreach ($configurations as $key => $value) {
            $this->registry->config->set($key, $value);
        }

        return $this;
    }
331348
protected function setEnv(array $configuration)
    {
        if (isset($configuration[static::CONFIG_ENV])) {
            $this->configuration->setEnv($configuration[static::CONFIG_ENV]);
        }
    }
746613
protected function sanitizeConfiguration(array $configuration)
    {
        // Removing configuration of fields which do not exist for this form.
        $sanitizedFieldsConfiguration = [];
        $fieldsConfiguration = (isset($configuration['fields']))
            ? $configuration['fields']
            : [];

        foreach ($this->formObject->getProperties() as $property) {
            $sanitizedFieldsConfiguration[$property] = (isset($fieldsConfiguration[$property]))
                ? $fieldsConfiguration[$property]
                : [];
        }

        $configuration['fields'] = $sanitizedFieldsConfiguration;

        return $configuration;
    }
691266
public function setConfiguration(array $configuration)
    {
        // Setting action requests array
        $this->actions = array();

        // Setting Http client object
        $this->client = new Client();

        // Checking if configuration matrix contains a parameters array
        if (!isset($configuration['parameters'])) {
            throw new BadApiConfigurationException(sprintf(
                    '[%s] Missing parameters array for api configuration', $this->getApiName())
            );
        } else {
            // Setting general api call parameters
            $this->setGeneralApiCallParameters($configuration['parameters']);
        }

        // Getting common actions parameters
        $actionConfiguration = array();
        if (isset($configuration['actions_parameters'])) {
            $actionConfiguration = $configuration['actions_parameters'];
        }

        // Checking if configuration matrix contains an actions array
        if (!isset($configuration['actions'])) {
            throw new BadApiConfigurationException(sprintf(
                '[%s] Missing actions array for api configuration', $this->getApiName())
            );
        } else {
            if ($this->getInitAllActions()) {
                // Setting api call actions (this method should always be defined in the child class)
                $this->setActionRequests($configuration['actions'], $actionConfiguration);
            } else {
                $this->actionsCommonConfig = $actionConfiguration;
                $this->actionsConfig       = $configuration['actions'];
            }
        }

        // Configuring client
        if (isset($configuration['config'])) {
            $configs = $configuration['config'];
            if (is_array($configs)) {
                $this->configureClientConfig($configs);
            }
        }
    }
453197
public function checkNamespace(array $configuration)
    {
        foreach ($configuration as $classNamespace => $classConfiguration) {
            if (class_exists($classNamespace) || interface_exists($classNamespace)) {
                return $this;
            }
        }

        throw new TranslationDefinitionException();
    }
744171
protected function parseConfiguration($configuration = [], $defaults = [])
    {
        $configuration = array_merge($defaults, $this->mapConfiguration($configuration));

        array_walk($configuration, [$this, 'setConfig']);

        return $this;
    }
959417
private function parseConfigurationArray(array $configuration = array())
    {
        if (!isset($configuration['host'])) {
            throw new \Exception('Missing Magento Host');
        }
        $url = parse_url($configuration['host']);
        $this->baseUri = sprintf('%s://%s', $url['scheme'], $url['host']);

        if (isset($url['port'])) {
            $this->baseUri .= ':'.$url['port'];
        }

        if (isset($url['path'])) {
            $this->baseUri .= '/'.trim($url['path'], '/');
        }
        $this->isAdmin = !empty($configuration['admin']);
        if (!empty($configuration['adminUrl'])) {
            $this->adminUrl = $configuration['adminUrl'].'/oauth_authorize';
        } else {
            $this->adminUrl = $this->baseUri.'/admin/oauth_authorize';
        }
    }
944104
public function configure(array $configuration)
    {
        // allows to use the default options when a null value is passed
        if (array_key_exists('options', $configuration) && $configuration['options'] === null) {
            unset($configuration['options']);
        }

        $optionsResolver = new OptionsResolver();
        $optionsResolver
            ->setDefined(['host', 'database', 'options', 'driver_options'])
            ->setDefaults([
                'options' => ['connect' => false],
                'driver_options' => ['typeMap' => ['root' => 'array', 'document' => 'array', 'array' => 'array']],
            ])
            ->setRequired(['host', 'database'])
            ->setAllowedTypes('host', 'string')
            ->setAllowedTypes('database', 'string')
            ->setAllowedTypes('options', 'array')
            ->setAllowedTypes('driver_options', 'array')
        ;

        try {
            $this->configuration = $optionsResolver->resolve($configuration);
        } catch (\Exception $e) {
            throw new NoSQLDriverException('Wrong configuration: '.$e->getMessage(), $e->getCode(), $e);
        }
    }
39888
public function checkAlias(array $configuration)
    {
        foreach ($configuration as $classNamespace => $classConfiguration) {
            if (
                isset($classConfiguration['alias']) &&
                $classConfiguration['alias']
            ) {
                return $this;
            }
        }

        throw new TranslationDefinitionException();
    }
945210
public function setConfig(array $config)
    {
        foreach ($config as $key => $value) {
            $this->_config[$key] = $value;
        }

        return $this;
    }
1327160
protected function buildTasks(array $configuration)
    {
        $this->io->text('- Building tasks...');
        $builder = new TaskBuilder($this->debug);

        $tasks = $builder->build($configuration);

        $this->io->text('- Tasks build !');
        $this->io->newLine();

        return $tasks;
    }
105612
protected function fileFactory(array $configuration): File
	{
		return (new File($this->container->get(FileSystem::class), $configuration['path'], $this->classWhitelist))->setPrefix($configuration['prefix'] ?? '');
	}
550640
public static function fromArray(array $configuration)
    {
        $type = ArrayHelper::getValue($configuration, 'type');
        $value = ArrayHelper::getValue($configuration, 'value');
        $target = ArrayHelper::getValue($configuration, 'target');
        
        if (empty($type)) {
            return false;
        }
        
        return (new self(['type' => $type, 'value' => $value, 'target' => $target]));
    }