[Flow] How to define targetEntity in abstractClass

Alexander Wende a_wende at web.de
Mon Jul 21 10:38:37 CEST 2014


I'm trying to build a "revision-safe" model for some entities like pages, news and so on.
Page and news model extends the revising model which contains pointers to the previous revision and the next revision.

This is the abstractRevision class extended by page and news model:


namespace COMPANY\Revising\Domain\Model;

use TYPO3\Flow\Annotations as Flow;
use Doctrine\ORM\Mapping as ORM;

abstract class AbstractRevision implements RevisionInterface {

    /**
     * Vorherige Revision
     * Nicht gesetzt wenn es sich um die erste Revision handelt
     * @var \COMPANY\Revising\Domain\Model\RevisionInterface
     * @ORM\OneToOne(mappedBy="nextRevision")
     * @ORM\Column(nullable=true)
     */
    protected $previousRevision;

    /**
     * Nächste Revision
     * Nicht gesetzt falls es sich um die neueste Revision handelt.
     * @var \COMPANY\Revising\Domain\Model\RevisionInterface
     * @ORM\OneToOne(mappedBy="previousRevision")
     * @ORM\Column(nullable=true)
     */
    protected $nextRevision;

    /**
     * @var integer
     * @Flow\Validate(type="Integer")
     * @ORM\Column(type="integer")
     */
    protected $revisionNumber = 0;

[ ...]


But how did I tell doctrine which concrete entities should be used in page or news model? I can't use the targetEntity anotation because the concrete entity depends on the class which extends the abstract class.

I tried to use an interface but only the revionsnumber column is created when I call doctrine:update.
I also tried to use the objects.yaml in the page package to override the interface like

COMPANY\Revising\Domain\Model\RevisionInterface:
  className: 'COMPANY\Page\Domain\Model\Page'

But it didn't worked. 

What I'm doing wrong??


More information about the Flow mailing list