Those of you using Bisna library to easily hook Doctrine 2 ORM into Zend Framework, may find that it is incompatible with Doctrine 2.1. The reason is the rewritten annotation reader in Doctrine 2.1, which Bisna doesn’t support. However, its easy to update it.
In Bisna/Application/Container/DoctrineContainer.php, find the method startORMMetadata (should be the last method in the file), and replace it with the following (apologies for messed up indentation :():
private function startORMMetadata(array $config = array())
{
$metadataDriver = new \Doctrine\ORM\Mapping\Driver\DriverChain();
// Default metadata driver configuration
$defaultMetadataDriver = array(
'adapterClass' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'mappingNamespace' => '',
'mappingDirs' => array(),
'annotationReaderClass' => 'Doctrine\Common\Annotations\AnnotationReader',
'annotationReaderCache' => $this->defaultCacheInstance,
'annotationReaderNamespaces' => array()
);
foreach ($config as $driver) {
$driver = array_replace_recursive($defaultMetadataDriver, $driver);
// Register the ORM Annotations in the AnnotationRegistry
\Doctrine\Common\Annotations\AnnotationRegistry::registerFile(
APPLICATION_PATH . '/../library/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
$reflClass = new \ReflectionClass($driver['adapterClass']);
$nestedDriver = null;
if (
$reflClass->getName() == 'Doctrine\ORM\Mapping\Driver\AnnotationDriver' ||
$reflClass->isSubclassOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver')
) {
$annotationReaderClass = $driver['annotationReaderClass'];
$reader = new $annotationReaderClass();
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
$reader->setIgnoreNotImportedAnnotations(true);
$reader->setEnableParsePhpImports(false);
foreach ($driver['annotationReaderNamespaces'] as $alias => $namespace) {
$reader->setAnnotationNamespaceAlias($namespace, $alias);
}
$annotationReader = new \Doctrine\Common\Annotations\CachedReader(
new \Doctrine\Common\Annotations\IndexedReader($reader),
new \Doctrine\Common\Cache\ArrayCache()
);
$nestedDriver = $reflClass->newInstance($annotationReader, $driver['mappingDirs']);
} else {
$nestedDriver = $reflClass->newInstance($driver['mappingDirs']);
}
$metadataDriver->addDriver($nestedDriver, $driver['mappingNamespace']);
}
if (($drivers = $metadataDriver->getDrivers()) && count($drivers) == 1) {
reset($drivers);
$metadataDriver = $drivers[key($drivers)];
}
return $metadataDriver;
}
You should be good to go. Hopefully this saved you some time in research. I’ll try to push this update to github as well.
Any comments about missed configuration options are always welcomed!