Last active
August 29, 2015 14:15
-
-
Save johnpancoast/eec2e73e6b695a32719c to your computer and use it in GitHub Desktop.
Embedded Mongo Doc Prob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @ODM\MappedSuperclass | |
*/ | |
class BaseFoo | |
{ | |
/** | |
* @var string | |
* @ODM\String | |
* @Assert\Type(type = "string") | |
* @Assert\NotBlank | |
*/ | |
protected $name; | |
} | |
/** | |
* @ODM\Document( | |
* collection="foo", | |
* ) | |
* @ODM\InheritanceType("COLLECTION_PER_CLASS") | |
*/ | |
class Foo extends BaseFoo | |
{ | |
/** | |
* @ODM\Id | |
*/ | |
protected $id; | |
/** | |
* @var string | |
* | |
* Note that this overrides the parent name field since we're adding a unique index. | |
* The base doesn't have this since other children may be embedded docs w/o an index. | |
* | |
* @ODM\String | |
* @Assert\Type(type = "string") | |
* @Assert\NotBlank | |
* @ODM\UniqueIndex | |
*/ | |
protected $name; | |
} | |
/** | |
* @ODM\EmbeddedDocument | |
*/ | |
class EmbeddedFoo extends BaseFoo | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment