‪TYPO3CMS  9.5
ApplicationContext.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
36 {
42  protected ‪$contextString;
43 
49  protected ‪$rootContextString;
50 
56  protected ‪$parentContext;
57 
64  public function ‪__construct(‪$contextString)
65  {
66  if (strpos(‪$contextString, '/') === false) {
67  $this->rootContextString = ‪$contextString;
68  $this->parentContext = null;
69  } else {
70  $contextStringParts = explode('/', ‪$contextString);
71  $this->rootContextString = $contextStringParts[0];
72  array_pop($contextStringParts);
73  $this->parentContext = new self(implode('/', $contextStringParts));
74  }
75 
76  if (!in_array($this->rootContextString, ['Development', 'Production', 'Testing'], true)) {
77  throw new ‪Exception('The given context "' . ‪$contextString . '" was not valid. Only allowed are Development, Production and Testing, including their sub-contexts', 1335436551);
78  }
79 
80  $this->contextString = ‪$contextString;
81  }
82 
88  public function ‪__toString()
89  {
91  }
92 
98  public function ‪isDevelopment()
99  {
100  return $this->rootContextString === 'Development';
101  }
102 
108  public function ‪isProduction()
109  {
110  return $this->rootContextString === 'Production';
111  }
112 
118  public function ‪isTesting()
119  {
120  return $this->rootContextString === 'Testing';
121  }
122 
128  public function ‪getParent()
129  {
131  }
132 }
‪TYPO3\CMS\Core\Core\ApplicationContext\$parentContext
‪TYPO3 CMS Core Core ApplicationContext $parentContext
Definition: ApplicationContext.php:53
‪TYPO3\CMS\Core\Core\ApplicationContext
Definition: ApplicationContext.php:36
‪TYPO3\CMS\Core\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Core\Exception
‪TYPO3\CMS\Core\Core\ApplicationContext\isProduction
‪bool isProduction()
Definition: ApplicationContext.php:105
‪TYPO3\CMS\Core\Core\ApplicationContext\isTesting
‪bool isTesting()
Definition: ApplicationContext.php:115
‪TYPO3\CMS\Core\Core\ApplicationContext\$rootContextString
‪string $rootContextString
Definition: ApplicationContext.php:47
‪TYPO3\CMS\Core\Core\ApplicationContext\__toString
‪string __toString()
Definition: ApplicationContext.php:85
‪TYPO3\CMS\Core\Core\ApplicationContext\$contextString
‪string $contextString
Definition: ApplicationContext.php:41
‪TYPO3\CMS\Core\Core\ApplicationContext\getParent
‪TYPO3 CMS Core Core ApplicationContext getParent()
Definition: ApplicationContext.php:125
‪TYPO3\CMS\Core\Core\ApplicationContext\isDevelopment
‪bool isDevelopment()
Definition: ApplicationContext.php:95
‪TYPO3\CMS\Core\Core
Definition: ApplicationContext.php:2
‪TYPO3\CMS\Core\Core\ApplicationContext\__construct
‪__construct($contextString)
Definition: ApplicationContext.php:61