diff --git a/DependencyInjection/Compiler/AdapterCompilerPass.php b/DependencyInjection/Compiler/AdapterCompilerPass.php index 8bc1f526..abbff5c0 100644 --- a/DependencyInjection/Compiler/AdapterCompilerPass.php +++ b/DependencyInjection/Compiler/AdapterCompilerPass.php @@ -32,7 +32,9 @@ public function process(ContainerBuilder $container) $definition = $container->getDefinition('sonata.core.model.adapter.chain'); if ($container->has('doctrine')) { - $definition->addMethodCall('addAdapter', array(new Reference('sonata.core.model.adapter.doctrine_orm'))); + if (class_exists('\Doctrine\ORM\Version')) { + $definition->addMethodCall('addAdapter', array(new Reference('sonata.core.model.adapter.doctrine_orm'))); + } } else { $container->removeDefinition('sonata.core.model.adapter.doctrine_orm'); } @@ -43,4 +45,4 @@ public function process(ContainerBuilder $container) $container->removeDefinition('sonata.core.model.adapter.doctrine_phpcr'); } } -} \ No newline at end of file +} diff --git a/Model/Adapter/DoctrinePHPCRAdapter.php b/Model/Adapter/DoctrinePHPCRAdapter.php index ac64fae7..bf54e72f 100644 --- a/Model/Adapter/DoctrinePHPCRAdapter.php +++ b/Model/Adapter/DoctrinePHPCRAdapter.php @@ -44,7 +44,7 @@ public function getNormalizedIdentifier($document) return null; } - $manager = $this->registry->getManagerForClass($document); + $manager = $this->registry->getManagerForClass(ClassUtils::getClass($document)); if (!$manager instanceof DocumentManager) { return null; diff --git a/Tests/Model/Adapter/DoctrinePHPCRAdapterTest.php b/Tests/Model/Adapter/DoctrinePHPCRAdapterTest.php index 65e9427d..4daefe68 100644 --- a/Tests/Model/Adapter/DoctrinePHPCRAdapterTest.php +++ b/Tests/Model/Adapter/DoctrinePHPCRAdapterTest.php @@ -99,8 +99,9 @@ public function testNormalizedIdentifierWithValidObject($data, $expected) public static function getFixtures() { return array( - array("/salut", "salut"), - array("/les-gens", "les-gens"), + array('/salut', 'salut'), + array('/les-gens', 'les-gens'), + array('/cms/media/53d00ace7b3a6', 'cms/media/53d00ace7b3a6'), ); } -} \ No newline at end of file +} diff --git a/Twig/Extension/TemplateExtension.php b/Twig/Extension/TemplateExtension.php index 050162cd..445a27cc 100644 --- a/Twig/Extension/TemplateExtension.php +++ b/Twig/Extension/TemplateExtension.php @@ -103,9 +103,10 @@ public function slugify($text) */ public function getUrlsafeIdentifier($model) { - return $this->modelAdapter->getUrlsafeIdentifier($model); - } - + $res = $this->modelAdapter->getUrlsafeIdentifier($model); + return $res; + } + /** * {@inheritdoc} */