‪TYPO3CMS  10.4
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 
64  {
65  $this->context = ‪$context;
66  $this->node = ‪$node;
67  $this->subject = ‪$subject;
68  }
69 
73  public function ‪getContext(): ‪EntityContext
74  {
75  return ‪$this->context;
76  }
77 
81  public function ‪getNode(): ‪EntityPointer
82  {
83  return ‪$this->node;
84  }
85 
89  public function ‪getSubject(): ‪EntityUidPointer
90  {
91  return ‪$this->subject;
92  }
93 
97  public function ‪getLanguageLink(): ?‪EntityPointerLink
98  {
100  }
101 
107  {
108  if ($this->languageLink === ‪$languageLink) {
109  return $this;
110  }
111  $target = clone $this;
112  $target->languageLink = ‪$languageLink;
113  return $target;
114  }
115 
119  public function ‪getVersionLink(): ?‪EntityPointerLink
120  {
121  return ‪$this->versionLink;
122  }
123 
129  {
130  if ($this->versionLink === ‪$versionLink) {
131  return $this;
132  }
133  $target = clone $this;
134  $target->versionLink = ‪$versionLink;
135  return $target;
136  }
137 
141  public function ‪isNew(): bool
142  {
144  $this->subject->getIdentifier()
145  );
146  }
147 
160  public function ‪resolveNodeIdentifier(): string
161  {
162  if ($this->subject->isNode()
163  && $this->context->getLanguageId() > 0
164  && $this->languageLink !== null
165  ) {
166  return $this->languageLink->getHead()->getSubject()->getIdentifier();
167  }
168  return $this->node->getIdentifier();
169  }
170 
185  public function ‪resolveNodeAggregateIdentifier(): string
186  {
187  if ($this->subject->isNode()
188  && $this->context->getLanguageId() > 0
189  && $this->languageLink !== null
190  ) {
191  return $this->languageLink->getHead()->getSubject()->getIdentifier();
192  }
193  if ($this->subject->isNode() && $this->versionLink) {
194  return $this->versionLink->getHead()->getSubject()->getIdentifier();
195  }
196  if ($this->subject->isNode()) {
197  return $this->subject->getIdentifier();
198  }
199  return $this->node->getIdentifier();
200  }
201 }
‪TYPO3\CMS\Core\DataHandling\Model\EntityContext
Definition: EntityContext.php:27
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\resolveNodeAggregateIdentifier
‪string resolveNodeAggregateIdentifier()
Definition: RecordState.php:180
‪TYPO3\CMS\Core\DataHandling\Model\EntityPointer
Definition: EntityPointer.php:24
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger($var)
Definition: MathUtility.php:74
‪TYPO3\CMS\Core\DataHandling\Model\EntityUidPointer
Definition: EntityUidPointer.php:24
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getVersionLink
‪EntityPointerLink getVersionLink()
Definition: RecordState.php:114
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\resolveNodeIdentifier
‪string resolveNodeIdentifier()
Definition: RecordState.php:155
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\withVersionLink
‪static withVersionLink(?EntityPointerLink $versionLink)
Definition: RecordState.php:123
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getSubject
‪EntityUidPointer getSubject()
Definition: RecordState.php:84
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$context
‪EntityContext $context
Definition: RecordState.php:35
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getContext
‪EntityContext getContext()
Definition: RecordState.php:68
‪TYPO3\CMS\Core\DataHandling\Model
Definition: CorrelationId.php:18
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\isNew
‪bool isNew()
Definition: RecordState.php:136
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\__construct
‪__construct(EntityContext $context, EntityPointer $node, EntityUidPointer $subject)
Definition: RecordState.php:58
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\withLanguageLink
‪static withLanguageLink(?EntityPointerLink $languageLink)
Definition: RecordState.php:101
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getNode
‪EntityPointer getNode()
Definition: RecordState.php:76
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$node
‪EntityPointer $node
Definition: RecordState.php:39
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\getLanguageLink
‪EntityPointerLink getLanguageLink()
Definition: RecordState.php:92
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$versionLink
‪EntityPointerLink $versionLink
Definition: RecordState.php:51
‪TYPO3\CMS\Core\DataHandling\Model\RecordState\$languageLink
‪EntityPointerLink $languageLink
Definition: RecordState.php:47
‪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\Utility\MathUtility
Definition: MathUtility.php:22