Build a definition from the passed values.

@param Configuration $configuration The configuration.
@param array         $data          The configuration values.

@return Definition

@throws \InvalidArgumentException When a required key is missing.
969419
public function build(Configuration $configuration, array $data): Definition
    {
        foreach (['name', 'jobs'] as $key) {
            if (!array_key_exists($key, $data)) {
                throw new \InvalidArgumentException('Missing key "' . $key . '"');
            }
        }

        $name = $data['name'];
        $jobs = [];
        foreach ($data['jobs'] as $index => $job) {
            // Global defined job?
            if (is_string($job)) {
                $jobs[] = new ReferencedJobDefinition($job, $configuration);
                continue;
            }

            // Create local job.
            if (!isset($job['name'])) {
                $job['name'] = $name . '.' . $index;
            }
            $jobs[] = $this->definitionBuilder->buildJob($configuration, $job);
        }
        unset($data['name'], $data['jobs']);

        return new BatchJobDefinition($name, $jobs, $data);
    }
394138
public function validate(array $data)
    {
        $processor = new Processor();
        $processor->processConfiguration($this, $data);

        foreach ($data['tools'] as $tool) {
            $importer = $this->getImporterByName($tool['tool']['type']);

            if (!$importer && isset($tool['tool']['data'])) {
                throw new InvalidConfigurationException('The importer ' . $tool['tool']['type'] . ' does not exist');
            }

            if (isset($tool['tool']['data'])) {
                $array['data'] = $tool['tool']['data'];
                $importer->validate($array);
            }
        }
    }
453197
public function checkNamespace(array $configuration)
    {
        foreach ($configuration as $classNamespace => $classConfiguration) {
            if (class_exists($classNamespace) || interface_exists($classNamespace)) {
                return $this;
            }
        }

        throw new TranslationDefinitionException();
    }
929862
public function sitesEdit(array $data)
    {
        if (!array_key_exists('code', $data)) {
            throw new \InvalidArgumentException(
                'Data must contain "code" parameter.'
            );
        }

        /* @noinspection PhpUndefinedMethodInspection */
        return $this->client->makeRequest(
            sprintf('/reference/sites/%s/edit', $data['code']),
            "POST",
            ['site' => json_encode($data)]
        );
    }
1261066
protected function instantiate(string $configuration)
	{
		if(!isset($this->configurations[$configuration]))
		{
			throw new RuntimeException(vsprintf('[ %s ] has not been defined in the cache configuration.', [$configuration]));
		}

		$configuration = $this->configurations[$configuration];

		return $this->factory($configuration['type'], $configuration);
	}
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']);
            }
        }
    }
457479
private function setImporters(Configuration $configuration, array $data)
    {
        foreach ($this->listImporters as $importer) {
            $importer->setRootPath($configuration->getExtractPath());
            if ($owner = $configuration->getOwner()) {
                $importer->setOwner($owner);
            } else {
                $importer->setOwner($this->container->get('security.token_storage')->getToken()->getUser());
            }
            $importer->setConfiguration($data);
            $importer->setListImporters($this->listImporters);

            if ($this->logger) $importer->setLogger($this->logger);
        }
    }
891933
protected function getForce(PropertyMappingConfigurationInterface $configuration = null)
    {
        if ($configuration === null) {
            throw new InvalidPropertyMappingConfigurationException('Missing property configuration', 1457516367);
        }
        return (boolean)$configuration->getConfigurationValue(PackageConverter::class, self::FORCE);
    }
965848
public function requireIfNotAvailableOr(Configuration $configuration, array $params)
  {
    $requiredIfNotAvailable = $configuration->getOptions()->getRequiredIfNotAvailable();
    foreach ($requiredIfNotAvailable->getOr() as $key)
    {
      if (!array_key_exists(strtolower($key), $params))
      {
        return true;
        break;
      }
    }

    return false;
  }
1270844
private function parseConfiguration(array $configuration = array())
    {
        $configToPropertyMap = array(
            'identifier' => 'applicationKey',
            'expiration' => 'applicationExpiration',
            'name' => 'applicationName',
            'scope' => 'applicationScope',
        );

        foreach ($configToPropertyMap as $config => $property) {
            if (isset($configuration[$config])) {
                $this->$property = $configuration[$config];
            }
        }
    }
1110015
private static function getContainerBuilder(Configuration $configuration): DIContainerBuilder
    {
        $containerBuilder = new DIContainerBuilder($configuration->getContainerClass());

        $containerBuilder->useAutowiring($configuration->doesUseAutowiring());
        $containerBuilder->useAnnotations($configuration->doesUseAnnotations());
        $containerBuilder->ignorePhpDocErrors($configuration->doesIgnorePhpDocErrors());

        if ($configuration->doesUseDefinitionCache()) {
            $containerBuilder->enableDefinitionCache();
        }

        if ($configuration->getWrapContainer() !== null) {
            $containerBuilder->wrapContainer($configuration->getWrapContainer());
        }

        if ($configuration->getProxiesPath() !== null) {
            $containerBuilder->writeProxiesToFile(true, $configuration->getProxiesPath());
        }

        if (!empty($configuration->getCompilationPath())) {
            $containerBuilder->enableCompilation(
                $configuration->getCompilationPath(),
                'CompiledContainer',
                $configuration->getCompiledContainerClass()
            );
        }

        return $containerBuilder;
    }
824635
public static function fromArray(array $data)
	{
		if ( ! array_key_exists('client_id', $data))
			throw new ClientConfigurationException('Configuration file has no client_id set');
		if ( ! array_key_exists('client_secret', $data))
			throw new ClientConfigurationException('Configuration file has no client_secret set');
		if ( ! array_key_exists('site_token', $data))
			throw new ClientConfigurationException('Configuration file has no site_token set');

		$baseUrl = ( ! array_key_exists('api', $data))
			? null
			: $data['api'];

		$httpClientConfig = ( ! array_key_exists('http_client', $data))
			? array()
			: $data['http_client'];

		$clientConfig = new ClientConfig($data['client_id'], $data['client_secret'], $data['site_token'], $baseUrl, $httpClientConfig);

		if (array_key_exists('cache_file', $data))
			$clientConfig->setAccessTokenCacheFile($data['cache_file']);

		return $clientConfig;
	}
888784
public function create($adapterType, array $config)
    {
        if (!array_key_exists($adapterType, $this->adapters)) {
            throw new \InvalidArgumentException(
                sprintf('Cache Adapter\'s key %s does not exist', $adapterType)
            );
        }

        /**
         * @fixme : Active this part & clean cache config
         */
        if (!isset($config[$adapterType])) {
            throw new InvalidConfigurationException(
                sprintf('Config is not set for adapter %s', $adapterType)
            );
        }

        return new $this->adapters[$adapterType]($config[$adapterType]);
    }
689408
public function addData($key, $value = null)
    {
        if (is_array($key)) {
            foreach ($key as $k => $v) {
                $this->data[$k] = $v;
            }
        }
        else if (is_string($key)) {
            $this->data[$key] = $value;
        }
        else {
            throw new \InvalidArgumentException(
                "invalid value provided for 'key'; expecting a key as a ".
                "string or an associative array"
            );
        }
        return $this;
    }
1117665
public function configure(Configuration $configuration)
    {
        foreach ($this->nsMap as $type => $map) {
            if (!count($map)) {
                continue;
            }
            $method = 'get' . ucfirst($type) . 'NamespacesMap';
            if (!method_exists($configuration, $method)) {
                throw new InvalidArgumentException('Invalid type of structure namespaces map: ' . $type);
            }
            /** @var $nsMap Configuration\NamespacesMap */
            $nsMap = $configuration->$method();
            $nsMap->add($map);
        }
    }
987467
public function buildName($pipeline, $configuration)
    {
        $name = is_array($configuration) && array_key_exists("name", $configuration) ? $configuration["name"] : null;
        if (empty($name)) {
            throw new InvalidConfigurationException("Missing pipeline name");
        }
        $pipeline->setName($name);
    }
745175
public function fetch(ReportInterface $report, array $configuration = [])
    {
        if (null === $type = $report->getDataFetcher()) {
            throw new \InvalidArgumentException('Cannot fetch data for ReportInterface instance without DataFetcher defined.');
        }

        /** @var DataFetcherInterface $dataFetcher */
        $dataFetcher = $this->registry->get($type);
        $configuration = empty($configuration) ? $report->getDataFetcherConfiguration() : $configuration;

        return $dataFetcher->fetch($configuration);
    }