Skip to content

Commit

Permalink
Merge pull request #486 from symfony-cmf/fix-persistence-3
Browse files Browse the repository at this point in the history
no longer register CmfRoutingBundle alias when using doctrine/persistence 3
  • Loading branch information
dbu authored Jun 3, 2023
2 parents 19b4dc9 + 028b3d7 commit e90e861
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ jobs:
tools: 'composer:v2'

- name: Install Symfony Flex
run: composer global require --no-progress --no-scripts --no-plugins symfony/flex
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins symfony/flex
- name: Install dependencies with Composer
uses: ramsey/composer-install@v1
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

3.0.2
-----

* Do not register CmfRoutingBundle alias for ORM / PHPCR-ODM when we have doctrine/persistence 3.x as the short alias is no longer supported.

3.0.1
-----

Expand Down
15 changes: 13 additions & 2 deletions src/CmfRoutingBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass;
use Doctrine\Common\Persistence\PersistentObject;
use Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver as PHPCRXmlDriver;
use Doctrine\ODM\PHPCR\Version as PHPCRVersion;
use Doctrine\ORM\EntityManagerInterface;
Expand Down Expand Up @@ -56,6 +57,11 @@ private function buildPhpcrCompilerPass(ContainerBuilder $container): void
$container->addCompilerPass(
$this->buildBaseCompilerPass(DoctrinePhpcrMappingsPass::class, PHPCRXmlDriver::class, 'phpcr')
);
$aliasMap = [];
// short alias is no longer supported in doctrine/persistence 3, but keep aliasing for BC with old installations
if (class_exists(PersistentObject::class)) {
$aliasMap = ['CmfRoutingBundle' => 'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr'];
}
$container->addCompilerPass(
DoctrinePhpcrMappingsPass::createXmlMappingDriver(
[
Expand All @@ -64,7 +70,7 @@ private function buildPhpcrCompilerPass(ContainerBuilder $container): void
],
['cmf_routing.dynamic.persistence.phpcr.manager_name'],
'cmf_routing.backend_type_phpcr',
['CmfRoutingBundle' => 'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr']
$aliasMap
)
);
}
Expand All @@ -81,6 +87,11 @@ private function buildOrmCompilerPass(ContainerBuilder $container): void
$container->addCompilerPass(
$this->buildBaseCompilerPass(DoctrineOrmMappingsPass::class, ORMXmlDriver::class, 'orm')
);
$aliasMap = [];
// short alias is no longer supported in doctrine/persistence 3, but keep aliasing for BC with old installations
if (class_exists(PersistentObject::class)) {
$aliasMap = ['CmfRoutingBundle' => 'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm'];
}
$container->addCompilerPass(
DoctrineOrmMappingsPass::createXmlMappingDriver(
[
Expand All @@ -89,7 +100,7 @@ private function buildOrmCompilerPass(ContainerBuilder $container): void
],
['cmf_routing.dynamic.persistence.orm.manager_name'],
'cmf_routing.backend_type_orm_default',
['CmfRoutingBundle' => 'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm']
$aliasMap
)
);

Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Phpcr/LocaleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function setLocales(array $locales): void

/**
* Whether to make the route prepend the locale pattern if it does not
* have one of the allowed locals in its id.
* have one of the allowed locales in its id.
*/
public function setAddLocalePattern(bool $addLocalePattern): void
{
Expand Down

0 comments on commit e90e861

Please sign in to comment.