‪TYPO3CMS  9.5
EntityPointerLink.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 
23 {
27  protected ‪$subject;
28 
32  protected ‪$ancestor;
33 
38  {
39  $this->subject = ‪$subject;
40  }
41 
45  public function ‪getSubject(): ‪EntityPointer
46  {
47  return ‪$this->subject;
48  }
49 
53  public function ‪getHead(): ‪EntityPointerLink
54  {
55  $head = $this;
56  while ($head->ancestor !== null) {
57  $head = $head->ancestor;
58  }
59  return $head;
60  }
61 
65  public function ‪getAncestor(): ?‪EntityPointerLink
66  {
67  return ‪$this->ancestor;
68  }
69 
75  {
76  if ($this->ancestor === ‪$ancestor) {
77  return $this;
78  }
79  $target = clone $this;
80  $target->ancestor = ‪$ancestor;
81  return $target;
82  }
83 }
‪TYPO3\CMS\Core\DataHandling\Model\EntityPointer
Definition: EntityPointer.php:23
‪TYPO3\CMS\Core\DataHandling\Model
Definition: EntityContext.php:4