[FEATURE] Backport ApplicationContext from Flow
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Core / Bootstrap.php
index 54114ae..81e060d 100644 (file)
@@ -59,10 +59,21 @@ class Bootstrap {
        protected $requestId;
 
        /**
+        * The application context
+        *
+        * @var \TYPO3\CMS\Core\Core\ApplicationContext
+        */
+       protected $context;
+
+       /**
         * Disable direct creation of this object.
+        * Set unique requestId and the application context
+        *
+        * @var string Application context
         */
-       protected function __construct() {
+       protected function __construct($context) {
                $this->requestId = uniqid();
+               $this->context = new ApplicationContext($context);
        }
 
        /**
@@ -80,7 +91,9 @@ class Bootstrap {
         */
        static public function getInstance() {
                if (is_null(self::$instance)) {
-                       self::$instance = new \TYPO3\CMS\Core\Core\Bootstrap();
+                       require_once(__DIR__ . '/ApplicationContext.php');
+                       $context = trim(getenv('TYPO3_CONTEXT'), '"\' ') ? : 'Production';
+                       self::$instance = new \TYPO3\CMS\Core\Core\Bootstrap($context);
                }
                return self::$instance;
        }
@@ -96,6 +109,15 @@ class Bootstrap {
        }
 
        /**
+        * Returns the context this bootstrap was started in.
+        *
+        * @return \TYPO3\CMS\Core\Core\ApplicationContext The context encapsulated in an object
+        */
+       public function getContext() {
+               return $this->context;
+       }
+
+       /**
         * Prevent any unwanted output that may corrupt AJAX/compression.
         * This does not interfere with "die()" or "echo"+"exit()" messages!
         *