Parses a configuration from an array to provide access via object.

@param array $configuration The configuration to parse

@author Benjamin Carl <opensource@clickalicious.de>

@return Doozr_Form_Service_Configuration Instance for chaining
333283
public function parseFromArray(array $configuration)
    {
        $this->validateInput($configuration);
        $this->setInput($configuration);
        $this->parse($configuration);
        $this->setId($this->getHash());

        return $this;
    }
963973
public function extract(array $configurations)
    {
        $emailConfiguration = new EmailConfiguration();

        foreach ($configurations as $configuration) {
            switch ($configuration->getKey()) {
                case self::EMAIL_SENDER:
                    $emailConfiguration->setEmailSender($configuration->getValue());
                    break;
                case self::EMAIL_SENDER_NAME:
                    $emailConfiguration->setEmailSenderName($configuration->getValue());
                    break;
                case self::EMAIL_SUBJECT_PREFIX:
                    $emailConfiguration->setEmailSubjectPrefix($configuration->getValue());
                    break;
                case self::EMAIL_BODY_SIGNATURE:
                    $emailConfiguration->setEmailBodySignature($configuration->getValue());
                    break;
            }
        }

        return $emailConfiguration;
    }
59020
public static function get(array $configuration = array())
    {
        if (extension_loaded('redis')) {
            $redis = new \Redis();
            $redis->connect($configuration[CacheKeys::HOST]);
            $cache = new RedisCache();
            $cache->setRedis($redis);
            return $cache;
        }
    }
755029
protected function redisFactory(array $configuration): Redis
	{
		return (new Redis($this->container->get(RedisConnectionManager::class)->connection($configuration['configuration']), $this->classWhitelist))->setPrefix($configuration['prefix'] ?? '');
	}
1342211
public function setup($configurations = array())
    {
        foreach ($configurations as $key => $value) {
            if (!$this->registry->config->has($key)) {
                throw new \RuntimeException(sprintf('Unknown setup key %s.', $key));
            }
            if ($this->registry->validator->has($key)) {
                $validator = $this->registry->validator->get($key);
                if (!$validator->isValid($value)) {
                    if (count($choices = $validator->getChoices())) {
                        throw new \RuntimeException(sprintf('Invalid value %s for %s, values are %s.', var_export($value, true), $key, implode(', ', $choices)));
                    } else {
                        throw new \RuntimeException(sprintf('Invalid value %s for %s.', var_export($value, true), $key));
                    }
                }
            }
            $this->registry->config->set($key, $value);
        }

        return $this;
    }
275669
private function checkTransitionsConfiguration(array $configuration)
    {
        foreach ($configuration as $transitionConfiguration) {
            if (
                is_array($transitionConfiguration) &&
                (count($transitionConfiguration) === 3) &&
                isset($transitionConfiguration[0]) &&
                is_string($transitionConfiguration[0]) &&
                $transitionConfiguration[0] &&
                isset($transitionConfiguration[1]) &&
                is_string($transitionConfiguration[1]) &&
                $transitionConfiguration[1] &&
                isset($transitionConfiguration[2]) &&
                is_string($transitionConfiguration[2]) &&
                $transitionConfiguration[2]
            ) {
                return $this;
            }
        }

        throw new TransitionNotValidException();
    }
990401
protected function sanitize(array $configuration)
    {
        foreach ($configuration as $key => $config) {
            if (null === $config['name']) {
                $configuration[$key]['name'] = $this->defaultRouteName($key);
            }
            if (null === $config['path']) {
                $configuration[$key]['path'] = $this->defaultRoutePath($key);
            }
            if (null === $config['api_name']) {
                $configuration[$key]['api_name'] = $this->defaultApiRouteName($key);
            }
            if (null === $config['api_path']) {
                $configuration[$key]['api_path'] = $this->defaultApiRoutePath($key);
            }
        }

        return $configuration;
    }
521258
public function processRequestPatterns(array &$configuration)
    {
        if (!isset($configuration['TYPO3']['Flow']['security']['authentication']['providers'])) {
            return;
        }
        foreach ($configuration['TYPO3']['Flow']['security']['authentication']['providers'] as $providerName => &$providerOptions) {
            if (!isset($providerOptions['requestPatterns'])) {
                continue;
            }
            foreach ($providerOptions['requestPatterns'] as $requestPatternName => $requestPatternOptions) {
                // already converted?
                if (isset($requestPatternOptions['pattern'])) {
                    continue;
                }
                switch (strtolower($requestPatternName)) {
                    case 'controllerobjectname':
                        $requestPatternOptions = [
                            'pattern' => 'ControllerObjectName',
                            'patternOptions' => ['controllerObjectNamePattern' => $requestPatternOptions]
                        ];
                        break;
                    case 'csrfprotection':
                        $requestPatternOptions = [
                            'pattern' => 'CsrfProtection',
                        ];
                        break;
                    case 'host':
                        $requestPatternOptions = [
                            'pattern' => 'Host',
                            'patternOptions' => ['hostPattern' => $requestPatternOptions]
                        ];
                        break;
                    case 'ip':
                        $requestPatternOptions = [
                            'pattern' => 'Ip',
                            'patternOptions' => ['cidrPattern' => $requestPatternOptions]
                        ];
                        break;
                    case 'uri':
                        $requestPatternOptions = [
                            'pattern' => 'Uri',
                            'patternOptions' => ['uriPattern' => $requestPatternOptions]
                        ];
                        break;
                    default:
                        $this->showWarning(sprintf('Could not automatically convert the syntax of the custom request pattern "%s". Please adjust it manually as described in the documentation.', $requestPatternName));
                        continue 2;
                }
                $patternIdentifier = $this->targetPackageData['packageKey'] . ':' . $this->getShortClassName($requestPatternName);
                $providerOptions['requestPatterns'][$patternIdentifier] = $requestPatternOptions;
                unset($providerOptions['requestPatterns'][$requestPatternName]);
                $this->showNote(sprintf('Adjusted configuration syntax of the "%s" request pattern.', $requestPatternName));
            }
        }
    }
852665
protected function transformObject($object, array $configuration)
    {
        if ($object instanceof \DateTimeInterface) {
            return $object->format(\DateTime::ISO8601);
        } else {
            $propertyNames = ObjectAccess::getGettablePropertyNames($object);

            $propertiesToRender = [];
            foreach ($propertyNames as $propertyName) {
                if (isset($configuration['_only']) && is_array($configuration['_only']) && !in_array($propertyName, $configuration['_only'])) {
                    continue;
                }
                if (isset($configuration['_exclude']) && is_array($configuration['_exclude']) && in_array($propertyName, $configuration['_exclude'])) {
                    continue;
                }

                $propertyValue = ObjectAccess::getProperty($object, $propertyName);

                if (!is_array($propertyValue) && !is_object($propertyValue)) {
                    $propertiesToRender[$propertyName] = $propertyValue;
                } elseif (isset($configuration['_descend']) && array_key_exists($propertyName, $configuration['_descend'])) {
                    $propertiesToRender[$propertyName] = $this->transformValue($propertyValue, $configuration['_descend'][$propertyName]);
                }
            }
            if (isset($configuration['_exposeObjectIdentifier']) && $configuration['_exposeObjectIdentifier'] === true) {
                if (isset($configuration['_exposedObjectIdentifierKey']) && strlen($configuration['_exposedObjectIdentifierKey']) > 0) {
                    $identityKey = $configuration['_exposedObjectIdentifierKey'];
                } else {
                    $identityKey = '__identity';
                }
                $propertiesToRender[$identityKey] = $this->persistenceManager->getIdentifierByObject($object);
            }
            if (isset($configuration['_exposeClassName']) && ($configuration['_exposeClassName'] === self::EXPOSE_CLASSNAME_FULLY_QUALIFIED || $configuration['_exposeClassName'] === self::EXPOSE_CLASSNAME_UNQUALIFIED)) {
                $className = TypeHandling::getTypeForValue($object);
                $classNameParts = explode('\\', $className);
                $propertiesToRender['__class'] = ($configuration['_exposeClassName'] === self::EXPOSE_CLASSNAME_FULLY_QUALIFIED ? $className : array_pop($classNameParts));
            }

            return $propertiesToRender;
        }
    }
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;
    }
1213863
public function init($configurations = array())
    {
        $this->parseAndFillConfiguration($configurations);

        $this->included_directories = $this->default_include['directories'];
        $this->included_extensions = $this->default_include['extensions'];
        $this->included_patterns = $this->default_include['patterns'];

        $this->excluded_directories = $this->default_exclude['directories'];
        $this->excluded_files = $this->default_exclude['files'];
        $this->excluded_extensions = $this->default_exclude['extensions'];
        $this->excluded_patterns = $this->default_exclude['patterns'];
        $this->exclude_hidden = $this->default_exclude['hidden'];

        return $this;
    }
526255
protected function loadConfigurationRecursive(ContainerBuilder $container, array $configuration)
    {
        foreach ($configuration as $values) {
            $loader = new XmlFileLoader($container, new FileLocator($values['path']));
            foreach ($values['configFiles'] as $configFile) {
                $loader->load($configFile);
            }
            if (array_key_exists('configuration', $values)) {
                $this->loadConfigurationRecursive($container, $values['configuration']);
            }
        }
    }
175378
private function parseAndFillConfiguration($configurations)
    {
        $this->default_include = isset($configurations['include']) ?
            array_merge($this->default_include, $configurations['include']) : $this->default_include;

        $this->default_exclude = isset($configurations['exclude']) ?
            array_merge($this->default_exclude, $configurations['exclude']) : $this->default_exclude;
    }
956158
public function resolveParams(array $configuration)
    {
        if ($this->resolved) {
            return;
        }

        $this->config = $configuration;
        $parameters = [];
        foreach ($configuration as $key => $value) {
            $key = $this->resolveValue($key);
            $value = $this->resolveValue($value);
            $parameters[$key] = $this->unescapeValue($value);
        }

        $this->resolved = true;

        return $parameters;
    }
453197
public function checkNamespace(array $configuration)
    {
        foreach ($configuration as $classNamespace => $classConfiguration) {
            if (class_exists($classNamespace) || interface_exists($classNamespace)) {
                return $this;
            }
        }

        throw new TranslationDefinitionException();
    }
1364674
public function loadConfiguration(array $config = [])
    {
        if (isset($config['login'])) {
            $this->setLogin($config['login']);
        }
        if (isset($config['password'])) {
            $this->setPassword($config['password']);
        }
        if (isset($config['dsn'])) {
            $this->setDSN($config['dsn']);
        }
        return $this;
    }
540343
public function loadConfiguration(ConfigurationInterface $configuration)
    {
        $extAssocList = $configuration->getExternalAssociations();
        foreach ($extAssocList as $extAssoc) {
            $this->mapExternalAssociation($extAssoc);
        }
        return $this;
    }