‪TYPO3CMS  10.4
ApplicationContext.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 
37 {
43  protected ‪$contextString;
44 
50  protected ‪$rootContextString;
51 
57  protected ‪$parentContext;
58 
65  public function ‪__construct(‪$contextString)
66  {
67  if (strpos(‪$contextString, '/') === false) {
68  $this->rootContextString = ‪$contextString;
69  $this->parentContext = null;
70  } else {
71  $contextStringParts = explode('/', ‪$contextString);
72  $this->rootContextString = $contextStringParts[0];
73  array_pop($contextStringParts);
74  $this->parentContext = new self(implode('/', $contextStringParts));
75  }
76 
77  if (!in_array($this->rootContextString, ['Development', 'Production', 'Testing'], true)) {
78  throw new ‪Exception('The given context "' . ‪$contextString . '" was not valid. Only allowed are Development, Production and Testing, including their sub-contexts', 1335436551);
79  }
80 
81  $this->contextString = ‪$contextString;
82  }
83 
89  public function ‪__toString()
90  {
92  }
93 
99  public function ‪isDevelopment()
100  {
101  return $this->rootContextString === 'Development';
102  }
103 
109  public function ‪isProduction()
110  {
111  return $this->rootContextString === 'Production';
112  }
113 
119  public function ‪isTesting()
120  {
121  return $this->rootContextString === 'Testing';
122  }
123 
129  public function ‪getParent()
130  {
132  }
133 }
‪TYPO3\CMS\Core\Core\ApplicationContext\$parentContext
‪TYPO3 CMS Core Core ApplicationContext $parentContext
Definition: ApplicationContext.php:54
‪TYPO3\CMS\Core\Core\ApplicationContext
Definition: ApplicationContext.php:37
‪TYPO3\CMS\Core\Exception
‪TYPO3\CMS\Core\Core\ApplicationContext\isProduction
‪bool isProduction()
Definition: ApplicationContext.php:106
‪TYPO3\CMS\Core\Core\ApplicationContext\isTesting
‪bool isTesting()
Definition: ApplicationContext.php:116
‪TYPO3\CMS\Core\Core\ApplicationContext\$rootContextString
‪string $rootContextString
Definition: ApplicationContext.php:48
‪TYPO3\CMS\Core\Core\ApplicationContext\__toString
‪string __toString()
Definition: ApplicationContext.php:86
‪TYPO3\CMS\Core\Core\ApplicationContext\$contextString
‪string $contextString
Definition: ApplicationContext.php:42
‪TYPO3\CMS\Core\Core\ApplicationContext\getParent
‪TYPO3 CMS Core Core ApplicationContext getParent()
Definition: ApplicationContext.php:126
‪TYPO3\CMS\Core\Error\Exception
Definition: Exception.php:22
‪TYPO3\CMS\Core\Core\ApplicationContext\isDevelopment
‪bool isDevelopment()
Definition: ApplicationContext.php:96
‪TYPO3\CMS\Core\Core
Definition: ApplicationContext.php:16
‪TYPO3\CMS\Core\Core\ApplicationContext\__construct
‪__construct($contextString)
Definition: ApplicationContext.php:62