Determine the root provider name from the container.

@param ContainerInterface $container The container from where the name shall be retrieved.

@return string

@throws DcGeneralRuntimeException If the root provider can not be determined.
502364
protected function getRootProviderName(ContainerInterface $container)
    {
        $rootProvider = $container->getBasicDefinition()->getRootDataProvider();

        if (!$rootProvider) {
            throw new DcGeneralRuntimeException(
                'Root data provider name not specified in DCA but rootEntries section specified.'
            );
        }

        if (!$container->getDataProviderDefinition()->hasInformation($rootProvider)) {
            throw new DcGeneralRuntimeException('Unknown root data provider but rootEntries section specified.');
        }

        return $rootProvider;
    }
172623
private function getCommandsFolder(ContainerInterface $container): string
    {
        assert($container->has(CacheSettingsProviderInterface::class));

        /** @var CacheSettingsProviderInterface $provider */
        $provider  = $container->get(CacheSettingsProviderInterface::class);
        $appConfig = $provider->getApplicationConfiguration();
        $folder    = $appConfig[S::KEY_COMMANDS_FOLDER];

        return $folder;
    }
138880
private function initAdmingeneratorClassLoader(ContainerInterface $container)
    {
        if (!$this->classLoaderInitialized) {
            $this->classLoaderInitialized = true;

            $AdmingeneratedClassLoader = new AdmingeneratedClassLoader();
            $AdmingeneratedClassLoader->setBasePath($container->getParameter('kernel.cache_dir'));
            $AdmingeneratedClassLoader->register();
        }
    }
544673
public function findRootContainer() : DelegateInterface
    {
        $obj = $this;
        while($obj->hasParent() === true) {
            $obj = $obj->getParent();
        }
        return $obj;
    }
254631
protected function loadAdditionalDefinitions(ContainerInterface $container)
    {
        if (null !== $this->getFromDca('dca_config/data_provider')) {
            $dataContainerName = $container->getName();
            $this->getDispatcher()->addListener(
                PopulateEnvironmentEvent::NAME,
                function (PopulateEnvironmentEvent $event) use ($dataContainerName) {
                    $environment = $event->getEnvironment();
                    $definition  = $environment->getDataDefinition();
                    if ($definition->getName() !== $dataContainerName) {
                        return;
                    }

                    $parentName = $definition->getBasicDefinition()->getParentDataProvider();
                    if ($parentName) {
                        if ($parentName === $definition->getName()) {
                            $parentDefinition = $definition;
                        } else {
                            $parentDefinition = (new DcGeneralFactory())
                                ->setEventDispatcher($environment->getEventDispatcher())
                                ->setTranslator($environment->getTranslator())
                                ->setContainerName($parentName)
                                ->createDcGeneral()
                                ->getEnvironment()
                                ->getDataDefinition();
                        }
                        $environment->setParentDataDefinition($parentDefinition);
                    }

                    $rootName = $definition->getBasicDefinition()->getRootDataProvider();
                    if ($rootName) {
                        if ($rootName === $definition->getName()) {
                            $rootDefinition = $definition;
                        } else {
                            $rootDefinition = (new DcGeneralFactory())
                                ->setEventDispatcher($environment->getEventDispatcher())
                                ->setTranslator($environment->getTranslator())
                                ->setContainerName($rootName)
                                ->createDcGeneral()
                                ->getEnvironment()
                                ->getDataDefinition();
                        }

                        $environment->setRootDataDefinition($rootDefinition);
                    }
                }
            );
        }
    }
799741
private static function invalidRequestHandler(ContainerInterface $container): InvalidRequestHandlerInterface
    {
        if (!$container->has(InvalidRequestHandlerInterface::class)) {
            return new InvalidRequestHandler();
        }

        return $container->get(InvalidRequestHandlerInterface::class);
    }
698878
public function locateFilterRegistry(ContainerBuilder $container, $registryId)
    {
        if ( ! $container->hasDefinition($registryId)) {
            $definition = new Definition();
            $definition->setClass('Spray\PersistenceBundle\FilterLocator\FilterRegistry');
            $container->setDefinition($registryId, $definition);
        }
        return $container->getDefinition($registryId);
    }
1154437
public function pathResolvable(Container $container)
    {
        $event = $this->loadEventFromPath($container);
        return ($event instanceof EventInterface) && $event->id();
    }
1267569
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition($this->pathReducerService)) {
            return;
        }

        if (!$pathReducers = $this->findTaggedServices($container, $this->pathReducerTag, PluginInterface::class, 'getName')) {
            throw new RuntimeException(sprintf('You must tag at least one service as "%s" to use the "%s" service.', $this->pathReducerTag, $this->pathReducerService));
        }

        $pathReducerDefinition = $container->getDefinition($this->pathReducerService);
        $pathReducerDefinition->replaceArgument(0, $pathReducers);
    }
524817
protected function parseDataProvider(ContainerInterface $container)
    {
        if ($container->hasDataProviderDefinition()) {
            $config = $container->getDataProviderDefinition();
        } else {
            $config = new DefaultDataProviderDefinition();
            $container->setDataProviderDefinition($config);
        }

        // If mode is 5, we need to define tree view.
        if ((5 === $this->getFromDca('list/sorting/mode'))
            && !$container->getBasicDefinition()->getRootDataProvider()
        ) {
            $container->getBasicDefinition()->setRootDataProvider($container->getName());
        }

        if (null !== ($parentTable = $this->getFromDca('config/ptable'))) {
            // Check config if it already exists, if not, add it.
            if (!$config->hasInformation($parentTable)) {
                $providerInformation = new ContaoDataProviderInformation();
                $providerInformation->setName($parentTable);
                $config->addInformation($providerInformation);
            } else {
                $providerInformation = $config->getInformation($parentTable);
            }

            if ($providerInformation instanceof ContaoDataProviderInformation) {
                $initializationData = (array) $providerInformation->getInitializationData();

                $providerInformation
                    ->setTableName($parentTable)
                    ->setInitializationData(
                        \array_merge(
                            [
                                'source' => $parentTable,
                                'name'   => $parentTable,
                            ],
                            $initializationData
                        )
                    );

                if (!$container->getBasicDefinition()->getRootDataProvider()) {
                    $container->getBasicDefinition()->setRootDataProvider($parentTable);
                }
                if (!$container->getBasicDefinition()->getParentDataProvider()) {
                    $container->getBasicDefinition()->setParentDataProvider($parentTable);
                }
            }
        }

        $providerName = $container->getBasicDefinition()->getDataProvider() ?: $container->getName();

        // Check config if it already exists, if not, add it.
        if (!$config->hasInformation($providerName)) {
            $providerInformation = new ContaoDataProviderInformation();
            $providerInformation->setName($providerName);
            $config->addInformation($providerInformation);
        } else {
            $providerInformation = $config->getInformation($providerName);
        }

        if ($providerInformation instanceof ContaoDataProviderInformation) {
            $initializationData = (array) $providerInformation->getInitializationData();

            if (!isset($initializationData['source'])) {
                $providerInformation
                    ->setTableName($providerName)
                    ->setInitializationData(
                        \array_merge(
                            [
                                'source' => $providerName,
                                'name'   => $providerName
                            ],
                            $initializationData
                        )
                    );
            }
            $providerInformation
                ->setVersioningEnabled((bool) $this->getFromDca('config/enableVersioning'));

            if (!$container->getBasicDefinition()->getDataProvider()) {
                $container->getBasicDefinition()->setDataProvider($providerName);
            }
        }
    }
502050
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition($this->generatorService)) {
            return;
        }

        if (!$generators = $this->findTaggedServices($container, $this->generatorTag, PluginInterface::class, 'getName')) {
            throw new RuntimeException(sprintf('You must tag at least one service as "%s" to use the "%s" service.', $this->generatorTag, $this->generatorService));
        }

        $generatorDefinition = $container->getDefinition($this->generatorService);
        $generatorDefinition->replaceArgument(0, $generators);
    }
651845
private function getRedisConfig(ContainerInterface $container)
    {
        if (!$container->has('config')) {
            return [];
        }

        $config = $container->get('config');

        if (!isset($config['doctrine']['cache']['redis'])) {
            return [];
        }

        return $config['doctrine']['cache']['redis'];
    }
1262339
public function getContainer()
    {
        if (property_exists(__CLASS__, 'container')) {
            return $this->container;
        } else {
            return parent::getContainer();
        }

        throw new RuntimeException(sprintf('The service container must be accessible from class %s to use this trait', __CLASS__));
    }
696192
public function getDataProvider($source = null)
    {
        if (null === $source) {
            $source = $this->getDataDefinition()->getBasicDefinition()->getDataProvider();
        }

        if (isset($this->arrDataProvider[$source])) {
            return $this->arrDataProvider[$source];
        }

        throw new DcGeneralRuntimeException(\sprintf('Data provider %s not defined', $source));
    }
526361
protected function getRealClassName(ContainerBuilder $container, $classname)
    {
        return 0 === strpos($classname, '%') ? $container->getParameter(trim($classname, '%')) : $classname;
    }
1215556
public function createDcGeneral()
    {
        if (empty($this->containerName) && !$this->dataContainer) {
            throw new DcGeneralRuntimeException('Required container name or container is missing');
        }

        if (null === $this->eventDispatcher) {
            throw new DcGeneralRuntimeException('Required event dispatcher is missing');
        }

        // Backwards compatibility.
        $this->getEventDispatcher()->dispatch(PreCreateDcGeneralEvent::NAME, new PreCreateDcGeneralEvent($this));

        $environment = $this->environment ?: $this->createEnvironment();

        /** @var DcGeneral $dcGeneral */
        $dcGeneral = (new \ReflectionClass($this->dcGeneralClassName))->newInstance($environment);

        // Backwards compatibility.
        $this->getEventDispatcher()->dispatch(CreateDcGeneralEvent::NAME, new CreateDcGeneralEvent($dcGeneral));

        return $dcGeneral;
    }
5745
private function getSettings(ContainerInterface $container): array
    {
        $appConfig = null;

        /** @var CacheSettingsProviderInterface $settingsProvider */
        if ($container->has(CacheSettingsProviderInterface::class) === true &&
            ($settingsProvider = $container->get(CacheSettingsProviderInterface::class)) !== null
        ) {
            $appConfig = $settingsProvider->getApplicationConfiguration();
        }

        return [
            $appConfig[A::KEY_IS_DEBUG] ?? false,
            $appConfig[A::KEY_APP_NAME] ?? null,
            $appConfig[A::KEY_EXCEPTION_DUMPER] ?? null,
        ];
    }