Single Table Inheritance for polls
Since v0.9 t3oodle provides single table inheritance for polls. This allows you to provide own poll types in extensions, easier.
Extbase models t3oodle provide:
-
\FGTCLB\(abstract)T3oodle\ Domain\ Model\ Base Poll \FGTCLB\(final)T3oodle\ Domain\ Model\ Simple Poll \FGTCLB\(final)T3oodle\ Domain\ Model\ Schedule Poll
How to provide new poll type?
- Create a new Extbase model extending from
\FGTCLB\T3oodle\ Domain\ Model\ Base Poll - Overwrite the property
protected $typewith an UpperCamelCase identifier (used in templates and localization identifiers)Name = 'Whatever'; -
Create new TCA override (
EXT:);your_ ext/ Configuration/ TCA/ Overrides/ tx_ t3oodle_ domain_ model_ poll. php $GLOBALS['TCA']['tx_t3oodle_domain_model_poll']['types'][\Vendor\YourExt\Domain\Model\WhateverPoll::class] = [ 'showitem' => $GLOBALS['TCA']['tx_t3oodle_domain_model_poll']['types'][\FGTCLB\T3oodle\Domain\Model\SimplePoll::class]['showitem'] ]; $GLOBALS['TCA']['tx_t3oodle_domain_model_poll']['columns']['type']['config']['items'][] = [ 'Whatever Poll', \Vendor\YourExt\Domain\Model\WhateverPoll::class ];Copied! -
Extend Extbase mapping:
config.tx_extbase { persistence { classes { FGTCLB\T3oodle\Domain\Model\BasePoll { subclasses { \Vendor\YourExt\Domain\Model\WhateverPoll = Vendor\YourExt\Domain\Model\WhateverPoll } } Vendor\YourExt\Domain\Model\WhateverPoll { mapping { tableName = tx_t3oodle_domain_model_poll recordType = Vendor\YourExt\Domain\Model\WhateverPoll } } } } }Copied!Note
This example is for TYPO3 v9, written in TypoScript. In v10 you should use PHP syntax instead.
- When you use Routing Enhancer, you need to add the new poll type, to routing aspect
poll-map and localeMaptype - Add a partial for the new typeName e.g.
EXT:, keep in mind that you also need to register the partial path in t3oodle's TypoScriptyour_ ext/ Resources/ Private/ Partials/ Poll/ Form Fields/ Options/ Type/ Whatever. html -
There are also several translation keys (in locallang.xlf), which have the typeName appended:
header.new. header.edit. header.show. poll.type.
-
To provide validation for your new poll object, you just need to provide an Extbase validator matching this naming convention:
\Vendor\<- when this is your poll entityYour Ext\ Domain\ Model\ Whatever Poll \Vendor\<- this is the validator to be expectedYour Ext\ Domain\ Validator\ Whatever Poll Validator
Important
If the validator is not existing, validation for this poll entity is disabled!