-
-
Save Ocramius/6078317 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
use Doctrine\Common\Annotations\AnnotationRegistry; | |
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver; | |
use Doctrine\Common\Annotations\AnnotationReader; | |
use Doctrine\ODM\MongoDB\DocumentManager; | |
/* @var $loader \Composer\Autoload\ClassLoader */ | |
$loader = require __DIR__.'/vendor/autoload.php'; | |
AnnotationRegistry::registerLoader(array($loader, 'loadClass')); | |
AnnotationDriver::registerAnnotationClasses(); | |
require_once __DIR__ . '/Parent.php'; | |
require_once __DIR__ . '/Son.php'; | |
require_once __DIR__ . '/Daughter.php'; | |
$driver = new AnnotationDriver(new AnnotationReader(), array(__DIR__)); | |
// @todo instantiate $connection | |
// @todo instantiate $configuration (with provided metadata driver) | |
$dm = DocumentManager::create($connection, $configuration); | |
var_dump($dm->getMetadataFactory()->getAllMetadata()); |
This file contains 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
{ | |
"require": { | |
"doctrine/mongodb-odm": "1.0.0-BETA9@BETA" | |
} | |
} |
This file contains 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
<?php | |
namespace my\Bundle\Document\Childs; | |
use my\Bundle\Document\Parent as Parent; | |
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; | |
/** | |
* @ODM\Document | |
*/ | |
class Daughter extends Parent | |
{ | |
// ... | |
} |
This file contains 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
[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 |
This file contains 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
<?php | |
namespace my\GCBundle\Document; | |
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; | |
/** | |
* @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 | |
{ | |
// ... | |
} |
This file contains 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
#/bin/sh | |
curl -s https://getcomposer.org/installer | php | |
php composer.phar install | |
php Bootstrap.php |
This file contains 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
<?php | |
namespace my\Bundle\Document\Childs; | |
use my\Bundle\Document\Parent as Parent; | |
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; | |
/** | |
* @ODM\Document | |
*/ | |
class Son extends Parent | |
{ | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment