TYPO3 CMS  TYPO3_6-2
ApplicationContext.php
Go to the documentation of this file.
1 <?php
3 
36 
42  protected $contextString;
43 
49  protected $rootContextString;
50 
56  protected $parentContext;
57 
64  public function __construct($contextString) {
65  if (strstr($contextString, '/') === FALSE) {
66  $this->rootContextString = $contextString;
67  $this->parentContext = NULL;
68  } else {
69  $contextStringParts = explode('/', $contextString);
70  $this->rootContextString = $contextStringParts[0];
71  array_pop($contextStringParts);
72  $this->parentContext = new ApplicationContext(implode('/', $contextStringParts));
73  }
74 
75  if (!in_array($this->rootContextString, array('Development', 'Production', 'Testing'))) {
76  throw new \TYPO3\CMS\Core\Exception('The given context "' . $contextString . '" was not valid. Only allowed are Development, Production and Testing, including their sub-contexts', 1335436551);
77  }
78 
79  $this->contextString = $contextString;
80  }
81 
88  public function __toString() {
89  return $this->contextString;
90  }
91 
98  public function isDevelopment() {
99  return ($this->rootContextString === 'Development');
100  }
101 
109  public function isProduction() {
110  return ($this->rootContextString === 'Production');
111  }
112 
119  public function isTesting() {
120  return ($this->rootContextString === 'Testing');
121  }
122 
129  public function getParent() {
130  return $this->parentContext;
131  }
132 }