@param ContainerInterface $container
@param string             $settingsClass

@return array

@throws ContainerExceptionInterface
@throws NotFoundExceptionInterface
553879
protected static function getSettings(ContainerInterface $container, string $settingsClass): array
    {
        /** @var SettingsProviderInterface $provider */
        $provider = $container->get(SettingsProviderInterface::class);
        $settings = $provider->get($settingsClass);

        return $settings;
    }
193192
public function applyContext(ContainerBuilder $container)
    {
        $definition = $container->findDefinition('sonata.block.context_manager');

        foreach ($container->getParameter('sonata_block.blocks') as $service => $settings) {
            if (\count($settings['settings']) > 0) {
                $definition->addMethodCall('addSettingsByType', [$service, $settings['settings'], true]);
            }
        }
        foreach ($container->getParameter('sonata_block.blocks_by_class') as $class => $settings) {
            if (\count($settings['settings']) > 0) {
                $definition->addMethodCall('addSettingsByClass', [$class, $settings['settings'], true]);
            }
        }
    }
803491
protected function buildCondition(ContainerInterface $container)
    {
        if (!$condition = $container->getCondition()) {
            throw new ContainerException('Condition is empty');
        }

        $suffix = count($this->parameters) + 1;
        $condition->reconfigureParameters($suffix);

        if ($condition->isAggregateFunction()) {
            $where = $this->aggregate($condition);
        } else {
            $where = $condition->buildCondition();
            $this->addParameter($condition->getParameters());
        }
        if (!$where = $this->trimAndOr($where)) {
            return null;
        }

        return sprintf(
            '%s%s',
            $container->getAndOr() ? sprintf(' %s ', $container->getAndOr()) : null,
            $where
        );
    }
1056222
private function getSettingsFromRepository(SettingsOwnerInterface $owner = null)
    {
        $settings = array();

        foreach (array_keys($this->settingsConfiguration) as $name) {
            try {
                $this->validateSetting($name, $owner);
                $settings[$name] = null;
            } catch (WrongScopeException $e) {
                continue;
            }
        }

        /** @var Setting $setting */
        foreach ($this->repository->findBy(
            array('ownerId' => $owner === null ? null : $owner->getSettingIdentifier())
        ) as $setting) {
            if (array_key_exists($setting->getName(), $settings)) {
                $settings[$setting->getName()] = $this->serializer->unserialize($setting->getValue());
            }
        }

        return $settings;
    }
1372355
protected function createContainer(Composer $composer): ContainerInterface
    {
        // use application auto loader otherwise no app classes will be visible for us
        $autoLoaderPath = $this->getAutoloadPath($composer);
        if (file_exists($autoLoaderPath) === true) {
            /** @noinspection PhpIncludeInspection */
            require_once $autoLoaderPath;
        }

        $extra    = $this->getExtra($composer);
        $appKey   = CommandConstants::COMPOSER_JSON__EXTRA__APPLICATION;
        $classKey = CommandConstants::COMPOSER_JSON__EXTRA__APPLICATION__CLASS;
        $appClass = $extra[$appKey][$classKey] ?? CommandConstants::DEFAULT_APPLICATION_CLASS_NAME;
        if ($this->isValidApplicationClass($appClass) === false) {
            $settingsPath = "extra->$appKey->$classKey";
            throw new ConfigurationException(
                "Invalid application class specified '$appClass'. Check your settings at composer.json $settingsPath."
            );
        }

        $container = $this->createApplication($appClass)->createContainer();

        return $container;
    }
1029428
protected static function defaultCreateDataParser(
        ContainerInterface $container,
        string $rulesClass
    ): JsonApiDataParserInterface {
        static::assertClassImplements($rulesClass, JsonApiDataRulesInterface::class);

        /** @var JsonApiParserFactoryInterface $factory */
        $factory = $container->get(JsonApiParserFactoryInterface::class);
        $parser  = $factory->createDataParser($rulesClass);

        return $parser;
    }
429688
public function getDispatcherFactory(ContainerInterface $container): DispatcherFactoryInterface
    {
        $autowired = $container->get('ellipse.dispatcher.autowiring.status');

        if ($autowired) {

            $interfaces = $container->get('ellipse.dispatcher.autowiring.interfaces');

            $container = new ReflectionContainer($container, $interfaces);

        }

        return new DefaultResolver($container);
    }
1124728
protected static function defaultCreateParameterMapper(
        ContainerInterface $container,
        string $schemaClass
    ): ParametersMapperInterface {
        static::assertClassImplements($schemaClass, SchemaInterface::class);

        /** @var SchemaInterface $schemaClass */
        $jsonResourceType = $schemaClass::TYPE;

        /** @var ParametersMapperInterface $mapper */
        $mapper = $container->get(ParametersMapperInterface::class);
        $mapper->selectRootSchemaByResourceType($jsonResourceType);

        return $mapper;
    }
137134
protected function parseDataProvider(ContainerInterface $container)
    {
        // Parse data provider.
        if ($container->hasDataProviderDefinition()) {
            $config = $container->getDataProviderDefinition();
        } else {
            $config = new DefaultDataProviderDefinition();
            $container->setDataProviderDefinition($config);
        }

        // First check if we are using the "new" notation used in DcGeneral 0.9.
        if (!\is_array($this->getFromDca('dca_config/data_provider'))) {
            return;
        }

        $dataProvidersDca = $this->getFromDca('dca_config/data_provider');

        foreach ($dataProvidersDca as $dataProviderDcaName => $dataProviderDca) {
            $providerInformation = $this->parseSingleDataProvider(
                $container,
                $config,
                $dataProviderDca,
                $dataProviderDcaName
            );

            if ($providerInformation instanceof ContaoDataProviderInformation) {
                $initializationData     = (array) $providerInformation->getInitializationData();
                $baseInitializationData = [
                    'name' => $dataProviderDcaName
                ];

                switch ((string) $dataProviderDcaName) {
                    case 'default':
                        $providerInformation->setVersioningEnabled(
                            (bool) $this->getFromDca('config/enableVersioning')
                        );

                        $container->getBasicDefinition()->setDataProvider($providerInformation->getName());
                        $baseInitializationData['name'] = $providerInformation->getName();
                        break;

                    case 'root':
                        $container->getBasicDefinition()->setRootDataProvider($providerInformation->getName());
                        $baseInitializationData['name'] = $providerInformation->getName();
                        break;

                    case 'parent':
                        $container->getBasicDefinition()->setParentDataProvider($providerInformation->getName());
                        $baseInitializationData['name'] = $providerInformation->getName();
                        break;

                    default:
                }

                $providerInformation->setInitializationData(
                    \array_merge(
                        $baseInitializationData,
                        $dataProviderDca,
                        $initializationData
                    )
                );
            }
        }
    }
614790
private function createMigration(string $class, ContainerInterface $container): ?MigrationInterface
    {
        $migration = null;

        try {
            /** @var MigrationInterface $migration */
            $migration = new $class($container);
        } catch (Error $exception) {
            $this->getIO()->writeWarning("Migration `$class` not found." . PHP_EOL);
        }

        return $migration;
    }
228178
public static function setup(Settings $settings, ConnectionInterface $connection = null)
    {
        return static::getInstance($settings)->load($connection);
    }
797197
public function setContainer(ContainerInterface $container)
    {
        $application = $this;
        $container->share(ApplicationInterface::class, $application);
        $container->share(\Interop\Container\ContainerInterface::class, $container);

        $this->container = $container;

        return $this;
    }
661447
private function throwExceptionIfNotInstantiable($class, $reflectionClass)
    {
        /*
         * Check if reflection class is not instantiable then throw ContainerException
         */
        if (!$reflectionClass->isInstantiable()) {
            $type = ($this->reflection->getReflectionClass()->isInterface() ? 'interface' : 'class');
            throw new ContainerException("Cannot instantiate $type $class");
        }
    }
308861
protected function loadInstanceFromContainer($containerClass) {
        $this->containerInstance = $this->loadIntermediateContainerInstance($containerClass);

        try {
            $this->instance = $this->containerInstance->getInstance();
        } catch (BadConfigurationException $e) {
            $e = new ServiceException($e->getMessage(), $e->getCode(), $e);
            $e->setServiceName($this->serviceName);
            throw $e;
        }
    }
1136447
private function selectChildSettingsAmongTwo(
        SettingsInterface $instance1,
        SettingsInterface $instance2
    ): ?SettingsInterface {
        return is_subclass_of($instance1, get_class($instance2)) === true ?
            $instance1 : (is_subclass_of($instance2, get_class($instance1)) === true ? $instance2 : null);
    }
757243
private static function getTokenStorage(ContainerInterface $container): CsrfTokenStorageInterface
    {
        assert($container->has(CsrfTokenStorageInterface::class) === true);
        /** @var CsrfTokenStorageInterface $csrfStorage */
        $csrfStorage = $container->get(CsrfTokenStorageInterface::class);

        return $csrfStorage;
    }
109410
protected static function ctxGetContainer(ContextInterface $context): ContainerInterface
    {
        assert(static::ctxHasContainer($context));

        return $context->get(ContextProperties::CTX_CONTAINER);
    }