From eedd5a8216c33724b01653b2434bb45930d8ca95 Mon Sep 17 00:00:00 2001 From: dpfaffenbauer Date: Fri, 25 Aug 2017 16:16:57 +0200 Subject: [PATCH] add migration installer --- src/Installer.php | 45 ++++++++++++++++ src/Installer/PimcoreInstaller.php | 83 ------------------------------ src/ObjectIndexBundle.php | 2 +- src/Resources/config/services.yml | 10 ++++ 4 files changed, 56 insertions(+), 84 deletions(-) create mode 100644 src/Installer.php delete mode 100644 src/Installer/PimcoreInstaller.php diff --git a/src/Installer.php b/src/Installer.php new file mode 100644 index 0000000..fbf81e6 --- /dev/null +++ b/src/Installer.php @@ -0,0 +1,45 @@ +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 + } +} diff --git a/src/Installer/PimcoreInstaller.php b/src/Installer/PimcoreInstaller.php deleted file mode 100644 index 6f9bdf3..0000000 --- a/src/Installer/PimcoreInstaller.php +++ /dev/null @@ -1,83 +0,0 @@ -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 uninstall() - { - } - - /** - * {@inheritdoc} - */ - public function isInstalled() - { - return Db::get()->getSchemaManager()->tablesExist(['coreshop_index']); - } - - /** - * {@inheritdoc} - */ - public function canBeInstalled() - { - return !$this->isInstalled(); - } - - /** - * {@inheritdoc} - */ - public function canBeUninstalled() - { - return false; - } - - /** - * {@inheritdoc} - */ - public function needsReloadAfterInstall() - { - return false; - } - - /** - * {@inheritdoc} - */ - public function canBeUpdated() - { - return false; - } - - /** - * {@inheritdoc} - */ - public function update() - { - //InstallHelper::runDoctrineOrmSchemaUpdate(); - } -} diff --git a/src/ObjectIndexBundle.php b/src/ObjectIndexBundle.php index 46bab67..15a5328 100644 --- a/src/ObjectIndexBundle.php +++ b/src/ObjectIndexBundle.php @@ -36,7 +36,7 @@ public function getVersion() */ public function getInstaller() { - return new PimcoreInstaller(); + return $this->container->get(Installer::class); } /** diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index e69de29..b042c10 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -0,0 +1,10 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + ObjectIndexBundle\Installer: + public: true + arguments: + $bundle: "@=service('kernel').getBundle('ObjectIndexBundle')" \ No newline at end of file