TYPO3 CMS  TYPO3_6-2
DependencyEntityFactory.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $elements = array();
26 
30  protected $references = array();
31 
41  public function getElement($table, $id, array $data = array(), \TYPO3\CMS\Version\Dependency\DependencyResolver $dependency) {
43  $element = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Version\\Dependency\\ElementEntity', $table, $id, $data, $dependency);
44  $elementName = $element->__toString();
45  if (!isset($this->elements[$elementName])) {
46  $this->elements[$elementName] = $element;
47  }
48  return $this->elements[$elementName];
49  }
50 
58  public function getReference(\TYPO3\CMS\Version\Dependency\ElementEntity $element, $field) {
59  $referenceName = $element->__toString() . '.' . $field;
60  if (!isset($this->references[$referenceName][$field])) {
61  $this->references[$referenceName][$field] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Version\\Dependency\\ReferenceEntity', $element, $field);
62  }
63  return $this->references[$referenceName][$field];
64  }
65 
78  public function getReferencedElement($table, $id, $field, array $data = array(), \TYPO3\CMS\Version\Dependency\DependencyResolver $dependency) {
79  return $this->getReference($this->getElement($table, $id, $data, $dependency), $field);
80  }
81 
82 }
getReferencedElement($table, $id, $field, array $data=array(), \TYPO3\CMS\Version\Dependency\DependencyResolver $dependency)
getReference(\TYPO3\CMS\Version\Dependency\ElementEntity $element, $field)