Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
Use schema provider setting
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilkybarkid committed Apr 30, 2019
1 parent 58d109d commit a50156a
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 36 deletions.
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ext-mbstring": "*",
"ext-pdo_pgsql": "*",
"doctrine/doctrine-bundle": "^1.10",
"doctrine/doctrine-migrations-bundle": "^2.0",
"doctrine/doctrine-migrations-bundle": "dev-schema-provider",
"libero/api-problem-bundle": "^0.2",
"libero/content-api-bundle": "^0.1",
"symfony/config": "^4.2",
Expand Down Expand Up @@ -56,5 +56,11 @@
"symfony": {
"allow-contrib": true
}
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/thewilkybarkid/DoctrineMigrationsBundle"
}
]
}
41 changes: 26 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions config/packages/content_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ services:
arguments:
- '@doctrine.dbal.default_connection'
- 'items'

libero.content_store.items.schema:
class: Doctrine\DBAL\Schema\Schema
factory: 'libero.content_store.items:getSchema'

libero.content_store.items.schema_provider:
class: Doctrine\Migrations\Provider\StubSchemaProvider
arguments:
- '@libero.content_store.items.schema'
1 change: 1 addition & 0 deletions config/packages/doctrine_migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ doctrine_migrations:
dir_name: '%kernel.project_dir%/config/migrations'
name: Libero Content Store migrations
namespace: Libero\ContentStore\Migrations
schema_provider: libero.content_store.items.schema_provider
6 changes: 6 additions & 0 deletions config/packages/test/content_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ services:
class: Libero\ContentApiBundle\Adapter\FilesystemItems
arguments:
- '%env(ARTICLES_PATH)%'

libero.content_store.items.schema:
abstract: true

libero.content_store.items.schema_provider:
abstract: true
2 changes: 2 additions & 0 deletions config/packages/test/doctrine_migrations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
doctrine_migrations:
schema_provider: ~
20 changes: 1 addition & 19 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@

namespace Libero\ContentStore;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\Provider\StubSchemaProvider;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;

final class Kernel extends BaseKernel implements CompilerPassInterface
final class Kernel extends BaseKernel
{
use MicroKernelTrait;

Expand Down Expand Up @@ -44,20 +40,6 @@ public function registerBundles() : iterable
}
}

public function process(ContainerBuilder $container) : void
{
$diffCommand = $container->findDefinition('doctrine_migrations.diff_command');
$doctrineItems = $container->findDefinition('libero.content_store.items');

$schema = new Definition(Schema::class);
$schema->setFactory([$doctrineItems, 'getSchema']);

$schemaProvider = new Definition(StubSchemaProvider::class);
$schemaProvider->setArgument(0, $schema);

$diffCommand->setArgument(0, $schemaProvider);
}

protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) : void
{
$container->addResource(new FileResource("{$this->getConfigDir()}/bundles.php"));
Expand Down

0 comments on commit a50156a

Please sign in to comment.