setDescription('Installs a plugin to Phraseanet') ->addArgument('source', InputArgument::REQUIRED, 'The source is a folder'); } protected function doExecutePluginAction(InputInterface $input, OutputInterface $output) { $source = $input->getArgument('source'); $shouldDownload = $this->shouldDownloadPlugin($source); if ($shouldDownload){ $command = $this->getApplication()->find('plugins:download'); $arguments = [ 'command' => 'plugins:download', 'source' => $source ]; $downloadInput = new ArrayInput($arguments); $command->run($downloadInput, $output); } 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; } } protected function shouldDownloadPlugin($source) { $allowedScheme = array('https','ssh'); $scheme = parse_url($source, PHP_URL_SCHEME); if (in_array($scheme, $allowedScheme)){ return true; } else{ return false; } } }