Skip to content

Commit e90e861

Browse files
authored
Merge pull request #486 from symfony-cmf/fix-persistence-3
no longer register CmfRoutingBundle alias when using doctrine/persistence 3
2 parents 19b4dc9 + 028b3d7 commit e90e861

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

.github/workflows/test-application.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ jobs:
4040
tools: 'composer:v2'
4141

4242
- name: Install Symfony Flex
43-
run: composer global require --no-progress --no-scripts --no-plugins symfony/flex
43+
run: |
44+
composer global config --no-plugins allow-plugins.symfony/flex true
45+
composer global require --no-progress --no-scripts --no-plugins symfony/flex
4446
4547
- name: Install dependencies with Composer
4648
uses: ramsey/composer-install@v1

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
3.0.2
5+
-----
6+
7+
* Do not register CmfRoutingBundle alias for ORM / PHPCR-ODM when we have doctrine/persistence 3.x as the short alias is no longer supported.
8+
49
3.0.1
510
-----
611

src/CmfRoutingBundle.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
1515
use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass;
16+
use Doctrine\Common\Persistence\PersistentObject;
1617
use Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver as PHPCRXmlDriver;
1718
use Doctrine\ODM\PHPCR\Version as PHPCRVersion;
1819
use Doctrine\ORM\EntityManagerInterface;
@@ -56,6 +57,11 @@ private function buildPhpcrCompilerPass(ContainerBuilder $container): void
5657
$container->addCompilerPass(
5758
$this->buildBaseCompilerPass(DoctrinePhpcrMappingsPass::class, PHPCRXmlDriver::class, 'phpcr')
5859
);
60+
$aliasMap = [];
61+
// short alias is no longer supported in doctrine/persistence 3, but keep aliasing for BC with old installations
62+
if (class_exists(PersistentObject::class)) {
63+
$aliasMap = ['CmfRoutingBundle' => 'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr'];
64+
}
5965
$container->addCompilerPass(
6066
DoctrinePhpcrMappingsPass::createXmlMappingDriver(
6167
[
@@ -64,7 +70,7 @@ private function buildPhpcrCompilerPass(ContainerBuilder $container): void
6470
],
6571
['cmf_routing.dynamic.persistence.phpcr.manager_name'],
6672
'cmf_routing.backend_type_phpcr',
67-
['CmfRoutingBundle' => 'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr']
73+
$aliasMap
6874
)
6975
);
7076
}
@@ -81,6 +87,11 @@ private function buildOrmCompilerPass(ContainerBuilder $container): void
8187
$container->addCompilerPass(
8288
$this->buildBaseCompilerPass(DoctrineOrmMappingsPass::class, ORMXmlDriver::class, 'orm')
8389
);
90+
$aliasMap = [];
91+
// short alias is no longer supported in doctrine/persistence 3, but keep aliasing for BC with old installations
92+
if (class_exists(PersistentObject::class)) {
93+
$aliasMap = ['CmfRoutingBundle' => 'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm'];
94+
}
8495
$container->addCompilerPass(
8596
DoctrineOrmMappingsPass::createXmlMappingDriver(
8697
[
@@ -89,7 +100,7 @@ private function buildOrmCompilerPass(ContainerBuilder $container): void
89100
],
90101
['cmf_routing.dynamic.persistence.orm.manager_name'],
91102
'cmf_routing.backend_type_orm_default',
92-
['CmfRoutingBundle' => 'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm']
103+
$aliasMap
93104
)
94105
);
95106

src/Doctrine/Phpcr/LocaleListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function setLocales(array $locales): void
8888

8989
/**
9090
* Whether to make the route prepend the locale pattern if it does not
91-
* have one of the allowed locals in its id.
91+
* have one of the allowed locales in its id.
9292
*/
9393
public function setAddLocalePattern(bool $addLocalePattern): void
9494
{

0 commit comments

Comments
 (0)