I’m trying to set up a Base-class for my Typo3 Flow projects. It should contain the “created at” and the “updated at” date. Since Doctrine allows you to use inheritance mapping, I want to make my baseclass a “MappedSuperclass”.
BaseClass.php:
/**
* @Flow\Entity
* @ORM\MappedSuperclass
*/
class BaseClass {
/**
* @var \DateTime
* @ORM\Column(type="datetime")
*/
protected $created;
/**
* @var \DateTime
* @ORM\Column(type="datetime")
*/
protected $updated;
...
Component.php:
/**
* @Flow\Entity
* @ORM\InheritanceType("SINGLE_TABLE")
*/
class Component extends BaseClass{
If i try to use the "flow doctrine:update" command the following error message pops up:
Uncaught Exception Entity '...\Domain\Model\BaseClass' has no method 'Flow_Aop_Proxy_fixMethodsAndAdvicesArrayForDoctrineProxies' to be registered as lifecycle callback.
So is it possible to use model inheritance in TYPO3 Flow?
I found out one way to do it.
Just make your BaseClass abstract and add all the additional annotations like this:
And extend your models like that:
The table of SomeModel will now have the attributes from the BaseClass. But BaseClass itself is not represented in the database schema.
Maybe you are also able to use traits for more complex solutions.