Create the resources by the definitions

@param  array $definitions
@return Resource\ResourceInterface[]
@throws InvalidOptions
9484
static protected function createResources($definitions) {
		$resources = [];
		
		foreach ($definitions as $name => $options) {
			if (! isset($options['type'])) {
				throw new InvalidOptions('Type of resource must be specified');
			}
			
			$class = self::NAMESPACE_RESOURCE . '\\' . ucfirst($options['type']);
			unset($options['type']);
			
			$resources[$name] = new $class($options);
		}
		
		return $resources;
	}
491762
public function configure(...$definitions): ContainerConfiguration
    {
        $builder = new ContainerBuilder(ContainerConfiguration::class);

        $builder->useAutowiring(false)->useAnnotations(false)->ignorePhpDocErrors(false);

        $wiring = $this->config[WIRING] ?? null;
        if (fn\hasValue($wiring, [WIRING\REFLECTION, WIRING\AUTO])) {
            $builder->useAutowiring(true);
        } else if ($wiring === WIRING\STRICT) {
            $builder->useAnnotations(true)->ignorePhpDocErrors(false);
        } else if ($wiring === WIRING\TOLERANT) {
            $builder->useAnnotations(true)->ignorePhpDocErrors(true);
        }

        empty($this->config[CACHE]) || $builder->enableDefinitionCache();
        empty($this->config[PROXY]) || $builder->writeProxiesToFile(true, $this->config[PROXY]);
        empty($this->config[COMPILE]) || $builder->enableCompilation($this->config[COMPILE]);
        $this->container && $builder->wrapContainer($this->container);

        foreach ($definitions as $definition) {
            $builder->addDefinitions($definition);
        }

        /** @noinspection PhpUnhandledExceptionInspection */
        /** @noinspection PhpIncompatibleReturnTypeInspection */
        $built = $builder->build();
        return $built instanceof ContainerConfiguration
            ? $built
            : new ContainerConfiguration($built);
    }
1005451
public function createConfiguration(array $options)
    {
        // strip controller options

        $files = $options['files'];
        // if $files is a single object, casting will break it
        if (is_object($files)) {
            $files = array($files);
        } elseif (! is_array($files)) {
            $files = (array)$files;
        }
        unset($options['files']);

        $sources = array();
        foreach ($files as $file) {
            try {
                $sources[] = $this->sourceFactory->makeSource($file);
            } catch (Minify_Source_FactoryException $e) {
                $this->logger->error($e->getMessage());

                return new Minify_ServeConfiguration($options);
            }
        }

        return new Minify_ServeConfiguration($options, $sources);
    }
1202869
protected function fillOptionsWithValues(array $options)
    {
        return array_merge(
            array_map(
                function ($value) {
                    if (false === is_array($value)) {
                        throw new InvalidTypeException(
                            'Supported options of a service must be an array with a value as first entry, and a flag to tell if the option is required in the second entry.',
                            1459249834
                        );
                    }

                    return $value[0];
                },
                $this->supportedOptions
            ),
            $options
        );
    }
705143
public function addDefinition(Definition $definition)
    {
        if ($this->hasDefinition($definition)) {
            throw new \InvalidArgumentException(sprintf('Definition "%s" allready exists.', $definition->getName()));
        }

        $this->definitions[$definition->getName()] = $definition;

        return $this;
    }
753843
protected function parse(array $definitions)
    {
        foreach ($this->rawParams as $rKey => $rVal) {
            if (array_key_exists($rKey, $definitions)) {
                if (is_array($rVal)) {
                    $value = array();

                    foreach ($rVal as $key => $val) {
                        $value[$key] = $this->validateValue($val, $definitions[$rKey]);
                    }
                } else {
                    $value = $this->validateValue($rVal, $definitions[$rKey]);
                }

                $this->parsedParams[$rKey] = $value;
                unset($this->rawParams[$rKey]);

                if ($definitions[$rKey]->getIsRequired()) {
                    unset($this->requiredParams[array_search($rKey, $this->requiredParams)]);
                }
            }
        }

        $this->handleUndefinedParameters();
        $this->handleMissingRequiredParameters();
    }
1219181
public function build(array $filterConfigurations)
    {
        $resolver = new OptionsResolver();
        $filters = [];

        foreach ($filterConfigurations as $filterName => $filterConfiguration) {
            $resolver->clear();

            if ($filterConfiguration === null) {
                $filterConfiguration = [];
            }
            $configuration = $this->getFilterConfiguration($filterName);
            $configuration->configureOptions($resolver);
            $configuration->setParameters($resolver->resolve($filterConfiguration));

            $class = $this->mapping[$filterName];

            /** @var FilterInterface $filter */
            $filter = new $class(
                // filter's name
                $filterName,
                // filter's configuration
                $configuration,
                // event dispatcher
                $this->eventDispatcher
            );
            $filter->checkRequirements();

            $filters[$filterName] = $filter;
        }

        return $filters;
    }
854805
public function parseRulesDefinition($definition): RulesCollection
    {
        if (is_callable($definition)) {

            $definition = [$definition];

        }

        if (is_string($definition)) {

            $definition = array_map('trim', explode('|', $definition));

        }

        if (is_array($definition)) {

            $keys = array_keys($definition);

            return array_reduce($keys, function ($rules, $key) use ($definition) {

                $definition = $definition[$key];

                $rule = $this->parseRuleDefinition($key, $definition);

                return $rules->withRule($rule);

            }, new RulesCollection);

        }

        throw new InvalidRuleFormatException($definition);
    }
721138
public function addDefinitions(array $definitions)
    {
        foreach ($definitions as $name => $definition) {
            if (!($definition instanceof DefinitionInterface)) {
                throw new DcGeneralInvalidArgumentException(
                    'Definition ' . $name . ' does not implement DefinitionInterface.'
                );
            }

            $this->setDefinition($name, $definition);
        }

        return $this;
    }
840473
public function create(array $options)
    {
        $paths = [];

        $entityClass = $this->getClassName($options['entity-table']);
        $closureClass = $this->getClassName($options['closure-table']);
        $useInnoDB = $options['use-innodb'];
        $stubPrefix = $useInnoDB ? '-innodb' : '';

        $paths[] = $path = $this->getPath($options['entity-table'], $options['migrations-path']);
        $stub = $this->getStub('entity' . $stubPrefix, 'migrations');

        $this->filesystem->put($path, $this->parseStub($stub, [
            'entity_table' => $options['entity-table'],
            'entity_class' => $entityClass
        ]));

        $paths[] = $path = $this->getPath($options['closure-table'], $options['migrations-path']);
        $stub = $this->getStub('closuretable' . $stubPrefix, 'migrations');

        $this->filesystem->put($path, $this->parseStub($stub, [
            'closure_table' => $options['closure-table'],
            'closure_class' => $closureClass,
            'entity_table' => $options['entity-table']
        ]));

        return $paths;
    }
576552
public function build(array $definitions)
    {
        $criteria = [];

        foreach ($definitions as $definition) {
            $criterion = $this->dispatchBuild($definition);

            if ($criterion instanceof Criterion) {
                $criteria[] = $criterion;
            }
        }

        return $criteria;
    }
447908
private function getOptions(InputDefinition $definition, array $options): array
    {
        $argv = [];
        foreach ($options as $name => $value) {
            $definition->getOption($name) && $argv[] = sprintf('--%s=%s', $name, $value);
        }
        return $argv;
    }
1262667
public static function createFromOptions(array $options)
    {
        Validate::notNull($options['Name'], 'options[Name]');
        Validate::notNull($options['ParentAssetId'], 'options[ParentAssetId]');

        $assetFile = new self($options['Name'], $options['ParentAssetId']);
        $assetFile->fromArray($options);

        return $assetFile;
    }
1188440
private function initOptions()
    {
        $this->optionsResolver->setDefaults([
            'entity' => null,
            'qb' => null,
            'alias' => null,
            'em' => null,
            'useOutputWalkers' => null,
        ]);

        $this->optionsResolver->setAllowedTypes('entity', ['string', 'null']);
        $this->optionsResolver->setAllowedTypes('qb', ['\Doctrine\ORM\QueryBuilder', 'null']);
        $this->optionsResolver->setAllowedTypes('alias', ['null', 'string']);
        $this->optionsResolver->setAllowedTypes('em', ['null', 'string']);
        $this->optionsResolver->setAllowedTypes('useOutputWalkers', ['null', 'bool']);

        $entityNormalizer = function(Options $options, $value) {
            if (is_null($options['qb']) && is_null($value)) {
                throw new InvalidOptionsException('You must specify at least one option, "qb" or "entity".');
            }

            return $value;
        };

        $this->optionsResolver->setNormalizer('entity', $entityNormalizer);
    }
753848
protected function mergeDefinitions(array $definitions)
    {
        return array_merge(
            $definitions,
            array(
                new InputOption('config', 'c', InputOption::VALUE_OPTIONAL, 'Path to config file. Inline options override.', Resque::DEFAULT_CONFIG_FILE),
                new InputOption('include', 'I', InputOption::VALUE_OPTIONAL, 'Path to include php file'),
                new InputOption('host', 'H', InputOption::VALUE_OPTIONAL, 'The Redis hostname.', Resque\Redis::DEFAULT_HOST),
                new InputOption('port', 'p', InputOption::VALUE_OPTIONAL, 'The Redis port.', Resque\Redis::DEFAULT_PORT),
                new InputOption('scheme', null, InputOption::VALUE_REQUIRED, 'The Redis scheme to use.', Resque\Redis::DEFAULT_SCHEME),
                new InputOption('namespace', null, InputOption::VALUE_REQUIRED, 'The Redis namespace to use. This is prefixed to all keys.', Resque\Redis::DEFAULT_NS),
                new InputOption('password', null, InputOption::VALUE_OPTIONAL, 'The Redis AUTH password.'),
                new InputOption('log', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Specify the handler(s) to use for logging.'),
                new InputOption('events', 'e', InputOption::VALUE_NONE, 'Outputs all events to the console, for debugging.'),
            )
        );
    }
525935
protected function _createManager(array $definitions)
    {
        $manager = new DefinitionManager();

        foreach ($definitions as $name => $definition)
        {
            if ($definition instanceof DefinitionHelperInterface) {
                /** @var DefinitionHelperInterface $definition */
                $manager->add($definition->getDefinition($name));
            } else if ($definition instanceof EntryReference) {
                /** @var EntryReference $definition */
                $manager->add(new AliasDefinition($name, $definition->getName()));
            } else {
                $manager->add(new ValueDefinition($name, $definition));
            }
        }
        return $manager;
    }
759961
public function addDefinitions(array $definitions)
    {
        foreach ($definitions as $id => $definition) {
            $this->setDefinition($id, $definition);
        }
    }