@inheritdoc

@throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
@throws \Symfony\Component\DependencyInjection\Exception\OutOfBoundsException
@throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
422473
public function process(ContainerBuilder $container)
    {
        // 1. Register custom repositories with Aggregate repository
        $aggregateRepositoryDefinition = $container->findDefinition(static::$aggregateRepositoryId);
        $customRepositoryTags = $container->findTaggedServiceIds(static::$customRepositoryTag);
        $customRepositoryReferences = [];

        foreach (array_keys($customRepositoryTags) as $id) {
            $customRepositoryReferences[] = new Reference($id);
        }

        $aggregateRepositoryDefinition->replaceArgument(1, $customRepositoryReferences);

        $topEzRepositoryAlias = $container->getAlias(static::$topEzRepositoryAliasId);

        // 2. Re-link eZ Platform's public top Repository alias
        $container->setAlias(static::$renamedTopEzRepositoryAliasId, (string)$topEzRepositoryAlias);

        // 3. Overwrite eZ Platform's public top Repository alias
        // to aggregate Repository implementation
        $container->setAlias(static::$topEzRepositoryAliasId, static::$aggregateRepositoryId);
    }
1165869
protected function resolveDatabaseServiceInstance($service = null)
    {
        /** @var EngineType $engine */
        $engine = $this->getEngineInstance();
        $services = $engine->getServiceInstanceByGroup('database');

        if (!isset($service) || !isset($services[$service])) {
            if (count($services) > 1) {
                $options = array_keys($services);
                $service = $this->doAsk(
                    new ChoiceQuestion(
                        'Select the database service to use for import: ',
                        $options
                    )
                );
            } else {
                $options = array_keys($services);
                $service = reset($options);
            }
        }

        if (!isset($services[$service])) {
            throw new \RuntimeException(
                'Unable to resolve database service.'
            );
        }

        return $services[$service];
    }
331466
public function init()
    {
        $extensions = [];

        if (empty($this->extensionClasses) && empty($this->userConfig)) {
            return;
        }

        foreach ($this->extensionClasses as $extensionClass) {
            if (!class_exists($extensionClass)) {
                throw new \InvalidArgumentException(sprintf(
                    'Extension class "%s" does not exist',
                    $extensionClass
                ));
            }

            $extension = new $extensionClass();

            if (!$extension instanceof ExtensionInterface) {
                throw new \InvalidArgumentException(sprintf(
                    // add any manually specified extensions
                    'Extension "%s" must implement the PhpBench\\Extension interface',
                    get_class($extension)
                ));
            }

            $extensions[] = $extension;

            $this->config = array_merge(
                $this->config,
                $extension->getDefaultConfig()
            );
        }

        $diff = array_diff(array_keys($this->userConfig), array_keys($this->config));

        if ($diff) {
            throw new \InvalidArgumentException(sprintf(
                'Unknown configuration keys: "%s". Permitted keys: "%s"',
                implode('", "', $diff), implode('", "', array_keys($this->config))
            ));
        }

        $this->config = array_merge(
            $this->config,
            $this->userConfig
        );

        foreach ($extensions as $extension) {
            $extension->load($this);
        }
    }
592387
private function resolve($service, $method)
    {
        if (is_callable($service)) {
            return $service;
        }

        if (is_callable([$service, $method])) {
            return [$service, $method];
        }

        return null;
    }
505269
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $appServiceLocator = $serviceLocator;
        if ($appServiceLocator instanceof AbstractPluginManager) {
            $appServiceLocator->getServiceLocator();
        }

        /** @var ObjectManagerAutoDetectorInterface $objectManagerAutoDetector */
        $objectManagerAutoDetector = $appServiceLocator->get(ObjectManagerAutoDetectorInterface::class);

        /** @var DoctrineObjectManagerInterface $objectManager */
        $objectManager = $appServiceLocator->get(DoctrineObjectManagerInterface::class);


        return new DoctrineObjectHydratorLocator($objectManagerAutoDetector, $objectManager);
    }
96235
protected function setDependency(ContainerInterface $serviceLocator, AbstractModel $model, $entity)
    {

        /** @var EntityManager $entityManager */
        $cacheStatus   = $serviceLocator->get('synergy\cache\status');
        $entityManager = $serviceLocator->get('doctrine.entitymanager.' . $model->getOrm());
        $config        = $serviceLocator->get('config');
        $site          = null;
        $filterName    = 'super_sites';

        if ($serviceLocator->has(AuthenticationService::class)) {
            /** @var AuthenticationService $authService */
            $authService = $serviceLocator->get(AuthenticationService::class);
            $identity    = $authService->hasIdentity();
            $model->setIdentity($authService->getIdentity());
        } else {
            $identity = false;
        }

        if (is_string($entity)) {
            $model->setEntity($entity);
        } elseif ($model instanceof BaseModel) {
            $model->setEntityInstance($entity);
            $model->setEntity(get_class($entity));
        }
        /** @var Site $site */
        if (!$model instanceof SiteModel) {
            $site = $serviceLocator->get('active\site');

            if ($site and in_array($site->getId(), $config['super_sites']) and
                $entityManager->getFilters()->has($filterName) and
                $entityManager->getFilters()->isEnabled($filterName)
            ) {
                $entityManager->getFilters()->disable($filterName);
            }
        }

        if ($site and $model instanceof LocaleAwareInterface) {
            if ($locale = $site->getLocale()) {
                $model->setLocale($locale);
            }
        }

        if ($model instanceof CacheAwareInterface) {
            $model->setCache('system\cache');
        }
        $enabled       = (!$identity and $cacheStatus->enabled);
        $cachedManager = new CachedEntityManager($entityManager, $enabled);

        $model->setEnableResultCache($enabled);
        $model->setLogger($serviceLocator->get('logger'));
        $model->setEntityManager($cachedManager);
        $model->setServiceLocator($serviceLocator);

        return $model;
    }
914141
public function findServiceByEndpoint($endpoint)
    {
        $url = $this->getNormalizedUrl($endpoint);

        foreach ($this->services as $service) {
            foreach ($service->getEndpoints() as $endpoint) {
                $endpointUrl = $this->getNormalizedUrl($endpoint->getPublicUrl());
                if (substr($url, 0, strlen($endpointUrl)) === $endpointUrl) {
                    return $service;
                }
            }
        }

        throw new \OutOfBoundsException(sprintf('There is no service for endpoint %s', $url));
    }
78294
protected function registerRuntimeConfiguration()
    {
        $propel_conf = $this->app->config['propel.propel'];

        if ( ! isset($propel_conf['runtime']['connections']) ) {
            throw new \InvalidArgumentException('Unable to guess Propel runtime config file. Please, initialize the "propel.runtime" parameter.');
        }

        /** @var $serviceContainer \Propel\Runtime\ServiceContainer\StandardServiceContainer */
        $serviceContainer = Propel::getServiceContainer();
        $serviceContainer->closeConnections();
        $serviceContainer->checkVersion('2.0.0-dev');

        $runtime_conf = $propel_conf['runtime'];

        // set connections
        foreach ($runtime_conf['connections'] as $connection_name) {
            $config = $propel_conf['database']['connections'][$connection_name];

            $serviceContainer->setAdapterClass($connection_name, $config['adapter']);
            $manager = new ConnectionManagerSingle();
            $manager->setConfiguration($config + [$propel_conf['paths']]);
            $manager->setName($connection_name);
            $serviceContainer->setConnectionManager($connection_name, $manager);
        }

        $serviceContainer->setDefaultDatasource($runtime_conf['defaultConnection']);

        // set loggers
        $has_default_logger = false;
        if ( isset($runtime_conf['log']) ) {
            $has_default_logger = array_key_exists('defaultLogger', $runtime_conf['log']);
            foreach ($runtime_conf['log'] as $logger_name => $logger_conf) {
                $serviceContainer->setLoggerConfiguration($logger_name, $logger_conf);
            }
        }

        if ( ! $has_default_logger) {
            $serviceContainer->setLogger('defaultLogger', app()->log->getLogger());
        }

        Propel::setServiceContainer($serviceContainer);
    }
639172
public function import()
    {
        switch ($this->serviceGroupType) {
            case ServiceTypeGroups::DATABASE:
                $header = $this->getHeader();
                if ($this->createDbTableFromHeader($header)) {
                    try {
                        $this->importData();

                        return true;
                    } catch (\Exception $e) {
                        $this->revert();

                        throw $e;
                    }
                }
                break;
            default:
                throw new BadRequestException(
                    'Importing resource(s) to service type group [' . $this->serviceGroupType . '] ' .
                    'is not currently supported.'
                );
        }
    }
257238
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('BjyAuthorize\Config');

        if (! isset($config['role_providers']['BjyAuthorize\Provider\Role\ObjectRepositoryProvider'])) {
            throw new InvalidArgumentException(
                'Config for "BjyAuthorize\Provider\Role\ObjectRepositoryProvider" not set'
            );
        }

        $providerConfig = $config['role_providers']['BjyAuthorize\Provider\Role\ObjectRepositoryProvider'];

        if (! isset($providerConfig['role_entity_class'])) {
            throw new InvalidArgumentException('role_entity_class not set in the bjyauthorize role_providers config.');
        }

        if (! isset($providerConfig['object_manager'])) {
            throw new InvalidArgumentException('object_manager not set in the bjyauthorize role_providers config.');
        }

        /* @var $objectManager \Doctrine\Common\Persistence\ObjectManager */
        $objectManager = $serviceLocator->get($providerConfig['object_manager']);

        return new ObjectRepositoryProvider($objectManager->getRepository($providerConfig['role_entity_class']));
    }
7914
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $appServiceLocator = $serviceLocator;
        if ($serviceLocator instanceof AbstractPluginManager) {
            $appServiceLocator = $serviceLocator->getServiceLocator();
        }

        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */
        $moduleOptionsPluginManager = $appServiceLocator->get(ModuleOptionsPluginManagerInterface::class);


        $creationOptions = $this->getCreationOptions();
        $options = is_array($creationOptions) ? $creationOptions : [];

        $contextMap = array_key_exists('contextMap', $options) ? $options['contextMap'] : [];

        $className = array_key_exists('className', $options) ? (string)$options['className'] : static::$defaultTargetClassName;

        $r = new ReflectionClass($className);
        $resolverByModuleContextMap = $r->newInstance($moduleOptionsPluginManager);

        if (!$resolverByModuleContextMap instanceof static::$defaultTargetClassName) {
            $errMsg = sprintf('ResolverByModuleContextMap not implements: %s', static::$defaultTargetClassName);
            throw new Exception\RuntimeException($errMsg);
        }

        $resolverByModuleContextMap->setContextMap($contextMap);

        return $resolverByModuleContextMap;
    }
71734
public function load($resource, $type = null)
    {
        if (!preg_match('/^[^\:]+(?:::?(?:[^\:]+))?$/', $resource)) {
            throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the "service" route loader: use the format "service::method" or "service" if your service has an "__invoke" method.', $resource));
        }

        if (1 === substr_count($resource, ':')) {
            $resource = str_replace(':', '::', $resource);
            @trigger_error(sprintf('Referencing service route loaders with a single colon is deprecated since Symfony 4.1. Use %s instead.', $resource), E_USER_DEPRECATED);
        }

        $parts = explode('::', $resource);
        $serviceString = $parts[0];
        $method = $parts[1] ?? '__invoke';

        $loaderObject = $this->getServiceObject($serviceString);

        if (!\is_object($loaderObject)) {
            throw new \LogicException(sprintf('%s:getServiceObject() must return an object: %s returned', \get_class($this), \gettype($loaderObject)));
        }

        if (!\is_callable([$loaderObject, $method])) {
            throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, \get_class($loaderObject), $resource));
        }

        $routeCollection = $loaderObject->$method($this);

        if (!$routeCollection instanceof RouteCollection) {
            $type = \is_object($routeCollection) ? \get_class($routeCollection) : \gettype($routeCollection);

            throw new \LogicException(sprintf('The %s::%s method must return a RouteCollection: %s returned', \get_class($loaderObject), $method, $type));
        }

        // make the service file tracked so that if it changes, the cache rebuilds
        $this->addClassResource(new \ReflectionClass($loaderObject), $routeCollection);

        return $routeCollection;
    }
463597
public function injectWidgetDependencies(WidgetInterface $widget, ServiceLocatorInterface $serviceLocator)
    {
        /** @var $serviceLocator \yimaWidgetator\Service\WidgetManager */
        $sm = $serviceLocator->getServiceLocator();
        if (!$sm)
            throw new \Exception('Service Manager can`t found.');

        /**
         * MVC Widget
         */
        if ($widget instanceof ViewRendererPlugInterface) {
            if (! $sm->has('ViewRenderer'))
                throw new \Exception('ViewRenderer service not found on Service Manager.');

            $widget->setView($sm->get('ViewRenderer'));
        }

        if ($widget instanceof iInitableWidgetFeature) {
            // widget initialize himself after all
            $widget->init();
        }

        /*if ($widget instanceof AbstractWidget) {
            // register widget in service locator with own unique id
            $sl = $this->getServiceLocator();
            $sl->setService($widget->getID(), $widget);
        }*/
    }
520254
public function loadConfiguration(): void
	{
		if (!class_exists('Symfony\Component\Console\Application')) {
			throw new ServiceCreationException('Missing Symfony\Component\Console\Application service');
		}

		// Skip if it's not CLI mode
		if (!$this->cliMode) return;

		$builder = $this->getContainerBuilder();

		// Helpers
		$builder->addDefinition($this->prefix('connectionHelper'))
			->setFactory(ConnectionHelper::class)
			->setAutowired(false);

		//Commands
		$builder->addDefinition($this->prefix('importCommand'))
			->setFactory(ImportCommand::class)
			->addTag('console.command', 'dbal:import')
			->setAutowired(false);

		$builder->addDefinition($this->prefix('reservedWordsCommand'))
			->setFactory(ReservedWordsCommand::class)
			->addTag('console.command', 'dbal:reserved-words')
			->setAutowired(false);

		$builder->addDefinition($this->prefix('runSqlCommand'))
			->setFactory(RunSqlCommand::class)
			->addTag('console.command', 'dbal:run-sql')
			->setAutowired(false);
	}
155827
public function get($primaryKey, $secondaryKey)
    {
        if (!isset($this->values[$primaryKey][$secondaryKey])) {
            throw new OutOfBoundsException(sprintf(
                'The key ("%s","%s") does not exist.',
                $primaryKey,
                $secondaryKey
            ));
        }

        return $this->values[$primaryKey][$secondaryKey];
    }
1229777
private function resolveParameterWithoutConfigService(ContainerInterface $container, $requestedName)
    {
        /**
         * @param ReflectionParameter $parameter
         * @return mixed
         * @throws ServiceNotFoundException If type-hinted parameter cannot be
         *   resolved to a service in the container.
         */
        return function (ReflectionParameter $parameter) use ($container, $requestedName) {
            return $this->resolveParameter($parameter, $container, $requestedName);
        };
    }
336992
public function getEntityService()
    {
        if (null === $this->entityService) {
            $entityServiceClass = $this->getEntityServiceClass();
            if (!class_exists($entityServiceClass)) {
                throw new \RuntimeException("Classe $entityServiceClass inexistente!");
            }
            $this->entityService = new $entityServiceClass();
            $this->entityService->setServiceLocator($this->getServiceLocator());
        }

        return $this->entityService;
    }