‪TYPO3CMS  9.5
RecordState.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
20 
31 {
35  protected ‪$context;
36 
40  protected ‪$node;
41 
45  protected ‪$subject;
46 
50  protected ‪$languageLink;
51 
55  protected ‪$versionLink;
56 
63  {
64  $this->context = ‪$context;
65  $this->node = ‪$node;
66  $this->subject = ‪$subject;
67  }
68 
72  public function ‪getContext(): ‪EntityContext
73  {
74  return ‪$this->context;
75  }
76 
80  public function ‪getNode(): ‪EntityPointer
81  {
82  return ‪$this->node;
83  }
84 
88  public function ‪getSubject(): ‪EntityUidPointer
89  {
90  return ‪$this->subject;
91  }
92 
96  public function ‪getLanguageLink(): ?‪EntityPointerLink
97  {
99  }
100 
106  {
107  if ($this->languageLink === ‪$languageLink) {
108  return $this;
109  }
110  $target = clone $this;
111  $target->languageLink = ‪$languageLink;
112  return $target;
113  }
114 
118  public function ‪getVersionLink(): ?‪EntityPointerLink
119  {
120  return ‪$this->versionLink;
121  }
122 
128  {
129  if ($this->versionLink === ‪$versionLink) {
130  return $this;
131  }
132  $target = clone $this;
133  $target->versionLink = ‪$versionLink;
134  return $target;
135  }
136 
140  public function ‪isNew(): bool
141  {
143  $this->subject->getIdentifier()
144  );
145  }
146 
159  public function ‪resolveNodeIdentifier(): string
160  {
161  if ($this->subject->isNode()
162  && $this->context->getLanguageId() > 0
163  && $this->languageLink !== null
164  ) {
165  return $this->languageLink->getHead()->getSubject()->getIdentifier();
166  }
167  return $this->node->getIdentifier();
168  }
169 
184  public function ‪resolveNodeAggregateIdentifier(): string
185  {
186  if ($this->subject->isNode()
187  && $this->context->getLanguageId() > 0
188  && $this->languageLink !== null
189  ) {
190  return $this->languageLink->getHead()->getSubject()->getIdentifier();
191  }
192  if ($this->subject->isNode() && $this->versionLink) {
193  return $this->versionLink->getHead()->getSubject()->getIdentifier();
194  }
195  if ($this->subject->isNode()) {
196  return $this->subject->getIdentifier();
197  }
198  return $this->node->getIdentifier();
199  }
200 }
‪TYPO3\CMS\Core\DataHandling\Model\EntityContext
Definition: EntityContext.php:26
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\resolveNodeAggregateIdentifier
‪string resolveNodeAggregateIdentifier()
Definition: RecordState.php:179
‪TYPO3\CMS\Core\DataHandling\Model\EntityPointer
Definition: EntityPointer.php:23
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger($var)
Definition: MathUtility.php:73
‪TYPO3\CMS\Core\DataHandling\Model\EntityUidPointer
Definition: EntityUidPointer.php:23
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getVersionLink
‪EntityPointerLink getVersionLink()
Definition: RecordState.php:113
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\resolveNodeIdentifier
‪string resolveNodeIdentifier()
Definition: RecordState.php:154
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\withVersionLink
‪static withVersionLink(?EntityPointerLink $versionLink)
Definition: RecordState.php:122
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getSubject
‪EntityUidPointer getSubject()
Definition: RecordState.php:83
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$context
‪EntityContext $context
Definition: RecordState.php:34
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getContext
‪EntityContext getContext()
Definition: RecordState.php:67
‪TYPO3\CMS\Core\DataHandling\Model
Definition: EntityContext.php:4
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\isNew
‪bool isNew()
Definition: RecordState.php:135
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\__construct
‪__construct(EntityContext $context, EntityPointer $node, EntityUidPointer $subject)
Definition: RecordState.php:57
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\withLanguageLink
‪static withLanguageLink(?EntityPointerLink $languageLink)
Definition: RecordState.php:100
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getNode
‪EntityPointer getNode()
Definition: RecordState.php:75
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$node
‪EntityPointer $node
Definition: RecordState.php:38
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getLanguageLink
‪EntityPointerLink getLanguageLink()
Definition: RecordState.php:91
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$versionLink
‪EntityPointerLink $versionLink
Definition: RecordState.php:50
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$languageLink
‪EntityPointerLink $languageLink
Definition: RecordState.php:46
‪TYPO3\CMS\Core\DataHandling\Model\RecordState
Definition: RecordState.php:31
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$subject
‪EntityUidPointer $subject
Definition: RecordState.php:42
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:21