write("Validating plugins...");
foreach ($this->container['plugins.explorer'] as $directory) {
$manifests[] = $this->container['plugins.plugins-validator']->validatePlugin($directory);
}
$output->writeln(" OK");
return $manifests;
}
protected function doExecute(InputInterface $input, OutputInterface $output)
{
if (basename($_SERVER['PHP_SELF']) === 'console') {
$output->writeln("");
$output->writeln(sprintf(' /!\ Warning, this command is deprecated and will be removed as of Phraseanet 3.9, please use bin/setup %s instead /!\ ', $this->getName()));
$output->writeln("");
}
return $this->doExecutePluginAction($input, $output);
}
abstract protected function doExecutePluginAction(InputInterface $input, OutputInterface $output);
protected function updateConfigFiles(InputInterface $input, OutputInterface $output)
{
$manifests = $this->validatePlugins($input, $output);
$output->write("Updating config files...");
$this->container['plugins.autoloader-generator']->write($manifests);
$output->writeln(" OK");
}
protected function doInstallPlugin($source, InputInterface $input, OutputInterface $output)
{
$output->write("Validating plugin...");
$manifest = $this->container['plugins.plugins-validator']->validatePlugin($source);
$output->writeln(" OK found ".$manifest->getName()."");
$targetDir = $this->container['plugin.path'] . DIRECTORY_SEPARATOR . $manifest->getName();
if (normalizePath($targetDir) !== normalizePath($source)) {
$temporaryDir = $this->container['temporary-filesystem']->createTemporaryDirectory();
$output->write("Importing $source...");
$this->container['plugins.importer']->import($source, $temporaryDir);
$output->writeln(" OK");
$workingDir = $temporaryDir;
} else {
$workingDir = $targetDir;
}
if (!is_dir($workingDir.'/vendor')) {
$output->write("Setting up composer...");
$this->container['plugins.composer-installer']->install($workingDir);
$output->writeln(" OK");
}
$output->write("Installing plugin ".$manifest->getName()."...");
if (isset($temporaryDir)) {
$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");
if (isset($temporaryDir)) {
$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);
}
}