Skip to content

Commit

Permalink
add migration installer
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfaffenbauer committed Aug 25, 2017
1 parent 7449fff commit eedd5a8
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 84 deletions.
45 changes: 45 additions & 0 deletions src/Installer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace ObjectIndexBundle;

use Doctrine\DBAL\Migrations\Version;
use Doctrine\DBAL\Schema\Schema;
use Pimcore\Extension\Bundle\Installer\MigrationInstaller;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;

class Installer extends MigrationInstaller
{
/**
* {@inheritdoc}
*/
protected function beforeInstallMigration()
{
$kernel = \Pimcore::getKernel();
$application = new Application($kernel);
$application->setAutoExit(false);
$options = ['command' => 'doctrine:schema:update'];
$options = array_merge($options, ['--no-interaction' => true, '--force' => true]);
$application->run(new ArrayInput($options));

$options = ['command' => 'cache:clear'];
$options = array_merge($options, ['--no-warmup']);
$application->run(new ArrayInput($options));
}

/**
* {@inheritdoc}
*/
public function migrateInstall(Schema $schema, Version $version)
{
//Nothing to do here
}

/**
* {@inheritdoc}
*/
public function migrateUninstall(Schema $schema, Version $version)
{
//Nothing to do here
}
}
83 changes: 0 additions & 83 deletions src/Installer/PimcoreInstaller.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/ObjectIndexBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getVersion()
*/
public function getInstaller()
{
return new PimcoreInstaller();
return $this->container->get(Installer::class);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

ObjectIndexBundle\Installer:
public: true
arguments:
$bundle: "@=service('kernel').getBundle('ObjectIndexBundle')"

0 comments on commit eedd5a8

Please # to comment.