[+BUGFIX] (Persistence) Make Typo3QuerySettings exchangeable
authorMarc Bastian Heinrichs <heinrichs@mbh-web.de>
Sun, 6 Mar 2011 15:59:07 +0000 (16:59 +0100)
committerBastian Waidelich <bastian@typo3.org>
Mon, 7 Mar 2011 15:58:55 +0000 (16:58 +0100)
Let objectManager create querySettings object by
Tx_Extbase_Persistence_QuerySettingsInterface in
Tx_Extbase_Persistence_QueryFactory and remove obsolete instanceof
check in Typo3DbBackend

Fixes: #13191

Change-Id: I5ba9dbafeb8baa13d028fdb4f15c7bc9c6dcbd91

typo3/sysext/extbase/Classes/Persistence/QueryFactory.php
typo3/sysext/extbase/Classes/Persistence/Storage/Typo3DbBackend.php
typo3/sysext/extbase/ext_localconf.php
typo3/sysext/extbase/ext_typoscript_setup.txt

index 93d1d8d..58f10fb 100644 (file)
@@ -66,7 +66,7 @@ class Tx_Extbase_Persistence_QueryFactory implements Tx_Extbase_Persistence_Quer
         */
        public function create($className) {
                $query = $this->objectManager->create('Tx_Extbase_Persistence_QueryInterface', $className);
-               $querySettings = $this->objectManager->create('Tx_Extbase_Persistence_Typo3QuerySettings');
+               $querySettings = $this->objectManager->create('Tx_Extbase_Persistence_QuerySettingsInterface');
                $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
                $querySettings->setStoragePageIds(t3lib_div::intExplode(',', $frameworkConfiguration['persistence']['storagePid']));
                $query->setQuerySettings($querySettings);
index 05a9b07..db182df 100644 (file)
@@ -768,16 +768,14 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * @return void
         */
        protected function addAdditionalWhereClause(Tx_Extbase_Persistence_QuerySettingsInterface $querySettings, $tableName, &$sql) {
-               if ($querySettings instanceof Tx_Extbase_Persistence_Typo3QuerySettings) {
-                       if ($querySettings->getRespectEnableFields()) {
-                               $this->addEnableFieldsStatement($tableName, $sql);
-                       }
-                       if ($querySettings->getRespectSysLanguage()) {
-                               $this->addSysLanguageStatement($tableName, $sql);
-                       }
-                       if ($querySettings->getRespectStoragePage()) {
-                               $this->addPageIdStatement($tableName, $sql, $querySettings->getStoragePageIds());
-                       }
+               if ($querySettings->getRespectEnableFields()) {
+                       $this->addEnableFieldsStatement($tableName, $sql);
+               }
+               if ($querySettings->getRespectSysLanguage()) {
+                       $this->addSysLanguageStatement($tableName, $sql);
+               }
+               if ($querySettings->getRespectStoragePage()) {
+                       $this->addPageIdStatement($tableName, $sql, $querySettings->getStoragePageIds());
                }
        }
 
index 6625930..71ae4b5 100644 (file)
@@ -24,12 +24,13 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_extb
        ),
 );
 
-// We need to set the default implementation for the Storage Backend
+// We need to set the default implementation for Storage Backend & Query Settings
 // the code below is NO PUBLIC API! It's just to make sure that
 // Extbase works correctly in the backend if the page tree is empty or no
 // template is defined.
 $extbaseObjectContainer = t3lib_div::makeInstance('Tx_Extbase_Object_Container_Container'); // Singleton
 $extbaseObjectContainer->registerImplementation('Tx_Extbase_Persistence_Storage_BackendInterface', 'Tx_Extbase_Persistence_Storage_Typo3DbBackend');
+$extbaseObjectContainer->registerImplementation('Tx_Extbase_Persistence_QuerySettingsInterface', 'Tx_Extbase_Persistence_Typo3QuerySettings');
 unset($extbaseObjectContainer);
 
 # $GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:extbase/Classes/Persistence/Hook/TCEMainValueObjectUpdater.php:tx_Extbase_Persistence_Hook_TCEMainValueObjectUpdater';
index 33b9a32..ea830eb 100644 (file)
@@ -3,6 +3,9 @@ config.tx_extbase {
                Tx_Extbase_Persistence_Storage_BackendInterface {
                        className = Tx_Extbase_Persistence_Storage_Typo3DbBackend
                }
+               Tx_Extbase_Persistence_QuerySettingsInterface {
+                       className = Tx_Extbase_Persistence_Typo3QuerySettings
+               }
        }
        mvc {
                requestHandlers {