diff --git a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php
index b2c72999d1..2d9d211612 100644
--- a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php
+++ b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php
@@ -51,4 +51,41 @@ abstract class AbstractPluginCommand extends Command
$this->container['plugins.autoloader-generator']->write($manifests);
$output->writeln(" OK");
}
+
+ protected function doInstallPlugin($source, InputInterface $input, OutputInterface $output)
+ {
+ $temporaryDir = $this->container['temporary-filesystem']->createTemporaryDirectory();
+
+ $output->write("Importing $source...");
+ $this->container['plugins.importer']->import($source, $temporaryDir);
+ $output->writeln(" OK");
+
+ $output->write("Validating plugin...");
+ $manifest = $this->container['plugins.plugins-validator']->validatePlugin($temporaryDir);
+ $output->writeln(" OK found ".$manifest->getName()."");
+
+ $targetDir = $this->container['plugin.path'] . DIRECTORY_SEPARATOR . $manifest->getName();
+
+ $output->write("Setting up composer...");
+ $this->container['plugins.composer-installer']->install($temporaryDir);
+ $output->writeln(" OK");
+
+ $output->write("Installing plugin ".$manifest->getName()."...");
+ $this->container['filesystem']->mirror($temporaryDir, $targetDir);
+ $output->writeln(" OK");
+
+ $output->write("Copying public files ".$manifest->getName()."...");
+ $this->container['plugins.assets-manager']->update($manifest);
+ $output->writeln(" OK");
+
+ $output->write("Removing temporary directory...");
+ $this->container['filesystem']->remove($temporaryDir);
+ $output->writeln(" OK");
+
+ $output->write("Activating plugin...");
+ $this->container['conf']->set(['plugins', $manifest->getName(), 'enabled'], true);
+ $output->writeln(" OK");
+
+ $this->updateConfigFiles($input, $output);
+ }
}
diff --git a/lib/Alchemy/Phrasea/Command/Plugin/AddPlugin.php b/lib/Alchemy/Phrasea/Command/Plugin/AddPlugin.php
index 2b96043102..5f4f8b0da9 100644
--- a/lib/Alchemy/Phrasea/Command/Plugin/AddPlugin.php
+++ b/lib/Alchemy/Phrasea/Command/Plugin/AddPlugin.php
@@ -36,7 +36,8 @@ class AddPlugin extends AbstractPluginCommand
$command = $this->getApplication()->find('plugins:download');
$arguments = [
'command' => 'plugins:download',
- 'source' => $source
+ 'source' => $source,
+ 'shouldInstallPlugin' => true
];
$downloadInput = new ArrayInput($arguments);
@@ -44,41 +45,7 @@ class AddPlugin extends AbstractPluginCommand
} else {
- $temporaryDir = $this->container['temporary-filesystem']->createTemporaryDirectory();
-
- $output->write("Importing $source...");
- $this->container['plugins.importer']->import($source, $temporaryDir);
- $output->writeln(" OK");
-
- $output->write("Validating plugin...");
- $manifest = $this->container['plugins.plugins-validator']->validatePlugin($temporaryDir);
- $output->writeln(" OK found ".$manifest->getName()."");
-
- $targetDir = $this->container['plugin.path'] . DIRECTORY_SEPARATOR . $manifest->getName();
-
- $output->write("Setting up composer...");
- $this->container['plugins.composer-installer']->install($temporaryDir);
- $output->writeln(" OK");
-
- $output->write("Installing plugin ".$manifest->getName()."...");
- $this->container['filesystem']->mirror($temporaryDir, $targetDir);
- $output->writeln(" OK");
-
- $output->write("Copying public files ".$manifest->getName()."...");
- $this->container['plugins.assets-manager']->update($manifest);
- $output->writeln(" OK");
-
- $output->write("Removing temporary directory...");
- $this->container['filesystem']->remove($temporaryDir);
- $output->writeln(" OK");
-
- $output->write("Activating plugin...");
- $this->container['conf']->set(['plugins', $manifest->getName(), 'enabled'], true);
- $output->writeln(" OK");
-
- $this->updateConfigFiles($input, $output);
-
- return 0;
+ $this->doInstallPlugin($source, $input, $output);
}
}
diff --git a/lib/Alchemy/Phrasea/Command/Plugin/DownloadPlugin.php b/lib/Alchemy/Phrasea/Command/Plugin/DownloadPlugin.php
index 0a1ec9cfe9..a3fdacbc1c 100644
--- a/lib/Alchemy/Phrasea/Command/Plugin/DownloadPlugin.php
+++ b/lib/Alchemy/Phrasea/Command/Plugin/DownloadPlugin.php
@@ -27,13 +27,16 @@ class DownloadPlugin extends AbstractPluginCommand
$this
->setDescription('Downloads a plugin to Phraseanet')
->addArgument('source', InputArgument::REQUIRED, 'The source is a remote url (.zip or .git)')
- ->addArgument('destination', InputArgument::OPTIONAL, 'Download destination');
+ ->addArgument('destination', InputArgument::OPTIONAL, 'Download destination')
+ ->addArgument('shouldInstallPlugin', InputArgument::OPTIONAL, 'True or false, determines if plugin should be installed after download');
}
protected function doExecutePluginAction(InputInterface $input, OutputInterface $output)
{
$source = $input->getArgument('source');
$destination = $input->getArgument('destination');
+ $shouldInstallPlugin = false;
+ $shouldInstallPlugin = $input->getArgument('shouldInstallPlugin');
$destinationSubdir = '/plugin-'.md5($source);
@@ -98,6 +101,7 @@ class DownloadPlugin extends AbstractPluginCommand
$output->writeln("Failed unzipping $source");
} else {
$output->writeln("Plugin downloaded to $localDownloadPath");
+ if ($shouldInstallPlugin) $this->doInstallPlugin($localDownloadPath, $input, $output);
}
// remove zip archive
@@ -109,6 +113,7 @@ class DownloadPlugin extends AbstractPluginCommand
$output->writeln("Downloading $source...");
$repo = GitRepository::cloneRepository($source, $localDownloadPath);
$output->writeln("Plugin downloaded to $localDownloadPath");
+ if ($shouldInstallPlugin) $this->doInstallPlugin($localDownloadPath, $input, $output);
break;
}