Skip to content

Commit

Permalink
Merge pull request #52 from piotrkardasz/migration-paths-fix
Browse files Browse the repository at this point in the history
Fix doctrine migrations_paths order
  • Loading branch information
pptasinski-bitbag authored Apr 23, 2021
2 parents bcbb00e + 342d53f commit 7969fbd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/DependencyInjection/BitBagSyliusWishlistExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace BitBag\SyliusWishlistPlugin\DependencyInjection;

use Sylius\Bundle\CoreBundle\DependencyInjection\PrependDoctrineMigrationsTrait;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -12,6 +13,8 @@

final class BitBagSyliusWishlistExtension extends AbstractResourceExtension implements PrependExtensionInterface
{
use PrependDoctrineMigrationsTrait;

public function load(array $config, ContainerBuilder $container): void
{
$config = $this->processConfiguration($this->getConfiguration([], $container), $config);
Expand All @@ -23,20 +26,22 @@ public function load(array $config, ContainerBuilder $container): void

public function prepend(ContainerBuilder $container): void
{
if (!$container->hasExtension('doctrine_migrations') || !$container->hasExtension('sylius_labs_doctrine_migrations_extra')) {
return;
}

$container->prependExtensionConfig('doctrine_migrations', [
'migrations_paths' => [
'BitBag\SyliusWishlistPlugin\Migrations' => '@BitBagSyliusWishlistPlugin/Migrations',
],
]);

$container->prependExtensionConfig('sylius_labs_doctrine_migrations_extra', [
'migrations' => [
'BitBag\SyliusWishlistPlugin\Migrations' => ['Sylius\Bundle\CoreBundle\Migrations'],
],
]);
trigger_deprecation('bitbag/wishlist-plugin', '2.0', 'Doctrine migrations existing in a bundle will be removed, move migrations to the project directory.');
$this->prependDoctrineMigrations($container);
}

protected function getMigrationsNamespace(): string
{
return 'BitBag\SyliusWishlistPlugin\Migrations';
}

protected function getMigrationsDirectory(): string
{
return '@BitBagSyliusWishlistPlugin/Migrations';
}

protected function getNamespacesOfMigrationsExecutedBefore(): array
{
return ['Sylius\Bundle\CoreBundle\Migrations'];
}
}
3 changes: 3 additions & 0 deletions src/Migrations/Version20201029161558.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* @deprecated Since bitbag/wishlist-plugin 2.0: Doctrine migrations existing in a bundle will be removed, move migrations to the project directory.
*/
final class Version20201029161558 extends AbstractMigration
{
public function up(Schema $schema): void
Expand Down

0 comments on commit 7969fbd

Please sign in to comment.