Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

[WIP] Fixes for PHPCR-ODM #82

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions DependencyInjection/Compiler/AdapterCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the doctrine service is always present when the DoctrinePhpcrBundle is activated - but this does not mean the ORM is installed.

$definition->addMethodCall('addAdapter', array(new Reference('sonata.core.model.adapter.doctrine_orm')));
}
} else {
$container->removeDefinition('sonata.core.model.adapter.doctrine_orm');
}
Expand All @@ -43,4 +45,4 @@ public function process(ContainerBuilder $container)
$container->removeDefinition('sonata.core.model.adapter.doctrine_phpcr');
}
}
}
}
2 changes: 1 addition & 1 deletion Model/Adapter/DoctrinePHPCRAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions Tests/Model/Adapter/DoctrinePHPCRAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
);
}
}
}
7 changes: 4 additions & 3 deletions Twig/Extension/TemplateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ public function slugify($text)
*/
public function getUrlsafeIdentifier($model)
{
return $this->modelAdapter->getUrlsafeIdentifier($model);
}

$res = $this->modelAdapter->getUrlsafeIdentifier($model);
return $res;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this?

}

/**
* {@inheritdoc}
*/
Expand Down