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.');
    }
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.');
    }
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.' ) ; }
Determine the symfony container.

@return ContainerInterface|null

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

@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName)
Determine the symfony container .