[TYPO3-mvc] [!!!] FYI: Implemented first version of single table inheritance.

Andreas Kießling andreas.kiessling at web.de
Sun Apr 18 15:21:13 CEST 2010


Hi Jochen,

i tested the new feature, but it gave me quite some headaches when using 
it with my very simple DAM model.

Just for the record: DAM uses the field media_type --> text (1), image 
(2), audio (3) etc.


model from my own table:
/**
  * Getter for files
  *
  * @return 
Tx_Extbase_Persistence_ObjectStorage<Tx_Exttest_Domain_Model_Dam> files
  */
public function getFiles() {
   return $this->files;
}

without setting any recordType, this constraint is built for the files:
additionalWhereClause: (tx_dam.media_type='Tx_Exttest_Domain_Model_Dam')
--> no record can be found



Configuring the recordType in setup.txt

config.tx_extbase {
   persistence{
     classes {
       Tx_Exttest_Domain_Model_Dam {
         mapping {
           tableName = tx_dam
           recordType = 2
         }
       }
     }
   }
}

--> additionalWhereClause: (tx_dam.media_type='2')

only images are returned

So to get all elements, a class for each type must be implemented and 
configured in TS.

config.tx_extbase {
   persistence{
     classes {
       Tx_Exttest_Domain_Model_Dam {
         mapping {
           tableName = tx_dam
         }
         subclasses {
           Tx_Exttest_Domain_Model_Damimage = 
Tx_Exttest_Domain_Model_Damimage
           Tx_Exttest_Domain_Model_Damtext = Tx_Exttest_Domain_Model_Damtext
         }
       }
       Tx_Exttest_Domain_Model_Damtext {
         mapping {
         tableName = tx_dam
         recordType = 1
         }
       }
       Tx_Exttest_Domain_Model_Damimage {
         mapping {
         tableName = tx_dam
         recordType = 2
         }
       }
       ....
     }
   }
}

--> additionalWhereClause: 
(tx_dam.media_type='Tx_Exttest_Domain_Model_Dam' OR 
tx_dam.media_type='2' OR tx_dam.media_type='1')

If i want to have different visual output in the frontend, then i will 
have to distinguish the media_type in my template anyway, so i think it 
would be great to be able to skip the type check though it may be 
configured in ext_tables.php or maybe provide a list of types that a 
class can handle:

Tx_Exttest_Domain_Model_Dam {
   mapping {
     tableName = tx_dam
     recordTypes = 1,2,3,4,5
   }
}
could result in (tx_dam.media_type IN (1,2,3,4,5))

Greets,
Andreas



More information about the TYPO3-project-typo3v4mvc mailing list