1

I'm using doctrine mongodb with symfony framework, I have two Documents A and B, B extends from A and I use a discriminator map, A looks like this:

/**
 * My\NameSpace\A
 *
 * @MongoDB\Document(
 *   collection="as",
 *   requireIndexes=true
 * )
 * @MongoDB\DiscriminatorField(fieldName="type")
 * @MongoDB\DiscriminatorMap({
 *   "TYPEA"="A",
 *   "TYPEB"="B",
 * })
 * @MongoDB\DefaultDiscriminatorValue("TYPEA")
 */

class A {
    ...
}

and B extends from A

Class B extends A {
    ....
}

Now for example I have a object

$a = $dm->getRepository('MyNameSpace:A')->findOneById('...');

is there a way to get the discriminator value of $a? i.e. see whether $a is a A or a B? Thanks!

luchaninov
  • 6,792
  • 6
  • 60
  • 75
user2810081
  • 589
  • 1
  • 8
  • 27

0 Answers0