TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
DependencyEntityFactory.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Version\Dependency;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected $elements = [];
26 
30  protected $references = [];
31 
41  public function getElement($table, $id, array $data = [], \TYPO3\CMS\Version\Dependency\DependencyResolver $dependency)
42  {
44  $element = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Version\Dependency\ElementEntity::class, $table, $id, $data, $dependency);
45  $elementName = $element->__toString();
46  if (!isset($this->elements[$elementName])) {
47  $this->elements[$elementName] = $element;
48  }
49  return $this->elements[$elementName];
50  }
51 
59  public function getReference(\TYPO3\CMS\Version\Dependency\ElementEntity $element, $field)
60  {
61  $referenceName = $element->__toString() . '.' . $field;
62  if (!isset($this->references[$referenceName][$field])) {
63  $this->references[$referenceName][$field] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Version\Dependency\ReferenceEntity::class, $element, $field);
64  }
65  return $this->references[$referenceName][$field];
66  }
67 
80  public function getReferencedElement($table, $id, $field, array $data = [], \TYPO3\CMS\Version\Dependency\DependencyResolver $dependency)
81  {
82  return $this->getReference($this->getElement($table, $id, $data, $dependency), $field);
83  }
84 }
getReference(\TYPO3\CMS\Version\Dependency\ElementEntity $element, $field)
getReferencedElement($table, $id, $field, array $data=[],\TYPO3\CMS\Version\Dependency\DependencyResolver $dependency)
static makeInstance($className,...$constructorArguments)