Skip to content

Commit

Permalink
[FIX] Fix translations handling for file references in Extbase
Browse files Browse the repository at this point in the history
  • Loading branch information
Rouven Bardtke | Paints authored and Heiko Kromm | Paints committed Sep 19, 2016
1 parent d3b7196 commit 8151e2b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function setOriginalResource(\TYPO3\CMS\Core\Resource\FileReference $orig
*/
public function getOriginalResource() {
if ($this->originalResource === NULL) {
$this->originalResource = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileReferenceObject($this->getUid());
$this->originalResource = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileReferenceObject($this->_localizedUid);
}

return $this->originalResource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,25 @@ class ColumnMap {
*/
protected $internalType;

/**
* @var bool
*/
protected $relationsOverriddenByTranslation;

/**
* @return boolean
*/
public function isRelationsOverriddenByTranslation() {
return $this->relationsOverriddenByTranslation;
}

/**
* @param boolean $relationsOverriddenByTranslation
*/
public function setRelationsOverriddenByTranslation($relationsOverriddenByTranslation) {
$this->relationsOverriddenByTranslation = $relationsOverriddenByTranslation;
}

/**
* Constructs a Column Map
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ protected function setRelations(ColumnMap $columnMap, $columnConfiguration, $pro
} else {
$columnMap->setTypeOfRelation(ColumnMap::RELATION_NONE);
}
if (isset($columnConfiguration['behaviour']['localizationMode'])) {
$columnMap->setRelationsOverriddenByTranslation($columnConfiguration['behaviour']['localizationMode'] !== 'keep');
}

return $columnMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,11 @@ protected function getPreparedQuery(\TYPO3\CMS\Extbase\DomainObject\DomainObject
protected function getConstraint(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query, \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName, $fieldValue = '', $relationTableMatchFields = array()) {
$columnMap = $this->getDataMap(get_class($parentObject))->getColumnMap($propertyName);
if ($columnMap->getParentKeyFieldName() !== NULL) {
$constraint = $query->equals($columnMap->getParentKeyFieldName(), $parentObject);
if ($columnMap->isRelationsOverriddenByTranslation()) {
$constraint = $query->equals($columnMap->getParentKeyFieldName(), $parentObject->_getProperty('_localizedUid'));
} else {
$constraint = $query->equals($columnMap->getParentKeyFieldName(), $parentObject);
}
if ($columnMap->getParentTableFieldName() !== NULL) {
$constraint = $query->logicalAnd($constraint, $query->equals($columnMap->getParentTableFieldName(), $this->getDataMap(get_class($parentObject))->getTableName()));
}
Expand All @@ -387,6 +391,7 @@ protected function getConstraint(\TYPO3\CMS\Extbase\Persistence\QueryInterface $
$constraint = $query->logicalAnd($constraint, $query->equals($relationTableMatchFieldName, $relationTableMatchFieldValue));
}
}

return $constraint;
}

Expand Down

0 comments on commit 8151e2b

Please sign in to comment.