Closed juriansluiman closed 12 years ago
hey, do you use the current version of master branch for extensions? there was an issue some time ago.
also annotation namespace should be more specific Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Gedmo\\Mapping\\Annotation', 'path/to/gedmo/lib');
note me, if you still have problems
for instance my silex service config looks like:
<?php
// load proxy configuration settings
$config = new Doctrine\ORM\Configuration;
$config->setProxyDir(__DIR__.'/../tmp');
$config->setProxyNamespace('Proxy');
$config->setAutoGenerateProxyClasses(false);
// load metadata drivers
$annotationReader = new Doctrine\Common\Annotations\AnnotationReader;
$refl = new \ReflectionClass('Gedmo\Version');
$libDir = dirname($refl->getFileName()).'/../../lib';
Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace(
'Gedmo\\Mapping\\Annotation',
$libDir
);
$driverChain = new Doctrine\ORM\Mapping\Driver\DriverChain();
$annotationDriver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver($annotationReader, array(
__DIR__.'/../lib/Gedi/Entity',
$libDir.'/Gedmo/Translatable/Entity',
$libDir.'/Gedmo/Loggable/Entity',
$libDir.'/Gedmo/Tree/Entity',
));
// drivers
$driverChain->addDriver($annotationDriver, 'Gedi\\Entity');
$driverChain->addDriver($annotationDriver, 'Gedmo\\Translatable\\Entity');
$driverChain->addDriver($annotationDriver, 'Gedmo\\Loggable\\Entity');
$driverChain->addDriver($annotationDriver, 'Gedmo\\Tree\\Entity');
$config->setMetadataDriverImpl($driverChain);
// cache
$config->setMetadataCacheImpl(new Doctrine\Common\Cache\ArrayCache);
$config->setQueryCacheImpl(new Doctrine\Common\Cache\ArrayCache);
// event manager
$app['sluggable'] = new Gedmo\Sluggable\SluggableListener;
$app['db.evm']->addEventSubscriber($app['sluggable']);
$app['db.evm']->addEventSubscriber(new Gedmo\Tree\TreeListener);
$app['db.evm']->addEventSubscriber(new Gedmo\Loggable\LoggableListener);
$app['db.evm']->addEventSubscriber(new Gedmo\Timestampable\TimestampableListener);
$translatable = new Gedmo\Translatable\TranslationListener;
$translatable->setTranslatableLocale('en');
$app['db.evm']->addEventSubscriber($translatable);
// create entity manager
return Doctrine\ORM\EntityManager::create($app['db'], $config);
this might happen if you have doctrine common 2.2 version, I would recommend to use 2.1 still
@l3pp4rd Thanks for all the updates. I think I missed the Gedmo\Tree\Entity annotation driver in the driver chain. Also I use a Zend Framework 2 module which ships with Doctrine 2.2 by default. I will have a look to fix both issues and get back with my results :)
I think the issue is fixed to return to the Doctrine 2.1.2 version. I will notify the maintainer of the zf2 module to include the 2.1.2 version with his module. Thanks!
I currently trying to adapt the mapping to doctrine common 2.2, but ODM is also late for changes and does not work with latest components
I have a similar issue as issue #117, where I get an exception "Tree object class Class\Name must have tree metadata at this point". As far as I know, I register the namespace correctly:
I set up the listener:
The eventmanager is passed to the connection, the connection to the entity manager.
My entity:
What I do to trigger the exception:
What's wrong and how can I fix this?