-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Fix importing PHP configs in the prepend extension method #57937
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
Conversation
Thank you @yceruto. |
@@ -92,6 +92,7 @@ public function import(mixed $resource, ?string $type = null, bool|string $ignor | |||
} | |||
} finally { | |||
--$this->importing; | |||
$this->loadExtensionConfigs(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this here (even in case of exception) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because there is a return statement inside the try block, so there is no other chance to load the collected ext config after --$this->importing;
instruction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, it's not about the exception at all, but if it happens I guess it doesn't matter if we try to prepend some configs afterward
It doesn't work for more than one bundle Only the last bundle is taken into account bin/console doctrine:mapping:info
Found 3 mapped entities:
[OK] AcMarche\Cap\Entity\Commercant
[OK] AcMarche\Cap\Entity\CommercantGallery
[OK] AcMarche\Cap\Entity\CommercioBottin ABundle class ABundle extends AbstractBundle
{
public function getPath(): string
{
return \dirname(__DIR__);
}
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
{
$container->import('../config/services.php');
}
public function prependExtension(ContainerConfigurator $container, ContainerBuilder $builder): void
{
$container->import('../config/packages/doctrine.php');
}
} //doctrine.php
return static function (DoctrineConfig $doctrine) {
$doctrine->dbal()
->connection('default')
->url(env('DATABASE_URL')->resolve());
$em = $doctrine->orm()->entityManager('default');
$doctrine->dbal()->defaultConnection('default');
$em->connection('default');
$em->mapping('AcMarcheBottin')
->isBundle(false)
->type('attribute')
->dir('%kernel.project_dir%/src/AcMarche/Bottin/src/Entity')
->prefix('AcMarche\Bottin')
->alias('AcMarcheBottin');
}; BBundle class ABundle extends AbstractBundle
{
//...
//the same as above
} //doctrine.php
return static function (DoctrineConfig $doctrine) {
$doctrine->dbal()
->connection('cap')
->url(env('DATABASE_URL_CAP')->resolve());
$em = $doctrine->orm()->entityManager('cap');
$em->connection('cap');
$em->mapping('AcMarcheCap')
->isBundle(false)
->type('attribute')
->dir('%kernel.project_dir%/src/AcMarche/Cap/src/Entity')
->prefix('AcMarche\Cap')
->alias('AcMarcheCap');
}; |
@jfsenechal can you open a new issue with details so I can take a look? |
I missed this nesting case during #52843.