ORIENT/modules/system/console/PluginInstall.php

77 lines
2.0 KiB
PHP
Raw Normal View History

2014-05-14 13:24:20 +00:00
<?php namespace System\Console;
use Illuminate\Console\Command;
use System\Classes\UpdateManager;
use Symfony\Component\Console\Input\InputArgument;
use System\Classes\PluginManager;
/**
* 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
*/
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, true);
2014-05-14 13:24:20 +00:00
$this->output->writeln(sprintf('<info>Unpacking plugin: %s</info>', $code));
$manager->extractPlugin($code, $hash);
2022-12-14 15:55:13 +00:00
/*
* Make sure plugin is registered
*/
$pluginManager = PluginManager::instance();
$pluginManager->loadPlugins();
$plugin = $pluginManager->findByIdentifier($code);
$pluginManager->registerPlugin($plugin, $code);
2014-05-14 13:24:20 +00:00
/*
* Migrate plugin
*/
$this->output->writeln(sprintf('<info>Migrating plugin...</info>', $code));
$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
}