[+TASK] Extbase (DomainObject): Added a "private" property _localizationParentUid...
authorJochen Rau <j.rau@web.de>
Tue, 2 Mar 2010 15:49:26 +0000 (15:49 +0000)
committerJochen Rau <j.rau@web.de>
Tue, 2 Mar 2010 15:49:26 +0000 (15:49 +0000)
[+CONFIGURATION] Extbase (Persistence): Added a new flag respectSysLanguage to the Typoe3QuerySettings (TRUE by default). If it is set to true a "sys_language_uid IN (-1,0)" query part will be added if applicable.
[~TASK] Extbase (Persistence): Refactored getRows() and countRows() to avoid unnecessary calls to doLanguageAndWorkspaceOverlay().
[!!!][+FEATURE] Extbase (Persistence): It's now possible to edit localized domain models in the FE. Changes will be stored to the correct database row. This changes the behavior of mapping the uid to DomainObjects. The uid is now the "real" uid of the localized database tuple instead of the sys_language_parent. This may influence the $_GET parameters of cached pages as the uid is often part of the URI. Resolves #4639.
[~TASK] Extbase (Persistence): Added $query->getQuerySettings()->setRespectSysLanguage(FALSE); to all methods fetching an object "byUid".
[~TASK] Extbase (Persistence): Changed method signatures to Tx_Extbase_DomainObject_DomainObjectInterface instead of Tx_Extbase_DomainObject_AbstractEnty.

typo3/sysext/extbase/Classes/DomainObject/AbstractDomainObject.php
typo3/sysext/extbase/Classes/MVC/Controller/Argument.php
typo3/sysext/extbase/Classes/Persistence/Backend.php
typo3/sysext/extbase/Classes/Persistence/LazyLoadingProxy.php
typo3/sysext/extbase/Classes/Persistence/LazyObjectStorage.php
typo3/sysext/extbase/Classes/Persistence/Mapper/DataMapper.php
typo3/sysext/extbase/Classes/Persistence/Repository.php
typo3/sysext/extbase/Classes/Persistence/Storage/Typo3DbBackend.php
typo3/sysext/extbase/Classes/Persistence/Typo3QuerySettings.php
typo3/sysext/extbase/Classes/Persistence/Typo3QuerySettingsInterface.php
typo3/sysext/extbase/Classes/Property/Mapper.php

index 7ca212e..30f25af 100644 (file)
@@ -39,6 +39,11 @@ abstract class Tx_Extbase_DomainObject_AbstractDomainObject implements Tx_Extbas
        protected $uid;
 
        /**
+        * @var int The uid of the localization parent
+        */
+       protected $_localizationParentUid;
+
+       /**
         * TRUE if the object is a clone
         * @var boolean
         */
@@ -80,9 +85,13 @@ abstract class Tx_Extbase_DomainObject_AbstractDomainObject implements Tx_Extbas
         * @return int the uid or NULL if none set yet.
         */
        final public function getUid() {
-               return ($this->uid === NULL ? NULL : (int)$this->uid);
+               if ($this->uid !== NULL) {
+                       return (int)$this->uid;
+               } else {
+                       return NULL;
+               }
        }
-
+       
        /**
         * Reconstitutes a property. Only for internal use.
         *
index 8cc73d7..bf5c5f7 100644 (file)
@@ -381,6 +381,7 @@ class Tx_Extbase_MVC_Controller_Argument {
         */
        protected function findObjectByUid($uid) {
                $query = $this->queryFactory->create($this->dataType);
+               $query->getQuerySettings()->setRespectSysLanguage(FALSE);
                $result = $query->matching($query->withUid($uid))->execute();
                $object = NULL;
                if (count($result) > 0) {
index be6df24..2e52e4d 100644 (file)
@@ -768,8 +768,7 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
        protected function updateObject(Tx_Extbase_DomainObject_DomainObjectInterface $object, array &$row) {
                $tableName = $this->dataMapper->getDataMap(get_class($object))->getTableName();
                $this->addCommonFieldsToRow($object, $row);
-               $uid = $object->getUid();
-               $row['uid'] = $uid;
+               $row['uid'] = $object->getUid();
                $res = $this->storageBackend->updateRow(
                        $tableName,
                        $row
@@ -779,7 +778,7 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                }
                return $res;
        }
-
+       
        /**
         * Returns a table row to be inserted or updated in the database
         *
index ad20061..bb20883 100644 (file)
@@ -55,7 +55,7 @@ class Tx_Extbase_Persistence_LazyLoadingProxy implements Iterator, Tx_Extbase_Pe
         * @var mixed
         */
        private $fieldValue;
-
+       
        /**
         * Constructs this proxy instance.
         *
@@ -80,7 +80,7 @@ class Tx_Extbase_Persistence_LazyLoadingProxy implements Iterator, Tx_Extbase_Pe
                // it's parent... the result would be weird.
                if ($this->parentObject->_getProperty($this->propertyName) instanceof Tx_Extbase_Persistence_LazyLoadingProxy) {
                        $dataMapper = Tx_Extbase_Dispatcher::getPersistenceManager()->getBackend()->getDataMapper();
-                       $objects = $dataMapper->fetchRelated($this->parentObject, $this->propertyName, $this->fieldValue, FALSE);
+                       $objects = $dataMapper->fetchRelated($this->parentObject, $this->propertyName, $this->fieldValue, FALSE, FALSE);
                        $propertyValue = $dataMapper->mapResultToPropertyValue($this->parentObject, $this->propertyName, $objects);
                        $this->parentObject->_setProperty($this->propertyName, $propertyValue);
                        $this->parentObject->_memorizeCleanState($this->propertyName);
index dbb389a..9097053 100644 (file)
@@ -83,7 +83,7 @@ class Tx_Extbase_Persistence_LazyObjectStorage extends Tx_Extbase_Persistence_Ob
        protected function initializeStorage() {
                if (!$this->isInitialized) {
                        $dataMapper = Tx_Extbase_Dispatcher::getPersistenceManager()->getBackend()->getDataMapper();
-                       $objects = $dataMapper->fetchRelated($this->parentObject, $this->propertyName, $this->fieldValue, FALSE);
+                       $objects = $dataMapper->fetchRelated($this->parentObject, $this->propertyName, $this->fieldValue, FALSE, FALSE);
                        $storage = array();
                        foreach ($objects as $object) {
                                $storage[spl_object_hash($object)] = $object;
index 5ca4b3f..7dfcf3f 100644 (file)
@@ -184,7 +184,14 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                $className = get_class($object);
                $dataMap = $this->getDataMap($className);
                $properties = $object->_getProperties();
-               $object->_setProperty('uid', $row->getValue('uid'));
+               $localizedUid = $row->getValue('_LOCALIZED_UID');
+               if ($localizedUid !== NULL) {
+                       $object->_setProperty('uid', $localizedUid);
+                       $object->_setProperty('_localizationParentUid', $row->getValue('uid'));
+               } else {
+                       $object->_setProperty('uid', $row->getValue('uid'));
+               }
+               unset($properties['uid']);
                foreach ($properties as $propertyName => $propertyValue) {
                        if (!$dataMap->isPersistableProperty($propertyName)) continue;
                        $columnMap = $dataMap->getColumnMap($propertyName);
@@ -228,13 +235,14 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
        /**
         * Fetches a collection of objects related to a property of a parent object
         *
-        * @param Tx_Extbase_DomainObject_AbstractEntity $parentObject The object instance this proxy is part of
+        * @param Tx_Extbase_DomainObject_DomainObjectInterface $parentObject The object instance this proxy is part of
         * @param string $propertyName The name of the proxied property in it's parent
         * @param mixed $fieldValue The raw field value.
-        * @param Tx_Extbase_Persistence_Mapper_DataMap $dataMap The corresponding Data Map of the property
+        * @param bool $enableLazyLoading A flag indication if the related objects should be lazy loaded
+        * @param bool $performLanguageOverlay A flag indication if the related objects should be localized
         * @return mixed The result
         */
-       public function fetchRelated(Tx_Extbase_DomainObject_AbstractEntity $parentObject, $propertyName, $fieldValue = '', $enableLazyLoading = TRUE) {
+       public function fetchRelated(Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName, $fieldValue = '', $enableLazyLoading = TRUE, $performLanguageOverlay = TRUE) {
                $columnMap = $this->getDataMap(get_class($parentObject))->getColumnMap($propertyName);
                $propertyMetaData = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName);
                if ($enableLazyLoading === TRUE && ($propertyMetaData['lazy'] || ($columnMap->getLoadingStrategy() !== Tx_Extbase_Persistence_Mapper_ColumnMap::STRATEGY_EAGER))) {
@@ -244,7 +252,7 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                                $result = t3lib_div::makeInstance('Tx_Extbase_Persistence_LazyLoadingProxy', $parentObject, $propertyName, $fieldValue);
                        }
                } else {
-                       $result = $this->fetchRelatedEager($parentObject, $propertyName, $fieldValue);
+                       $result = $this->fetchRelatedEager($parentObject, $propertyName, $fieldValue, $performLanguageOverlay);
                }
                return $result;
        }
@@ -252,26 +260,28 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
        /**
         * Fetches the related objects from the storage backend.
         *
-        * @param Tx_Extbase_DomainObject_AbstractEntity $parentObject The object instance this proxy is part of
+        * @param Tx_Extbase_DomainObject_DomainObjectInterface $parentObject The object instance this proxy is part of
         * @param string $propertyName The name of the proxied property in it's parent
         * @param mixed $fieldValue The raw field value.
+        * @param bool $performLanguageOverlay A flag indication if the related objects should be localized
         * @return void
         */
-       protected function fetchRelatedEager(Tx_Extbase_DomainObject_AbstractEntity $parentObject, $propertyName, $fieldValue = '') {
+       protected function fetchRelatedEager(Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName, $fieldValue = '', $performLanguageOverlay = TRUE) {
                if ($fieldValue === '') return array();
                $query = $this->getPreparedQuery($parentObject, $propertyName, $fieldValue);
+               $query->getQuerySettings()->setRespectSysLanguage($performLanguageOverlay);
                return $query->execute();
        }
        
        /**
         * Builds and returns the prepared query, ready to be executed.
         *
-        * @param Tx_Extbase_DomainObject_AbstractEntity $parentObject 
+        * @param Tx_Extbase_DomainObject_DomainObjectInterface $parentObject 
         * @param string $propertyName 
         * @param string $fieldValue 
         * @return void
         */
-       protected function getPreparedQuery(Tx_Extbase_DomainObject_AbstractEntity $parentObject, $propertyName, $fieldValue = '') {
+       protected function getPreparedQuery(Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName, $fieldValue = '') {
                $columnMap = $this->getDataMap(get_class($parentObject))->getColumnMap($propertyName);
                $queryFactory = t3lib_div::makeInstance('Tx_Extbase_Persistence_QueryFactory');
                $parentKeyFieldName = $columnMap->getParentKeyFieldName();
@@ -344,7 +354,7 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
         * @param array $propertyMetaData The property meta data
         * @return void
         */
-       public function mapResultToPropertyValue(Tx_Extbase_DomainObject_AbstractEntity $parentObject, $propertyName, $result) {
+       public function mapResultToPropertyValue(Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName, $result) {
                if ($result instanceof Tx_Extbase_Persistence_LoadingStrategyInterface) {
                        $propertyValue = $result;
                } else {
@@ -377,11 +387,11 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
        /**
         * Counts the number of related objects assigned to a property of a parent object
         *
-        * @param Tx_Extbase_DomainObject_AbstractEntity $parentObject The object instance this proxy is part of
+        * @param Tx_Extbase_DomainObject_DomainObjectInterface $parentObject The object instance this proxy is part of
         * @param string $propertyName The name of the proxied property in it's parent
         * @param mixed $fieldValue The raw field value.
         */
-       public function countRelated(Tx_Extbase_DomainObject_AbstractEntity $parentObject, $propertyName, $fieldValue = '') {
+       public function countRelated(Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName, $fieldValue = '') {
                $query = $this->getPreparedQuery($parentObject, $propertyName, $fieldValue);
                return $query->count();
        }
@@ -476,11 +486,11 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
        /**
         * Returns the type of a child object.
         *
-        * @param Tx_Extbase_DomainObject_AbstractEntity $parentObject The object instance this proxy is part of
+        * @param Tx_Extbase_DomainObject_DomainObjectInterface $parentObject The object instance this proxy is part of
         * @param string $propertyName The name of the proxied property in it's parent
         * @return string The class name of the child object
         */
-       protected function getType(Tx_Extbase_DomainObject_AbstractEntity $parentObject, $propertyName) {
+       protected function getType(Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName) {
                $propertyMetaData = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName);
                $columnMap = $this->getDataMap(get_class($parentObject))->getColumnMap($propertyName);
                $childClassName = $columnMap->getChildClassName();
@@ -497,11 +507,11 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
        /**
         * Returns the type of the elements inside an ObjectStorage or array.
         *
-        * @param Tx_Extbase_DomainObject_AbstractEntity $parentObject The object instance this proxy is part of
+        * @param Tx_Extbase_DomainObject_DomainObjectInterface $parentObject The object instance this proxy is part of
         * @param string $propertyName The name of the proxied property in it's parent
         * @return string The class name of the elements inside an ObjectStorage
         */
-       protected function getElementType(Tx_Extbase_DomainObject_AbstractEntity $parentObject, $propertyName) {
+       protected function getElementType(Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName) {
                $propertyMetaData = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName);
                $columnMap = $this->getDataMap(get_class($parentObject))->getColumnMap($propertyName);
                $childClassName = $columnMap->getChildClassName();
index eb3e8e9..0630dc7 100644 (file)
@@ -236,6 +236,7 @@ class Tx_Extbase_Persistence_Repository implements Tx_Extbase_Persistence_Reposi
                        $object = $this->identityMap->getObjectByIdentifier($uid, $this->objectType);
                } else {
                        $query = $this->createQuery();
+                       $query->getQuerySettings()->setRespectSysLanguage(FALSE);
                        $result = $query->matching($query->withUid($uid))->execute();
                        $object = NULL;
                        if (count($result) > 0) {
index 6b1a803..3993752 100644 (file)
@@ -227,7 +227,9 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                // debug($statement,-2);
                $result = $this->databaseHandle->sql_query($statement);
                $this->checkSqlErrors();
-               return $this->getRowsFromResult($query->getSource(), $result);
+               $rows = $this->getRowsFromResult($query->getSource(), $result);
+               $rows = $this->doLanguageAndWorkspaceOverlay($query->getSource(), $rows);
+               return $rows;
        }
 
        /**
@@ -246,8 +248,8 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                $this->replacePlaceholders($statement, $parameters);
                $result = $this->databaseHandle->sql_query($statement);
                $this->checkSqlErrors();
-               $tuples = $this->getRowsFromResult($query->getSource(), $result);
-               return current(current($tuples));
+               $rows = $this->getRowsFromResult($query->getSource(), $result);
+               return current(current($rows));
        }
        
        /**
@@ -376,6 +378,9 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                                if ($querySettings->getRespectEnableFields()) {
                                        $this->addEnableFieldsStatement($tableName, $sql);
                                }
+                               if ($querySettings->getRespectSysLanguage()) {
+                                       $this->addSysLanguageStatement($tableName, $sql);
+                               }
                                if ($querySettings->getRespectStoragePage()) {
                                        $this->addPageIdStatement($tableName, $sql);
                                }
@@ -421,6 +426,10 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                                $this->addEnableFieldsStatement($leftTableName, $sql);
                                $this->addEnableFieldsStatement($rightTableName, $sql);
                        }
+                       if ($querySettings->getRespectSysLanguage()) {
+                               $this->addSysLanguageStatement($leftTableName, $sql);
+                               $this->addSysLanguageStatement($rightTableName, $sql);
+                       }
                        if ($querySettings->getRespectStoragePage()) {
                                $this->addPageIdStatement($leftTableName, $sql);
                                $this->addPageIdStatement($rightTableName, $sql);
@@ -634,7 +643,22 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                        }
                }
        }
-
+       
+       /**
+        * Builds the language field statement
+        *
+        * @param string $tableName The database table name
+        * @param array &$sql The query parts
+        * @return void
+        */
+       protected function addSysLanguageStatement($tableName, array &$sql) {
+               if (is_array($GLOBALS['TCA'][$tableName]['ctrl'])) {
+                       if(isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField']) && $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] !== NULL) {
+                               $sql['additionalWhereClause'][] = $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] . ' IN (0,-1)';
+                       }
+               }
+       }
+       
        /**
         * Builds the page ID checking statement
         *
@@ -707,8 +731,7 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
        }
 
        /**
-        * Transforms a Resource from a database query to an array of rows. Performs the language and
-        * workspace overlay before.
+        * Transforms a Resource from a database query to an array of rows.
         *
         * @param Tx_Extbase_Persistence_QOM_SourceInterface $source The source (selector od join)
         * @param resource $result The result
@@ -717,14 +740,9 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
        protected function getRowsFromResult(Tx_Extbase_Persistence_QOM_SourceInterface $source, $result) {
                $rows = array();
                while ($row = $this->databaseHandle->sql_fetch_assoc($result)) {
-                       if      ($source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
-                               $row = $this->doLanguageAndWorkspaceOverlay($source->getSelectorName(), $row);
-                       } else if ($source instanceof Tx_Extbase_Persistence_QOM_JoinInterface) {
-                               $row = $this->doLanguageAndWorkspaceOverlay($source->getLeft()->getSelectorName(), $row);
-                       }
                        if (is_array($row)) {
                                // TODO Check if this is necessary, maybe the last line is enough
-                               $arrayKeys = range(0,count($row));
+                               $arrayKeys = range(0, count($row));
                                array_fill_keys($arrayKeys, $row);
                                $rows[] = $row;
                        }
@@ -736,46 +754,58 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * Performs workspace and language overlay on the given row array. The language and workspace id is automatically
         * detected (depending on FE or BE context). You can also explicitly set the language/workspace id.
         *
-        * @param Tx_Extbase_Persistence_Mapper_DataMap $dataMap
+        * @param Tx_Extbase_Persistence_QOM_SourceInterface $source The source (selector od join)
         * @param array $row The row array (as reference)
         * @param string $languageUid The language id
         * @param string $workspaceUidUid The workspace id
         * @return void
         */
-       protected function doLanguageAndWorkspaceOverlay($tableName, array $row, $languageUid = NULL, $workspaceUid = NULL) {
-               if (!($this->pageSelectObject instanceof t3lib_pageSelect)) {
-                       if (TYPO3_MODE == 'FE') {
-                               if (is_object($GLOBALS['TSFE'])) {
-                                       $this->pageSelectObject = $GLOBALS['TSFE']->sys_page;
+       protected function doLanguageAndWorkspaceOverlay(Tx_Extbase_Persistence_QOM_SourceInterface $source, array $rows, $languageUid = NULL, $workspaceUid = NULL) {
+               $overlayedRows = array();
+               foreach ($rows as $row) {
+                       if (!($this->pageSelectObject instanceof t3lib_pageSelect)) {
+                               if (TYPO3_MODE == 'FE') {
+                                       if (is_object($GLOBALS['TSFE'])) {
+                                               $this->pageSelectObject = $GLOBALS['TSFE']->sys_page;
+                                       } else {
+                                               require_once(PATH_t3lib . 'class.t3lib_page.php');
+                                               $this->pageSelectObject = t3lib_div::makeInstance('t3lib_pageSelect');
+                                       }
                                } else {
                                        require_once(PATH_t3lib . 'class.t3lib_page.php');
-                                       $this->pageSelectObject = t3lib_div::makeInstance('t3lib_pageSelect');
+                                       $this->pageSelectObject = t3lib_div::makeInstance( 't3lib_pageSelect' );
                                }
-                       } else {
-                               require_once(PATH_t3lib . 'class.t3lib_page.php');
-                               $this->pageSelectObject = t3lib_div::makeInstance( 't3lib_pageSelect' );
-                       }
-               }
-               if (is_object($GLOBALS['TSFE'])) {
-                       if ($languageUid === NULL) {
-                               $languageUid = $GLOBALS['TSFE']->sys_language_uid;
                        }
-                       if ($workspaceUid !== NULL) {
+                       if (is_object($GLOBALS['TSFE'])) {
+                               if ($languageUid === NULL) {
+                                       $languageUid = $GLOBALS['TSFE']->sys_language_uid;
+                               }
+                               if ($workspaceUid !== NULL) {
+                                       $this->pageSelectObject->versioningWorkspaceId = $workspaceUid;
+                               }
+                       } else {
+                               if ($languageUid === NULL) {
+                                       $languageUid = intval(t3lib_div::_GP('L'));
+                               }
+                               if ($workspaceUid === NULL) {
+                                       $workspaceUid = $GLOBALS['BE_USER']->workspace;
+                               }
                                $this->pageSelectObject->versioningWorkspaceId = $workspaceUid;
                        }
-               } else {
-                       if ($languageUid === NULL) {
-                               $languageUid = intval(t3lib_div::_GP('L'));
+                       if ($source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
+                               $tableName = $source->getSelectorName();
+                       } elseif ($source instanceof Tx_Extbase_Persistence_QOM_JoinInterface) {
+                               $tableName = $source->getLeft()->getSelectorName();
                        }
-                       if ($workspaceUid === NULL) {
-                               $workspaceUid = $GLOBALS['BE_USER']->workspace;
+                       $this->pageSelectObject->versionOL($tableName, $row, TRUE);
+                       if(isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField']) && $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] !== '') {
+                               if (in_array($row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']], array(-1,0))) {
+                                       $row = $this->pageSelectObject->getRecordOverlay($tableName, $row, $languageUid);
+                               }
                        }
-                       $this->pageSelectObject->versioningWorkspaceId = $workspaceUid;
+                       $overlayedRows[] = $row;
                }
-               $this->pageSelectObject->versionOL($tableName, $row, TRUE);
-               $row = $this->pageSelectObject->getRecordOverlay($tableName, $row, $languageUid, ''); //'hideNonTranslated'
-               // TODO Skip if empty languageoverlay (languagevisibility)
-               return $row;
+               return $overlayedRows;
        }
 
        /**
index bfb0352..05a12b7 100644 (file)
@@ -49,6 +49,12 @@ class Tx_Extbase_Persistence_Typo3QuerySettings implements Tx_Extbase_Persistenc
        protected $respectEnableFields = TRUE;
 
        /**
+        * Flag if the sys_language_uid should be respected (default is TRUE).
+        * @var boolean
+        */
+       protected $respectSysLanguage = TRUE;
+
+       /**
         * Flag if the the query result should be returned as raw QueryResult.
         * @var boolean
         */
@@ -76,6 +82,27 @@ class Tx_Extbase_Persistence_Typo3QuerySettings implements Tx_Extbase_Persistenc
        }
 
        /**
+        * Sets the flag if a  and language overlay should be performed.
+        *
+        * @param $respectEnableFields TRUE if a  and language overlay should be performed.
+        * @return $this (fluent interface)
+        * @api
+        */
+       public function setRespectSysLanguage($respectSysLanguage) {
+               $this->respectSysLanguage = $respectSysLanguage;
+               return $this;
+       }
+
+       /**
+        * Returns the state, if a  and language overlay should be performed.
+        *
+        * @return boolean TRUE, if a  and language overlay should be performed; otherwise FALSE.
+        */
+       public function getRespectSysLanguage() {
+               return $this->respectSysLanguage;
+       }
+       
+       /**
         * Sets the flag if the visibility in the frontend should be respected.
         *
         * @param $respectEnableFields TRUE if the visibility in the frontend should be respected. If TRUE, the "enable fields" of TYPO3 will be added to the query statement.
index e008c19..1ace0ab 100644 (file)
@@ -55,9 +55,27 @@ interface Tx_Extbase_Persistence_Typo3QuerySettingsInterface extends Tx_Extbase_
        public function setRespectEnableFields($respectEnableFields);
 
        /**
+        * Sets the flag if if the sys language should be respected.
+        *
+        * @param $respectSysLanguage TRUE if the sys language should be respected.
+        * @return $this (fluent interface)
+        * @api
+        */
+       public function setRespectSysLanguage($respectSysLanguage);
+       
+       /**
+        * Returns the state, if the sys language should be respected.
+        *
+        * @return boolean TRUE, if the sys language should be respected; otherwise FALSE.
+        */
+       public function getRespectSysLanguage();
+       
+
+       /**
         * Sets the state, if the QueryResult should be returned unmapped.
         *
         * @return boolean TRUE, if the QueryResult should be returned unmapped; otherwise FALSE.
+        * @api
         */
        public function setReturnRawQueryResult($returnRawQueryResult);
        
@@ -65,6 +83,7 @@ interface Tx_Extbase_Persistence_Typo3QuerySettingsInterface extends Tx_Extbase_
         * Returns the state, if the QueryResult should be returned unmapped.
         *
         * @return boolean TRUE, if the QueryResult should be returned unmapped; otherwise FALSE.
+        * @api
         */
        public function getReturnRawQueryResult();
        
index 2f78a58..1379a00 100644 (file)
@@ -305,6 +305,7 @@ class Tx_Extbase_Property_Mapper {
         */
        protected function findObjectByUid($dataType, $uid) {
                $query = $this->queryFactory->create($dataType);
+               $query->getQuerySettings()->setRespectSysLanguage(FALSE);
                $result = $query->matching($query->withUid($uid))->execute();
                $object = NULL;
                if (count($result) > 0) {