I've come for help again.
I'm developing a couple of Symfony 6.2 applications that have a bunch of code shared between them. So, I'm putting a bunch on bundles. And so far it is working, including configuring the bundle options on the main apps.
The issue is that now, one of the bundles will have some migrations in it. I know I can just go to my config/doctrine_migrations.yaml
and manually add the new path to:
doctrine_migrations:
migrations_paths:
'CustomBundleMigrations': '@CustomBundle/migrations'
My question is, is there a way to make this automatically when I require the bundle? I tried using prepend, but it get replace by the application on doctrine_migrations config file
Here is my CustomBundle.php file.
<?php
namespace Vendor\CustomBundle;
use Vendor\CustomBundle\DependencyInjection\CustomExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
class CustomBundle extends AbstractBundle
{
public function getContainerExtension(): ?ExtensionInterface
{
if (null === $this->extension) {
$this->extension = new CustomExtension();
}
return $this->extension;
}
public function prependExtension(
ContainerConfigurator $container,
ContainerBuilder $builder
): void {
$container->import('../config/packages/doctrine_migrations.yaml');
}
}
And this is the /config/packages/doctrine_migrations.yaml
doctrine_migrations:
migrations_paths:
'CustomBundleMigrations': '%kernel.project_dir%/migrations'