[TYPO3-dev] EXTBASE :: Domain model inheritance for entities

Steffen Wickham steffen at gaming-inc.de
Thu Aug 29 12:05:42 CEST 2013


Hello Philipp,

I'd like to thank you for your help! :)
After a week I'd stay in bed, I got everything up and running. All types
of questions can now be entered and extends the base object. For the
normal backend user it is a really nice and easy way to enter all data
through the IRRE fields. I wouldn't archieve it without your help!

I just get messed around with the repository for the quiz, maybe you
could help me another time, please?! :)
Every time I execute a query on the quiz and try to get the questions, I
only get a ObjectStorage object full of "Question" objects but expect to
get the right child classes like "MultipleChoiceQuestion" within the
result set. If I do a var_dump on the objectStorage, it will even dump
the correct type-field like:

["type":protected]=>
        string(41) "Tx_LgQuizbasetypes_MultipleChoiceQuestion"

I only added a Repository for the Quiz object itself but no one for the
Question base class nor each kind of Question.

Do you know how I can fix that so I get the correct Question object
through the QuizRepository?!

Thanks again!
Steffen




Am 19.08.13 09:31, schrieb Philipp:
> Basically you simply have to add the types column to the columns array
> and add the field to your types-list.
> That sounds a little bit confusing. So lets assume you have 4 types
> for your question model. Then you have a type-field-list for each of
> them. In this list you place the fields, that are shown in the TCE
> Form. The types field itself (where you can change the type of your
> question) has to be existent in all types-field-lists. Lets just
> explain it using some code-snippets:
>
> Registering your table in ext_tables.php
> $TCA['tx_lgquizbase_domain_model_question'] = array(
> 'ctrl' => array(
> // general settings like title, label, sorting, enablefields,
> versioning, translationhandling, searchfelds, icons, etc
> 'type' => 'type' // this is the type-change column
> ),
> 'interface' => array(
> // appearance settings for T3Backend
> ),
> 'columns' => array(
> 'type' => array(
> // label
> 'config' => array( 'type' => 'select',
> 'size' => 1,
> 'items' => array(
> array('Text', 'Tx_LgQuizbasetypes_TextInputQuestion'),
> array('Multiple Choice','Tx_LgQuizbasetypes_MultipleChoiceQuestion'),
> array('Sorting', Tx_LgQuizbasetypes_SortingQuestion')
> )
> 'default' => 'Tx_LgQuizbasetypes_TextInputQuestion'
> )
> )
> ),
> // other field settings like questionTitle and so on...
> ),
> 'types' => array(
> '1' => array('showitem' => 'type'),
> 'Tx_LgQuizbasetypes_TextInputQuestion' => array('showitem' =>
> 'type,title,question'),
> 'Tx_LgQuizbasetypes_MultipleChoiceQuestion => array('showitem' =>
> 'type,title,qestion,answers'),
> 'Tx_LgQuizbasetypes_SortingQuestion' => array('showitem' =>
> 'type,title,question,answers')
> ),
> 'pallettes' => array(
> // define pallettes for TCE FORM
> )
> );
>
> Then you should define question as IRRE field in your quiz. Also you
> should define Answers as IRRE Field in quesion, so you would be able
> to create a new quit, adjust it, add questions, change the question
> type, add answers, save the whole bunch of records and done....
>
>
> just typed this in here, there my be some syntax errors or something
> missing, but basically it should work this way.
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev




More information about the TYPO3-dev mailing list