Doctrine MongoDB ODM a auto load annotacii
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- bazo
- Člen | 620
caute skusal tu uz niekto spojazdnit doctrine odm pre mongo db? konkretne mam problem s nacitanim mapovacich anotacii.
zakazdym na mna vybehne Doctrine\Common\Annotations\AnnotationException:
[Semantical Error] The annotation "@Document" in class Documents\User was never imported. Did you maybe forget to add a "use" statement for this annotation?
tovarnicka na document manager vyzera takto
<?php
public static function create(Container $container)
{
$params = $container->params;
$tempDirectory = $params['tempDir'];
$documentsDirectory = $params['appDir'].'/models/Documents';
//include $params['libsDir'].'/Doctrine/ODM/MongoDB/Mapping/Annotations/DoctrineAnnotations.php';
$config = new Configuration();
$config->setProxyDir($tempDirectory . '/Proxies');
$config->setProxyNamespace('Proxies');
$config->setHydratorDir($tempDirectory . '/Hydrators');
$config->setHydratorNamespace('Hydrators');
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\ODM\MongoDB\Mapping\Annotations\\');
$driverImpl = new AnnotationDriver($reader, $documentsDirectory);
$config->setMetadataDriverImpl($driverImpl);
$dm = DocumentManager::create(new Connection(), $config);
return $dm;
}
?>
ak odkomentujem riadok s include tak exception zmizne. pritom tie triedy su uz indexovane robot loaderom.
treba este nieco nastavit niekde v doctrine alebo kde moze byt chyba? dakujem
- Filip Procházka
- Moderator | 4668
Od verze 2.1 Doctrine\Common se annotace automaticky nenačítají, řešení je zde.