Skip to content

Instantly share code, notes, and snippets.

@vaurat
Created July 24, 2013 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vaurat/6070898 to your computer and use it in GitHub Desktop.
Save vaurat/6070898 to your computer and use it in GitHub Desktop.
i have below :
my/Bundle/Document/Parent.php
my/Bundle/Document/Childs/Son.php
my/Bundle/Document/Childs/Daughter.php
and when i execute fixtures with persist/flush of a Son, i get :
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: class_parents(): Class my\Bundle\Document\Childs\Parent
does not exist and could not be loaded in /var/www/cogitosum/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php line 40
The Son think his Parent is close to him, but it's wrong : he's upstairs !!!
What does i have to do to fix that ?
my\Bundle\Document\Parent.php :
====================================================
namespace cogito\GCBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/**
* @package my\Bundle\Document
* @ODM\Document (collection="Individual")
* @ODM\InheritanceType("SINGLE_COLLECTION")
* @ODM\DiscriminatorField(fieldName="discr")
* @ODM\DiscriminatorMap({
* "Son" = "my\Bundle\Document\Childs\Son",
* "Daughter" = "my\Bundle\Document\Childs\Daughter"
* })
*/
abstract class Parent
{...
my\Bundle\Document\Childs\Son.php :
==================================================
namespace my\Bundle\Document\Childs;
use my\Bundle\Document\Parent as Parent;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/**
* @package my\Bundle\Document\Childs
* @ODM\Document
*/
class Son extends Parent
{...
my\Bundle\Document\Childs\Daughter.php:
=====================================================
namespace my\Bundle\Document\Childs;
use my\Bundle\Document\Parent as Parent;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/**
* @package my\Bundle\Document\Childs
* @ODM\Document
*/
class Daughter extends Parent
{...
this is my autoload.php:
===================================================
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
/**
* @var $loader ClassLoader
*/
$loader = require __DIR__.'/../vendor/autoload.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
AnnotationDriver::registerAnnotationClasses();
return $loader;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment