mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
Install function added
Added install function in plugins:download if called from plugins:add command
This commit is contained in:
@@ -51,4 +51,41 @@ abstract class AbstractPluginCommand extends Command
|
||||
$this->container['plugins.autoloader-generator']->write($manifests);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
}
|
||||
|
||||
protected function doInstallPlugin($source, InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$temporaryDir = $this->container['temporary-filesystem']->createTemporaryDirectory();
|
||||
|
||||
$output->write("Importing <info>$source</info>...");
|
||||
$this->container['plugins.importer']->import($source, $temporaryDir);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$output->write("Validating plugin...");
|
||||
$manifest = $this->container['plugins.plugins-validator']->validatePlugin($temporaryDir);
|
||||
$output->writeln(" <comment>OK</comment> found <info>".$manifest->getName()."</info>");
|
||||
|
||||
$targetDir = $this->container['plugin.path'] . DIRECTORY_SEPARATOR . $manifest->getName();
|
||||
|
||||
$output->write("Setting up composer...");
|
||||
$this->container['plugins.composer-installer']->install($temporaryDir);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$output->write("Installing plugin <info>".$manifest->getName()."</info>...");
|
||||
$this->container['filesystem']->mirror($temporaryDir, $targetDir);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$output->write("Copying public files <info>".$manifest->getName()."</info>...");
|
||||
$this->container['plugins.assets-manager']->update($manifest);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$output->write("Removing temporary directory...");
|
||||
$this->container['filesystem']->remove($temporaryDir);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$output->write("Activating plugin...");
|
||||
$this->container['conf']->set(['plugins', $manifest->getName(), 'enabled'], true);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$this->updateConfigFiles($input, $output);
|
||||
}
|
||||
}
|
||||
|
@@ -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 <info>$source</info>...");
|
||||
$this->container['plugins.importer']->import($source, $temporaryDir);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$output->write("Validating plugin...");
|
||||
$manifest = $this->container['plugins.plugins-validator']->validatePlugin($temporaryDir);
|
||||
$output->writeln(" <comment>OK</comment> found <info>".$manifest->getName()."</info>");
|
||||
|
||||
$targetDir = $this->container['plugin.path'] . DIRECTORY_SEPARATOR . $manifest->getName();
|
||||
|
||||
$output->write("Setting up composer...");
|
||||
$this->container['plugins.composer-installer']->install($temporaryDir);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$output->write("Installing plugin <info>".$manifest->getName()."</info>...");
|
||||
$this->container['filesystem']->mirror($temporaryDir, $targetDir);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$output->write("Copying public files <info>".$manifest->getName()."</info>...");
|
||||
$this->container['plugins.assets-manager']->update($manifest);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$output->write("Removing temporary directory...");
|
||||
$this->container['filesystem']->remove($temporaryDir);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$output->write("Activating plugin...");
|
||||
$this->container['conf']->set(['plugins', $manifest->getName(), 'enabled'], true);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$this->updateConfigFiles($input, $output);
|
||||
|
||||
return 0;
|
||||
$this->doInstallPlugin($source, $input, $output);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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 <info>$source</info>");
|
||||
} else {
|
||||
$output->writeln("Plugin downloaded to <info>$localDownloadPath</info>");
|
||||
if ($shouldInstallPlugin) $this->doInstallPlugin($localDownloadPath, $input, $output);
|
||||
}
|
||||
|
||||
// remove zip archive
|
||||
@@ -109,6 +113,7 @@ class DownloadPlugin extends AbstractPluginCommand
|
||||
$output->writeln("Downloading <info>$source</info>...");
|
||||
$repo = GitRepository::cloneRepository($source, $localDownloadPath);
|
||||
$output->writeln("Plugin downloaded to <info>$localDownloadPath</info>");
|
||||
if ($shouldInstallPlugin) $this->doInstallPlugin($localDownloadPath, $input, $output);
|
||||
break;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user