@param IRouter $router
@param array $config

@throws InvalidConfigurationException
511686
protected function processRoutes(IRouter $router, array $config) {
        $routes = array_get($config, 'routes', []);

        if ( ! is_array($routes)) {
            throw new InvalidConfigurationException(
                'Routing config "routes" must be an array.'
            );
        }

        foreach ($routes as $route) {
            list($method, $path, $action) = $this->gatherRouteFacts($route);

            if (empty($method) || empty($path) || empty($action)) {
                $message = s(
                    'Route must provide a "method", "path" and an "action". ' .
                    'Received method: "%s", path: "%s", action: "%s".',
                    is_scalar($method) ? $method : get_type($method),
                    is_scalar($path) ? $path : get_type($path),
                    is_scalar($action) ? $action : get_type($action)
                );

                throw new InvalidConfigurationException($message);
            }

            $router->route($method, $path, $action);
        }
    }
662403
public function registerRawRouting(array $routes, PackageResolver $resolver)
    {
        foreach ($routes as $key => &$route) {
            // Package
            if (isset($route['package'])) {
                if (!isset($route['pattern'])) {
                    throw new \InvalidArgumentException(sprintf('Route need pattern: %s', print_r($route, true)));
                }

                if (!$resolver->exists($route['package'])) {
                    throw new \InvalidArgumentException(sprintf(
                        'Package %s not exists when register routing: %s.',
                        $route['package'],
                        $key
                    ));
                }

                $package = $resolver->getPackage($route['package']);

                $package->loadRouting($this, $route['pattern']);

                continue;
            }

            // Simple route
            $this->addRouteByConfig($key, $route);
        }

        return $this;
    }
407082
protected function validateServerConfig($config)
    {
        if (!is_array($config)) {
            throw new InvalidArgumentException($this->translate(
                'Server configuration should be an array or Traversable.'
            ));
        }
        if (!isset($config['id']) || empty($config['id'])) {
            throw new InvalidArgumentException($this->translate(
                'Cannot find server id in configuration.'
            ));
        }
        if (!isset($config['connection']) || empty($config['connection'])) {
            throw new InvalidArgumentException($this->translate(
                'Cannot find connection type in configuration.'
            ));
        }
    }
23922
private function splitRoutesIntoSections(IRouter $router): array
	{
		$routes = [];
		$sections = [];
		$fileName = 1;

		if ($router instanceof ApiRoute) {
			$routes = [$router];
		} elseif ($router instanceof \IteratorAggregate) {
			$routes = $this->getApiRoutesFromIterator($router);
		}

		foreach ($routes as $route) {
			if ($route->getSection()) {
				if (empty($sections[$route->getSection()])) {
					$sections[$route->getSection()] = [];
				}

				$sections[$route->getSection()][$fileName++] = $route;
			} else {
				$sections[$fileName++] = $route;
			}
		}

		return $sections;
	}
597399
private function loadConfiguration(Router $router)
    {
        $configuration = new Configuration($this->translator);
        $configuration = $configuration->getConfiguration($router);

        foreach ($configuration['steps']['groups'] as &$currentGroup) {
            if (isset($currentGroup['title'])) {
                $currentGroup['title'] = $this->getTextFromSettings($currentGroup['title']);
            }
            if (isset($currentGroup['subtitle'])) {
                foreach ($currentGroup['subtitle'] as &$subtitle) {
                    $subtitle = $this->getTextFromSettings($subtitle);
                }
            }
            foreach ($currentGroup['steps'] as &$currentStep) {
                $currentStep['text'] = $this->getTextFromSettings($currentStep['text']);
            }
        }

        $this->configuration = $configuration;
    }
846227
public function setConfig(array $configs)
	{
		foreach($configs as $config_key => $config_value)
		{
			if( property_exists(get_class($this), $config_key) )
			{
				$this->$config_key = $config_value;
			}
			else
			{
				throw new \InvalidArgumentException;
			}
		}
	}
57011
private function assertValidAlgorithmConfiguration(array $algorithmConfig)
    {
        if (!array_key_exists('id', $algorithmConfig)
            || !$this->containsValidCryptoConfig($algorithmConfig, 'decryption')
            || !$this->containsValidCryptoConfig($algorithmConfig, 'encryption')
        ) {
            throw new InvalidAlgorithmConfigurationException();
        }
    }
1291658
public function configureMultisite(ContainerBuilder $container, array $config)
    {
        $multisite = $config['multisite'];

        if ('host' === $multisite) {
            $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host');

            $container->removeDefinition('sonata.page.site.selector.host_by_locale');
            $container->removeDefinition('sonata.page.site.selector.host_with_path');
            $container->removeDefinition('sonata.page.site.selector.host_with_path_by_locale');
        } elseif ('host_by_locale' === $multisite) {
            $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host_by_locale');

            $container->removeDefinition('sonata.page.site.selector.host');
            $container->removeDefinition('sonata.page.site.selector.host_with_path');
            $container->removeDefinition('sonata.page.site.selector.host_with_path_by_locale');
        } else {
            /*
             * The multipath option required a specific router and RequestContext
             */
            $container->setAlias('router.request_context', 'sonata.page.router.request_context');

            if ('host_with_path' === $multisite) {
                $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host_with_path');

                $container->removeDefinition('sonata.page.site.selector.host_with_path_by_locale');
                $container->removeDefinition('sonata.page.site.selector.host');
                $container->removeDefinition('sonata.page.site.selector.host_by_locale');
            } elseif ('host_with_path_by_locale' === $multisite) {
                $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host_with_path_by_locale');

                $container->removeDefinition('sonata.page.site.selector.host_with_path');
                $container->removeDefinition('sonata.page.site.selector.host');
                $container->removeDefinition('sonata.page.site.selector.host_by_locale');
            }
        }

        if ($container->hasAlias('sonata.page.site.selector')) {
            $container->getAlias('sonata.page.site.selector')->setPublic(true);
        }
    }
67912
protected function processResolvers(IRouter $router, array $config) {
        $resolvers = array_get($config, 'resolvers', []);

        if ( ! is_array($resolvers)) {
            throw new InvalidConfigurationException(
                'Routing resolvers "resolvers" must be an array.'
            );
        }

        foreach ($resolvers as $resolver) {
            $name = array_get($resolver, 'name');
            $handler = array_get($resolver, 'resolver');

            if (empty($name)) {
                throw new InvalidConfigurationException(
                    'Routing resolver must have a "name".'
                );
            }

            if ( ! is_callable($handler)) {
                throw new InvalidConfigurationException(
                    'Routing resolver must have a callable "resolver".'
                );
            }

            $router->addResolver($name, $handler);
        }
    }
673066
protected function paginateRows(array $pagination, $rowNumber)
    {
        if (null === $this->renderer) {
            throw new InvalidConfigurationException('The block renderer must be injected with "setRenderer" method');
        }

        $cacheRows = [];

        foreach ($this->dataTransformers as $dataTransformer) {
            if ($dataTransformer instanceof PrePaginateTransformerInterface) {
                $pagination = $dataTransformer->prePaginate($this->config, $pagination);
            }
        }

        // loop in rows
        foreach ($pagination as $data) {
            $row = [
                '_row_number' => $rowNumber++,
                '_attr_columns' => [],
            ];

            if (null !== $this->rowId) {
                $rowId = $this->getDataField($data, $this->rowId);

                if (null !== $rowId) {
                    $row['_row_id'] = $rowId;
                }
            }

            // loop in cells
            /* @var BlockInterface $column */
            foreach ($this->getColumns() as $column) {
                if ($column->hasOption('enabled') && false === $column->getOption('enabled')) {
                    continue;
                }

                if (\count($column->getOption('attr')) > 0) {
                    $row['_attr_columns'][$column->getName()] = $column->getOption('attr');
                }

                if ('_row_number' === $column->getOption('index')) {
                    continue;
                }

                $config = $column->getConfig();
                $formatter = $config->getOption('formatter');
                $field = $config->getOption('data_property_path');
                $field = null === $field
                    ? $this->formatIndex($config->getOption('index'))
                    : $field;
                $cellData = $this->getDataField($data, $field, $config->getOption('cell_empty_data'));
                $options = array_replace(['wrapped' => false, 'inherit_data' => false], $config->getOption('formatter_options'));
                $options = $this->overrideCellOptions($column, $formatter, $data, $options);

                if (TwigType::class === $formatter) {
                    $options = array_merge_recursive($options, [
                        'variables' => [
                            '_column' => $column,
                            '_row_data' => $data,
                            '_row_number' => $row['_row_number'],
                        ],
                    ]);
                }

                /* @var BlockBuilderInterface $config */
                $cell = $config->getBlockFactory()->createNamed($column->getName(), $formatter, $cellData, $options);
                $row[$column->getName()] = $this->renderer->searchAndRenderBlock($cell->createView(), 'widget');
            }

            if (0 === \count($row['_attr_columns'])) {
                unset($row['_attr_columns']);
            }

            $cacheRows[] = $row;
        }

        foreach ($this->dataTransformers as $dataTransformer) {
            if ($dataTransformer instanceof PostPaginateTransformerInterface) {
                $cacheRows = $dataTransformer->postPaginate($this->config, $cacheRows);
            }
        }

        return $cacheRows;
    }
1287349
public function setConfiguration(Configuration $config)
    {
        if ($config === null) {
            throw new Exception\InvalidArgumentException('$config cannot be null');
        }


        if ($this->config !== null) {
            $this->config->unregisterConfigChangeListener($this->getConfigChangeListener());
        }

        $this->config = $config;
        $this->setOptions($config->getZendLdapConfiguration());
        $this->config->registerConfigChangeListener($this->getConfigChangeListener());
    }
1100
protected function isConfigEnabled(ContainerBuilder $container, array $config)
    {
        if (!array_key_exists('enabled', $config)) {
            throw new InvalidArgumentException("The config array has no 'enabled' key.");
        }

        return (bool) $container->getParameterBag()->resolveValue($config['enabled']);
    }
199160
protected function treatRoutesConfig(array $config): void
    {
        if (!\array_key_exists('routes', $config)) {
            return;
        }

        if (!\is_array($config['routes'])) {
            throw new RouterException('Config routes has to be an array');
        }

        foreach ($config['routes'] as $route) {
            if (!\array_key_exists('methods', $route)) {
                throw new RouterException('Config routes/methods is mandatory');
            }

            if (!\array_key_exists('url', $route)) {
                throw new RouterException('Config routes/url is mandatory');
            }

            if (!\array_key_exists('callback', $route)) {
                throw new RouterException('Config routes/callback is mandatory');
            }

            $newRoute = new Route($route['methods'], $route['url'], $route['callback']);

            if (\array_key_exists('constraints', $route)) {
                $newRoute->setParametersConstraints($route['constraints']);
            }

            if (\array_key_exists('middlewares', $route)) {
                if (!\is_array($route['middlewares'])) {
                    throw new RouterException('Config routes/middlewares has to be an array');
                }

                foreach ($route['middlewares'] as $middleware) {
                    $newRoute->addMiddleware($middleware);
                }
            }

            if (\array_key_exists('name', $route)) {
                if (!\is_string($route['name'])) {
                    throw new RouterException('Config routes/name has to be a string');
                }

                $newRoute->setName($route['name']);
            }

            if (\array_key_exists('host', $route)) {
                if (!\is_string($route['host'])) {
                    throw new RouterException('Config routes/host has to be a string');
                }

                $newRoute->setHost($route['host']);
            }

            if (\array_key_exists('host_constraints', $route)) {
                if (!\is_array($route['host_constraints'])) {
                    throw new RouterException('Config routes/host_constraints has to be an array');
                }

                $newRoute->setHostConstraints($route['host_constraints']);
            }

            if (\array_key_exists('optionals_parameters', $route)) {
                if (!\is_array($route['optionals_parameters'])) {
                    throw new RouterException('Config routes/optionals_parameters has to be an array');
                }

                $newRoute->setOptionalsParameters($route['optionals_parameters']);
            }

            $this->addRoute($newRoute);
        }
    }
673949
public function setup(array $formatters)
    {
        foreach ($formatters as $formatterName => $formatter) {
            if (!$formatter instanceof TrackingParameterFormatterInterface) {
                throw new InvalidConfigurationException(
                    sprintf('Invalid tracking parameter formatter "%s".', $formatterName)
                );
            }
        }

        $this->formatters = $formatters;
    }
1064854
function add(iRoute $router, $allowOverride = true, $priority = null)
    {
        $router = $this->_prepareRouter($router);


        # Add Router in Stack:
        #
        $this->_priorityQueue()->insert($router, ['order' => $priority]);
        $this->routesAdd[$router->getName()] = $router;


        # Allow Override
        #
        $allowOverride = (bool) $allowOverride;
        if (false === $allowOverride)
            $this->_routes_strict_override[$router->getName()] = true;

        return $this;
    }
122846
private function validateTypeAndService(array $config, $path)
    {
        if (!isset($config['type']) && !isset($config['service'])) {
            throw new InvalidConfigurationException(sprintf('You must set one of "type" or "service" for "%s"', $path));
        }
        if (isset($config['type']) && isset($config['service'])) {
            throw new InvalidConfigurationException(sprintf('You cannot set both "type" and "service" for "%s" - please choose one.', $path));
        }
    }
3643
public static function config($configName, $config = null)
    {
        $_this = Purifier::getInstance();

        if (empty($config)) {
            if (!isset($_this->_configs[$configName])) {
                throw new \InvalidArgumentException(sprintf('Purifier configuration `%s` does not exist!', $configName));
            }
            return $_this->_configs[$configName];
        }

        if (is_array($config)) {
            $purifierConfig = \HTMLPurifier_Config::createDefault();
            foreach ($config as $key => $value) {
                $purifierConfig->set($key, $value);
            }

            return $_this->_configs[$configName] = $purifierConfig;
        } elseif (is_object($config) && is_a($config, 'HTMLPurifier_Config')) {
            return $_this->_configs[$configName] = $config;
        } else {
            throw new \InvalidArgumentException('Invalid purifier config passed!');
        }
    }