Skip to content

no longer register CmfRoutingBundle alias when using doctrine/persistence 3 #486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2023
Merged
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
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