‪TYPO3CMS  ‪main
CurrentObjectPathStack.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
28 {
32  private array ‪$stack = [];
33  private int ‪$stackSize = 0;
34 
35  public function ‪push(‪CurrentObjectPath ‪$path): void
36  {
37  $this->stack[] = ‪$path;
38  $this->stackSize++;
39  }
40 
41  public function ‪pop(): ‪CurrentObjectPath
42  {
43  if ($this->stackSize === 1) {
44  // Never pop the very last element off from the stack. This is the
45  // RootNode. This prevents errors when TypoScript has a closing
46  // curly bracket '}' too much.
47  return $this->‪getCurrent();
48  }
49  array_pop($this->stack);
50  $this->stackSize--;
51  return $this->‪getCurrent();
52  }
53 
55  {
56  return $this->stack[array_key_last($this->stack)];
57  }
58 
59  public function ‪getFirst(): ‪CurrentObjectPath
60  {
61  return reset($this->stack);
62  }
63 }
‪TYPO3\CMS\Core\TypoScript\AST\CurrentObjectPath\CurrentObjectPathStack\$stackSize
‪int $stackSize
Definition: CurrentObjectPathStack.php:33
‪TYPO3\CMS\Core\TypoScript\AST\CurrentObjectPath\CurrentObjectPathStack\getFirst
‪getFirst()
Definition: CurrentObjectPathStack.php:59
‪TYPO3\CMS\Core\TypoScript\AST\CurrentObjectPath
Definition: CurrentObjectPath.php:18
‪TYPO3\CMS\Core\TypoScript\AST\CurrentObjectPath\CurrentObjectPathStack
Definition: CurrentObjectPathStack.php:28
‪TYPO3\CMS\Core\TypoScript\AST\CurrentObjectPath\CurrentObjectPathStack\pop
‪pop()
Definition: CurrentObjectPathStack.php:41
‪TYPO3\CMS\Core\TypoScript\AST\CurrentObjectPath\CurrentObjectPathStack\getCurrent
‪getCurrent()
Definition: CurrentObjectPathStack.php:54
‪TYPO3\CMS\Core\TypoScript\AST\CurrentObjectPath\CurrentObjectPathStack\push
‪push(CurrentObjectPath $path)
Definition: CurrentObjectPathStack.php:35
‪TYPO3\CMS\Core\TypoScript\AST\CurrentObjectPath\CurrentObjectPath
Definition: CurrentObjectPath.php:32
‪TYPO3\CMS\Core\TypoScript\AST\CurrentObjectPath\CurrentObjectPathStack\$stack
‪array $stack
Definition: CurrentObjectPathStack.php:32
‪TYPO3\CMS\Core\TypoScript\AST\CurrentObjectPath\CurrentObjectPath\$path
‪array $path
Definition: CurrentObjectPath.php:36