Skip to content

Instantly share code, notes, and snippets.

@johnpancoast
Last active August 29, 2015 14:15
Show Gist options
  • Save johnpancoast/eec2e73e6b695a32719c to your computer and use it in GitHub Desktop.
Save johnpancoast/eec2e73e6b695a32719c to your computer and use it in GitHub Desktop.
Embedded Mongo Doc Prob
/**
* @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