Hi there.
I'd like to use i18n with Doctrine2 so i found gedmo
https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md
I want to setup my configuration file with the following code:
http://www.doctrine-project.org/blog/doctrine2-behavioral-extensions#setup
//setting the drivers
$chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();
$yourDefaultDriverImpl = new \Doctrine\ORM\Mapping\Driver\YamlDriver('/yml/mapping/files'); // only an example
$translatableDriverImpl = $doctrineOrmConfig->newDefaultAnnotationDriver(
'/path/to/library/DoctrineExtensions/lib/Gedmo/Translatable/Entity'
);
$chainDriverImpl->addDriver($yourDefaultDriverImpl, 'Entity');
$chainDriverImpl->addDriver($translatableDriverImpl, 'Gedmo\Translatable');
$doctrineOrmConfig->setMetadataDriverImpl($chainDriverImpl);
// attach listener to event manager
$evm = new \Doctrine\Common\EventManager();
$translationListener = new \Gedmo\Translatable\TranslationListener();
$translationListener->setTranslatableLocale('en_us');
$evm->addEventSubscriber($translationListener);
Here is what i did in my configuration file:
// driver settings
'entity_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'namespace' => 'Entity',
'paths' => array(APPLICATION_PATH . '/model/Entity')
),
'translatable_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'namespace' => 'Gedmo\Translatable',
'paths' => array(APPLICATION_PATH . '/vendor/Gedmo/Translatable/Entity')
),
'orm_driver_chain' => array(
'parameters' => array(
'drivers' => array(
'application_entity_driver' => $settings['entity_driver'],
'application_translatable_driver' => $settings['translatable_driver']
),
'cache' => $settings['cache']
)
),
'orm_evm' => array(
'parameters' => array(
'opts' => array(
'subscribers' => array(
'application_translatable_listener' => 'Gedmo\Translatable\TranslatableListener',
)
)
)
),
The following line:
'application_translatable_listener' => 'Gedmo\Translatable\TranslatableListener',
causes an arror:
Catchable fatal error: Argument 1 passed to Gedmo\Translatable\TranslatableListener::getTranslationClass() must be an instance of Gedmo\Translatable\Mapping\Event\TranslatableAdapter, instance of Gedmo\Mapping\Event\Adapter\ORM given, called in \vendor\Gedmo\Translatable\TranslatableListener.php on line 355 and defined in \vendor\Gedmo\Translatable\TranslatableListener.php on line 159
So i can't attach listener to event manager.
David