/** * This initializes the Contao Singleton object stack as it must be, * when using singletons within the config.php file of an Extension. * * @return void */ protected static function initializeContaoObjectStack() { // all of these getInstance calls are neccessary to keep the instance stack intact // and therefore prevent an Exception in unknown on line 0. // Hopefully this will get fixed with Contao Reloaded or Contao 3. Config::getInstance(); Environment::getInstance(); Input::getInstance(); // request token became available in 2.11 if (version_compare(TL_VERSION, '2.11', '>=')) { RequestToken::getInstance(); } self::getUser(); Database::getInstance(); }
}; /** * Contao Encryption class as a service. * * @return Encryption */ $container[Services::ENCRYPTION] = function () { return Encryption::getInstance(); }; /** * Request token as service. * * @return RequestToken */ $container[Services::REQUEST_TOKEN] = $container->share(function () { return RequestToken::getInstance(); }); // --------------------------------------------------------------------------------------------------------------------- // Toolkit Dependency injection // // Toolkit provides an container implementation which based on container-interop/container-interop ContainerInterface. // Instead of access Pimple in user land code it's recommend to depend on ContainerInterface. Since Contao 4.x is // supported, an adapter to Symfony container based on ContainerInterface or the updated // contao-community-alliance/dependency-injection implementation will be provided. // --------------------------------------------------------------------------------------------------------------------- /** * Get the container. * * @return ContainerInterface */ $container[Services::CONTAINER] = $container->share(function ($container) {
@set_exception_handler('__exception'); /** * Log PHP errors */ @ini_set('error_log', TL_ROOT . '/system/logs/error.log'); /** * Start the session */ @session_start(); /** * Load the basic classes */ $objConfig = Config::getInstance(); $objEnvironment = Environment::getInstance(); $objInput = Input::getInstance(); $objToken = RequestToken::getInstance(); /** * Set error_reporting */ @ini_set('display_errors', $GLOBALS['TL_CONFIG']['displayErrors'] ? 1 : 0); error_reporting($GLOBALS['TL_CONFIG']['displayErrors'] || $GLOBALS['TL_CONFIG']['logErrors'] ? E_ALL | E_STRICT : 0); /** * Set the timezone */ @ini_set('date.timezone', $GLOBALS['TL_CONFIG']['timeZone']); @date_default_timezone_set($GLOBALS['TL_CONFIG']['timeZone']); /** * Define the relativ path to the Contao installation */ if ($GLOBALS['TL_CONFIG']['websitePath'] === null) { $path = preg_replace('/\\/contao\\/[^\\/]*$/i', '', $objEnvironment->requestUri);