[!!!][~TASK] Extbase (Persistence): Changed the default behavior of the record type...
authorJochen Rau <j.rau@web.de>
Wed, 21 Apr 2010 12:33:46 +0000 (12:33 +0000)
committerJochen Rau <j.rau@web.de>
Wed, 21 Apr 2010 12:33:46 +0000 (12:33 +0000)
typo3/sysext/extbase/Classes/Persistence/Backend.php
typo3/sysext/extbase/Classes/Persistence/Mapper/DataMap.php
typo3/sysext/extbase/Classes/Persistence/Mapper/DataMapFactory.php
typo3/sysext/extbase/Classes/Persistence/Storage/Typo3DbBackend.php
typo3/sysext/extbase/ext_tables.php
typo3/sysext/extbase/ext_tables.sql
typo3/sysext/extbase/ext_typoscript_setup.txt

index dd91b09..82bc5af 100644 (file)
@@ -816,8 +816,8 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                if ($dataMap->getModificationDateColumnName() !== NULL) {
                        $row[$dataMap->getModificationDateColumnName()] = $GLOBALS['EXEC_TIME'];
                }
-               if ($dataMap->getRecordTypeColumnName() !== NULL) {
-                       $row[$dataMap->getRecordTypeColumnName()] = $className; // FIXME add mapping
+               if ($dataMap->getRecordTypeColumnName() !== NULL && $dataMap->getRecordType() !== NULL) {
+                       $row[$dataMap->getRecordTypeColumnName()] = $dataMap->getRecordType();
                }
                if ($object->_isNew() && !isset($row['pid'])) {
                        $row['pid'] = $this->determineStoragePageIdForNewRecord($object);
index e41e0d8..4bce3b4 100644 (file)
@@ -134,7 +134,7 @@ class Tx_Extbase_Persistence_Mapper_DataMap {
         * @param string $recordType The record type
         * @param array $subclasses The subclasses
         */
-       public function __construct($className, $tableName, $recordType, array $subclasses = array()) {
+       public function __construct($className, $tableName, $recordType = NULL, array $subclasses = array()) {
                $this->setClassName($className);
                $this->setTableName($tableName);
                $this->setRecordType($recordType);
index 2b044fe..165c095 100644 (file)
@@ -40,7 +40,7 @@ class Tx_Extbase_Persistence_Mapper_DataMapFactory {
         * @return Tx_Extbase_Persistence_Mapper_DataMap The data map
         */
        public function buildDataMap($className) {
-               $recordType = $className;
+               $recordType = NULL;
                $subclasses = array();
                $tableName = strtolower($className);
                $columnMapping = array();
index 3a76230..f92bd55 100644 (file)
@@ -387,21 +387,23 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                if ($className !== NULL) {
                        $dataMap = $this->dataMapper->getDataMap($className);
                        if ($dataMap->getRecordTypeColumnName() !== NULL) {
-                               $recordSubtypes = array();
+                               $recordTypes = array();
+                               if ($dataMap->getRecordType() !== NULL) {
+                                       $recordTypes[] = $dataMap->getRecordType();
+                               }
                                foreach ($dataMap->getSubclasses() as $subclassName) {
-                                       $recordSubtype = $this->dataMapper->getDataMap($subclassName)->getRecordType();
-                                       if ($recordSubtype !== NULL) {
-                                               $recordSubtypes[] = $recordSubtype;
-                                       } else {
-                                               $recordSubtypes[] = $subclassName;
+                                       $subclassDataMap = $this->dataMapper->getDataMap($subclassName);
+                                       if ($subclassDataMap->getRecordType() !== NULL) {
+                                               $recordTypes[] = $subclassDataMap->getRecordType();
                                        }
                                }
-                               $recordTypes = array_merge(array($dataMap->getRecordType()), $recordSubtypes);
-                               $recordTypeStatements = array();
-                               foreach ($recordTypes as $recordType) {
-                                       $recordTypeStatements[] = $dataMap->getTableName() . '.' . $dataMap->getRecordTypeColumnName() . '=' . $this->databaseHandle->fullQuoteStr($recordType, 'foo');
+                               if (count($recordTypes) > 0) {
+                                       $recordTypeStatements = array();
+                                       foreach ($recordTypes as $recordType) {
+                                               $recordTypeStatements[] = $dataMap->getTableName() . '.' . $dataMap->getRecordTypeColumnName() . '=' . $this->databaseHandle->fullQuoteStr($recordType, 'foo');
+                                       }
+                                       $sql['additionalWhereClause'][] = '(' . implode(' OR ', $recordTypeStatements) . ')';
                                }
-                               $sql['additionalWhereClause'][] = '(' . implode(' OR ', $recordTypeStatements) . ')';
                        }
                }
        }
index 5a25614..c0f2d98 100644 (file)
@@ -23,48 +23,52 @@ if (TYPO3_MODE == 'BE') {
 
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['extbase'][] = 'tx_extbase_utility_extbaserequirementscheck';
 
-$tempColumns = array(
-       'tx_extbase_type' => array(
-               'exclude' => 1,
-               'label'   => 'LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_users.tx_extbase_type',
-               'config' => array(
-                       'type' => 'select',
-                       'items' => array(
-                               array('LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_users.tx_extbase_type.0', '0'),
-                               array('LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_users.tx_extbase_type.Tx_Extbase_Domain_Model_FrontendUser', 'Tx_Extbase_Domain_Model_FrontendUser')
-                       ),
-                       'size' => 1,
-                       'maxitems' => 1,
-                       'default' => '0'
-               )
-       )
-);
 t3lib_div::loadTCA('fe_users');
-t3lib_extMgm::addTCAcolumns('fe_users', $tempColumns, 1);
-t3lib_extMgm::addToAllTCAtypes('fe_users', 'tx_extbase_type');
-$TCA['fe_users']['ctrl']['type'] = 'tx_extbase_type'; // TODO handle already set 'type'
+if (!isset($TCA['fe_groups']['ctrl']['type'])) {
+       $tempColumns = array(
+               'tx_extbase_type' => array(
+                       'exclude' => 1,
+                       'label'   => 'LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_users.tx_extbase_type',
+                       'config' => array(
+                               'type' => 'select',
+                               'items' => array(
+                                       array('LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_users.tx_extbase_type.0', '0'),
+                                       array('LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_users.tx_extbase_type.Tx_Extbase_Domain_Model_FrontendUser', 'Tx_Extbase_Domain_Model_FrontendUser')
+                               ),
+                               'size' => 1,
+                               'maxitems' => 1,
+                               'default' => '0'
+                       )
+               )
+       );
+       t3lib_extMgm::addTCAcolumns('fe_users', $tempColumns, 1);
+       t3lib_extMgm::addToAllTCAtypes('fe_users', 'tx_extbase_type');
+       $TCA['fe_users']['ctrl']['type'] = 'tx_extbase_type';
+}
 $TCA['fe_users']['types']['Tx_Extbase_Domain_Model_FrontendUser'] = $TCA['fe_users']['types']['0'];
 
-$tempColumns = array(
-       'tx_extbase_type' => array(
-               'exclude' => 1,
-               'label'   => 'LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_groups.tx_extbase_type',
-               'config' => array(
-                       'type' => 'select',
-                       'items' => array(
-                               array('LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_groups.tx_extbase_type.0', '0'),
-                               array('LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_groups.tx_extbase_type.Tx_Extbase_Domain_Model_FrontendUserGroup', 'Tx_Extbase_Domain_Model_FrontendUserGroup')
-                       ),
-                       'size' => 1,
-                       'maxitems' => 1,
-                       'default' => '0'
-               )
-       )
-);
 t3lib_div::loadTCA('fe_groups');
-t3lib_extMgm::addTCAcolumns('fe_groups', $tempColumns, 1);
-t3lib_extMgm::addToAllTCAtypes('fe_groups', 'tx_extbase_type');
-$TCA['fe_groups']['ctrl']['type'] = 'tx_extbase_type'; // TODO handle already set 'type'
+if (!isset($TCA['fe_groups']['ctrl']['type'])) {
+       $tempColumns = array(
+               'tx_extbase_type' => array(
+                       'exclude' => 1,
+                       'label'   => 'LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_groups.tx_extbase_type',
+                       'config' => array(
+                               'type' => 'select',
+                               'items' => array(
+                                       array('LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_groups.tx_extbase_type.0', '0'),
+                                       array('LLL:EXT:extbase/Resources/Private/Language/locallang_db.xml:fe_groups.tx_extbase_type.Tx_Extbase_Domain_Model_FrontendUserGroup', 'Tx_Extbase_Domain_Model_FrontendUserGroup')
+                               ),
+                               'size' => 1,
+                               'maxitems' => 1,
+                               'default' => '0'
+                       )
+               )
+       );
+       t3lib_extMgm::addTCAcolumns('fe_groups', $tempColumns, 1);
+       t3lib_extMgm::addToAllTCAtypes('fe_groups', 'tx_extbase_type');
+       $TCA['fe_groups']['ctrl']['type'] = 'tx_extbase_type';
+}
 $TCA['fe_groups']['types']['Tx_Extbase_Domain_Model_FrontendUserGroup'] = $TCA['fe_groups']['types']['0'];
 
 ?>
\ No newline at end of file
index 9f10cfc..4e3abcb 100644 (file)
@@ -26,9 +26,9 @@ CREATE TABLE tx_extbase_cache_reflection_tags (
 ) ENGINE=InnoDB;
 
 CREATE TABLE fe_users (
-       tx_extbase_type varchar(255)
+       tx_extbase_type varchar(255) DEFAULT '' NOT NULL,
 );
 
 CREATE TABLE fe_groups (
-       tx_extbase_type varchar(255)
+       tx_extbase_type varchar(255) DEFAULT '' NOT NULL,
 );
\ No newline at end of file
index 479d026..a3db992 100644 (file)
@@ -6,6 +6,7 @@ config.tx_extbase {
                        Tx_Extbase_Domain_Model_FrontendUser {
                                mapping {
                                        tableName = fe_users
+                                       recordType = Tx_Extbase_Domain_Model_FrontendUser
                                        columns {
                                                lockToDomain.mapOnProperty = lockToDomain
                                        }
@@ -14,6 +15,7 @@ config.tx_extbase {
                        Tx_Extbase_Domain_Model_FrontendUserGroup {
                                mapping {
                                        tableName = fe_groups
+                                       recordType = Tx_Extbase_Domain_Model_FrontendUserGroup
                                        columns {
                                                lockToDomain.mapOnProperty = lockToDomain
                                        }