‪TYPO3CMS  ‪main
RecordState.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 
21 
32 {
36  protected ‪$context;
37 
41  protected ‪$node;
42 
46  protected ‪$subject;
47 
51  protected ‪$languageLink;
52 
56  protected ‪$versionLink;
57 
59  {
60  $this->context = ‪$context;
61  $this->node = ‪$node;
62  $this->subject = ‪$subject;
63  }
64 
65  public function ‪getContext(): ‪EntityContext
66  {
67  return ‪$this->context;
68  }
69 
70  public function ‪getNode(): ‪EntityPointer
71  {
72  return ‪$this->node;
73  }
74 
75  public function ‪getSubject(): ‪EntityUidPointer
76  {
77  return ‪$this->subject;
78  }
79 
83  public function ‪getLanguageLink(): ?‪EntityPointerLink
84  {
86  }
87 
92  {
93  if ($this->languageLink === ‪$languageLink) {
94  return $this;
95  }
96  $target = clone $this;
97  $target->languageLink = ‪$languageLink;
98  return $target;
99  }
100 
104  public function ‪getVersionLink(): ?‪EntityPointerLink
105  {
106  return ‪$this->versionLink;
107  }
108 
113  {
114  if ($this->versionLink === ‪$versionLink) {
115  return $this;
116  }
117  $target = clone $this;
118  $target->versionLink = ‪$versionLink;
119  return $target;
120  }
121 
122  public function ‪isNew(): bool
123  {
125  $this->subject->getIdentifier()
126  );
127  }
128 
139  public function ‪resolveNodeIdentifier(): string
140  {
141  if ($this->subject->isNode()
142  && $this->context->getLanguageId() > 0
143  && $this->languageLink !== null
144  ) {
145  return $this->languageLink->getHead()->getSubject()->getIdentifier();
146  }
147  return $this->node->getIdentifier();
148  }
149 
162  public function ‪resolveNodeAggregateIdentifier(): string
163  {
164  if ($this->subject->isNode()
165  && $this->context->getLanguageId() > 0
166  && $this->languageLink !== null
167  ) {
168  return $this->languageLink->getHead()->getSubject()->getIdentifier();
169  }
170  if ($this->subject->isNode() && $this->versionLink) {
171  return $this->versionLink->getHead()->getSubject()->getIdentifier();
172  }
173  if ($this->subject->isNode()) {
174  return $this->subject->getIdentifier();
175  }
176  return $this->node->getIdentifier();
177  }
178 }
‪TYPO3\CMS\Core\DataHandling\Model\EntityContext
Definition: EntityContext.php:27
‪TYPO3\CMS\Core\DataHandling\Model\EntityPointer
Definition: EntityPointer.php:24
‪TYPO3\CMS\Core\DataHandling\Model\EntityUidPointer
Definition: EntityUidPointer.php:24
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getVersionLink
‪EntityPointerLink getVersionLink()
Definition: RecordState.php:99
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getNode
‪getNode()
Definition: RecordState.php:65
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\withVersionLink
‪static withVersionLink(?EntityPointerLink $versionLink)
Definition: RecordState.php:107
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getSubject
‪getSubject()
Definition: RecordState.php:70
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$context
‪EntityContext $context
Definition: RecordState.php:35
‪TYPO3\CMS\Core\DataHandling\Model
Definition: CorrelationId.php:18
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\__construct
‪__construct(EntityContext $context, EntityPointer $node, EntityUidPointer $subject)
Definition: RecordState.php:53
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\withLanguageLink
‪static withLanguageLink(?EntityPointerLink $languageLink)
Definition: RecordState.php:86
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger(mixed $var)
Definition: MathUtility.php:69
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\isNew
‪isNew()
Definition: RecordState.php:117
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$node
‪EntityPointer $node
Definition: RecordState.php:39
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$versionLink
‪EntityPointerLink null $versionLink
Definition: RecordState.php:51
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getLanguageLink
‪EntityPointerLink getLanguageLink()
Definition: RecordState.php:78
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\resolveNodeIdentifier
‪resolveNodeIdentifier()
Definition: RecordState.php:134
‪TYPO3\CMS\Core\DataHandling\Model\RecordState
Definition: RecordState.php:32
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$subject
‪EntityUidPointer $subject
Definition: RecordState.php:43
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getContext
‪getContext()
Definition: RecordState.php:60
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\resolveNodeAggregateIdentifier
‪resolveNodeAggregateIdentifier()
Definition: RecordState.php:157
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:24
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$languageLink
‪EntityPointerLink null $languageLink
Definition: RecordState.php:47