2014-05-14 13:24:20 +00:00
|
|
|
<?php namespace System\Console;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
use System\Classes\UpdateManager;
|
2018-08-24 17:40:40 +00:00
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
2014-05-14 13:24:20 +00:00
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
|
use System\Classes\PluginManager;
|
|
|
|
|
|
2017-03-16 06:08:20 +00:00
|
|
|
/**
|
|
|
|
|
* Console command to install a new plugin.
|
|
|
|
|
*
|
|
|
|
|
* This adds a new plugin by requesting it from the October marketplace.
|
|
|
|
|
*
|
|
|
|
|
* @package october\system
|
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
|
*/
|
2014-05-14 13:24:20 +00:00
|
|
|
class PluginInstall extends Command
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The console command name.
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $name = 'plugin:install';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The console command description.
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2017-03-16 06:08:20 +00:00
|
|
|
protected $description = 'Install a plugin from the October marketplace.';
|
2014-05-14 13:24:20 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute the console command.
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2017-07-14 06:28:47 +00:00
|
|
|
public function handle()
|
2014-05-14 13:24:20 +00:00
|
|
|
{
|
|
|
|
|
$pluginName = $this->argument('name');
|
2017-05-19 23:03:58 +00:00
|
|
|
$manager = UpdateManager::instance()->setNotesOutput($this->output);
|
2014-05-14 13:24:20 +00:00
|
|
|
|
|
|
|
|
$pluginDetails = $manager->requestPluginDetails($pluginName);
|
|
|
|
|
|
|
|
|
|
$code = array_get($pluginDetails, 'code');
|
|
|
|
|
$hash = array_get($pluginDetails, 'hash');
|
|
|
|
|
|
|
|
|
|
$this->output->writeln(sprintf('<info>Downloading plugin: %s</info>', $code));
|
|
|
|
|
$manager->downloadPlugin($code, $hash);
|
|
|
|
|
|
|
|
|
|
$this->output->writeln(sprintf('<info>Unpacking plugin: %s</info>', $code));
|
|
|
|
|
$manager->extractPlugin($code, $hash);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Migrate plugin
|
|
|
|
|
*/
|
|
|
|
|
$this->output->writeln(sprintf('<info>Migrating plugin...</info>', $code));
|
|
|
|
|
PluginManager::instance()->loadPlugins();
|
|
|
|
|
$manager->updatePlugin($code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the console command arguments.
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
protected function getArguments()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
['name', InputArgument::REQUIRED, 'The name of the plugin. Eg: AuthorName.PluginName'],
|
|
|
|
|
];
|
|
|
|
|
}
|
2014-10-18 09:58:50 +00:00
|
|
|
}
|