Determine the symfony container.

@return ContainerInterface|null

@throws \RuntimeException When the container can not be obtained.

@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName)
482327
private function getSymfonyContainer()
    {
        // 1. Preferred way in contao 4.0+
        if (method_exists('Contao\System', 'getContainer')
            && ($container = System::getContainer()) instanceof ContainerInterface
        ) {
            return $container;
        }

        // 2. Fallback to fetch from kernel.
        if (isset($GLOBALS['kernel'])
            && $GLOBALS['kernel'] instanceof KernelInterface
            && ($container = $GLOBALS['kernel']->getContainer()) instanceof ContainerInterface
        ) {
            return $container;
        }

        // 3. Nothing worked out, throw Exception as this may never happen.
        throw new \RuntimeException('Could not obtain symfony container.');
    }
579879
public static function getContainerInstance() : Container
    {
        if (self::$container === null) {
            self::$container = self::getUnboundContainerInstance();
        }

        return self::$container;
    }
406944
protected function getContainerBuilder()
    {
        if ($this->containerBuilder) {
            return $this->containerBuilder;
        }

        $kernel = $this->getApplication()->getKernel();

        if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) {
            $buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel));
            $container = $buildContainer();
        } else {
            (new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
            $container->setParameter('container.build_hash', $hash = ContainerBuilder::hash(__METHOD__));
            $container->setParameter('container.build_id', hash('crc32', $hash.time()));
        }

        $container->getCompilerPassConfig()->setRemovingPasses([]);
        $container->compile();

        return $this->containerBuilder = $container;
    }
1358691
public function getService($name = null)
    {
        $name = $name ?: $this->defaultService;

        if (!$name) {
            throw new \RuntimeException(sprintf(
                'You must configure a default %s service, registered %s services: "%s"',
                $this->serviceType, $this->serviceType,
                implode('", "', array_keys($this->services))
            ));
        }

        if (isset($this->services[$name])) {
            return $this->services[$name];
        }

        $this->assertServiceExists($name);
        $this->services[$name] = $this->container->get($this->serviceMap[$name]);

        return $this->services[$name];
    }
1056027
public static function get(ContainerInterface $container) {
    $storage_type = $container
      ->get('config.factory')
      ->get('acm.commerce_users')
      ->get('storage_type');

    switch ($storage_type) {
      case 'database_store':
        $storage = $container
          ->get('acm.database_session_store')
          ->get('acm');
        break;

      default:
        $storage = $container
          ->get('acm.php_session_store');
        break;
    }

    return $storage;
  }
83705
protected function initialiseContainer()
    {
        // @todo: add some form of container caching?
        $container = $this->buildContainer();
        $this->prepareContainer($container);

        $this->container = $container;
        return $this->container;
    }
54822
public static function getContainer($zendServiceManager = null)
    {
        if (!self::$container) {
            self::$container = new SymfonyContainerWithZFFallback();
        }

        if (!Module::$zendServiceManager && $zendServiceManager) {
            if ($zendServiceManager->has('serviceLocator')) {
                $zendServiceManager = $zendServiceManager->get('serviceLocator');
            }
            Module::$zendServiceManager = $zendServiceManager;
        }

        return self::$container;
    }
1063775
public static function getBootstrapContainer(): ContainerInterface
    {
        $symfonyContainer = new ContainerBuilder();
        $symfonyContainer->addCompilerPass(new RegisterListenersPass(EventDispatcherInterface::class));
        $loader = new YamlFileLoader($symfonyContainer, new \Symfony\Component\Config\FileLocator(__DIR__));
        $loader->load('..' . DIRECTORY_SEPARATOR . 'services.yaml');
        $symfonyContainer->compile();
        return $symfonyContainer;
    }
812715
public function getContainer(): Container
    {
        if (is_null($this->container)) {
            $this->container = $this->ui()->factory()->getContainer();
        }

        return $this->container;
    }
1366926
protected function buildContainer()
    {
        foreach (['cache' => $this->warmupDir ?: $this->getCacheDir(), 'logs' => $this->getLogDir()] as $name => $dir) {
            if (!is_dir($dir)) {
                if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
                    throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $dir));
                }
            } elseif (!is_writable($dir)) {
                throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir));
            }
        }

        $container = $this->getContainerBuilder();
        $container->addObjectResource($this);
        $this->prepareContainer($container);

        if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) {
            $container->merge($cont);
        }

        $container->addCompilerPass(new AddAnnotatedClassesToCachePass($this));

        return $container;
    }
1219249
public function getScope()
    {
        $scope = $this->getData('scope');

        if ($scope === null) {
            $scope = ContainerScopeInterface::SCOPE_DEFAULT;

            if ($this->getContainerCode()) {
                $scope = ContainerScopeInterface::SCOPE_CONTAINERS;
            }
            if ($this->getStoreCode()) {
                $scope = ContainerScopeInterface::SCOPE_STORE_CONTAINERS;
            }

            $this->setScope($scope);
        }

        return $scope;
    }
904160
public com.google.appengine.v1.ContainerInfo getContainer() {
    return container_ == null ? com.google.appengine.v1.ContainerInfo.getDefaultInstance() : container_;
  }
447940
protected function getContainer()
    {
        @trigger_error(sprintf('The "%s()" method is deprecated and will be removed in DoctrineBundle 2.0.', __METHOD__), E_USER_DEPRECATED);

        if ($this->container === null) {
            $application = $this->getApplication();
            if ($application === null) {
                throw new LogicException('The container cannot be retrieved as the application instance is not yet set.');
            }

            $this->container = $application->getKernel()->getContainer();
        }

        return $this->container;
    }
188071
public static function getContainer()
    {
        if (!(self::$container instanceof Container)) {
            self::$container = new Container();
            self::$container->load();
        }

        return self::$container;
    }
762564
public function getContainersAction() {
        $em = $this->getDoctrine()->getManager();

        // TODO : Check user access !

        $containers = $em->getRepository('InterneSeanceBundle:Container')->findAll();

        $view = $this->view($containers, Response::HTTP_OK);

        return $this->handleView($view);
    }
1103200
protected function getContainer()
    {
        if (!$this->container) {
            $kernel = new \AppKernel('prod', false);
            $kernel->boot();
            $this->container = $kernel->getContainer();
        }
        return $this->container;
    }
638947
public function getContainer()
    {
        if (is_null(self::$container)) {
            self::$container = $this->checkContainer();
        }
        return self::$container;
    }