php - Multiple level of different kind of inheritance -


for project, i'm trying use inheritance feature of doctrine. need represent medias (through different tables : 1 table uploaded documents, 1 linked videos, ... , on).

but, videos can vary provider provider (such youtube, dailymotion, name it). so, thinking of doing inheritance, proper video table, through single_table inheritance.

but, when declare entities, seems if add single_table inheritance annotation on abstractvideo entity, extends abstractmedia entity, video table never created (nor detected). here snippet of these 2 entities :

<?php namespace acme\demo\entity;  use datetime;  use doctrine\orm\mapping orm;  /**  * @orm\entity  * @orm\table(name="media")  * @orm\inheritancetype("joined")  * @orm\discriminatorcolumn(name="type", type="string")  */ abstract class abstractmedia {     /**      * @orm\id      * @orm\column(type="integer")      * @orm\generatedvalue(strategy="auto")      */     private $id;      // other fields }  /**  * @orm\entity  * @orm\table(name="video")  * @orm\inheritancetype("single_table")  * @orm\discriminatorcolumn(name="provider", type="string")  * @orm\discriminatormap({})  */ abstract class abstractvideo extends abstractmedia {     /** @orm\column(type="string") */     private $name;      // other fields } 

i tried have mapped entity foo entity, extending abstractvideo, when try persist something, says not valid entity.

any ideas, or should avoid such deep inheritance ? thanks

not sure if need, production code use.

we inherit file, other entities, , inherited. important part add inheriting(extending) entities disciminator map.

/**  * file  *  * @orm\table(name = "file")  * @orm\entity(repositoryclass="living\apibundle\entity\file\filerepository")  * @orm\inheritancetype("joined")  * @orm\discriminatorcolumn(name="type", type="string", length=64)  * @orm\discriminatormap({  *      "file"  = "something\entity\file\file",  *      "image" = "something\entity\image\image",  *      "specialimage" = "something\entity\image\specialimage",  * })  */ class file implements fileentityinterface  .....  /**  * imagefile  *  * @orm\table(name="image")  * @orm\entity(repositoryclass="living\apibundle\entity\image\imagerepository")  */ class image extends file implements imageentityinterface 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -