‪TYPO3CMS  11.5
Page.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 
23 class ‪Page implements \ArrayAccess
24 {
25  use ‪PropertyTrait;
26 
27  protected array ‪$specialPropertyNames = [
28  '_language',
29  '_LOCALIZED_UID',
30  '_MP_PARAM',
31  '_ORIG_uid',
32  '_ORIG_pid',
33  '_SHORTCUT_ORIGINAL_PAGE_UID',
34  '_PAGES_OVERLAY',
35  '_PAGES_OVERLAY_UID',
36  '_PAGES_OVERLAY_LANGUAGE',
37  '_PAGES_OVERLAY_REQUESTEDLANGUAGE',
38  ];
39 
40  protected array ‪$specialProperties = [];
41 
42  public function ‪__construct(array $properties)
43  {
44  foreach ($properties as $propertyName => $propertyValue) {
45  if (isset($this->specialPropertyNames[$propertyName])) {
46  $this->specialProperties[$propertyName] = $propertyValue;
47  } else {
48  $this->properties[$propertyName] = $propertyValue;
49  }
50  }
51  }
52 
53  public function ‪getLanguageId(): int
54  {
55  return $this->specialProperties['_language'] ?? $this->specialProperties['_PAGES_OVERLAY_LANGUAGE'] ?? $this->properties['sys_language_uid'];
56  }
57 
58  public function ‪getPageId(): int
59  {
60  $pageId = isset($this->properties['l10n_parent']) && $this->properties['l10n_parent'] > 0 ? $this->properties['l10n_parent'] : $this->properties['uid'];
61  return (int)$pageId;
62  }
63 
64  public function ‪toArray(): array
65  {
66  return $this->properties;
67  }
68 }
‪TYPO3\CMS\Core\Domain\Page\getPageId
‪getPageId()
Definition: Page.php:58
‪TYPO3\CMS\Core\Domain\Page
Definition: Page.php:24
‪TYPO3\CMS\Core\Domain\Page\$specialProperties
‪array $specialProperties
Definition: Page.php:40
‪TYPO3\CMS\Core\Domain\PropertyTrait
Definition: PropertyTrait.php:24
‪TYPO3\CMS\Core\Domain
Definition: Page.php:18
‪TYPO3\CMS\Core\Domain\Page\toArray
‪toArray()
Definition: Page.php:64
‪TYPO3\CMS\Core\Domain\Page\getLanguageId
‪getLanguageId()
Definition: Page.php:53
‪TYPO3\CMS\Core\Domain\Page\$specialPropertyNames
‪array $specialPropertyNames
Definition: Page.php:27
‪TYPO3\CMS\Core\Domain\Page\__construct
‪__construct(array $properties)
Definition: Page.php:42