2013-10-08 17:28:46 +02:00
|
|
|
<?php
|
2016-12-30 17:40:14 +01:00
|
|
|
|
2013-10-08 17:28:46 +02:00
|
|
|
/**
|
|
|
|
* PHPCI - Continuous Integration for PHP
|
|
|
|
*
|
2014-05-12 18:26:17 +02:00
|
|
|
* @copyright Copyright 2014, Block 8 Limited.
|
2013-10-08 17:28:46 +02:00
|
|
|
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
|
2014-05-12 18:26:17 +02:00
|
|
|
* @link https://www.phptesting.org/
|
2013-10-08 17:28:46 +02:00
|
|
|
*/
|
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
namespace PHPCensor\Controller;
|
2013-10-08 17:28:46 +02:00
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
use PHPCensor\Helper\Lang;
|
|
|
|
use PHPCensor\Plugin\Util\ComposerPluginInformation;
|
|
|
|
use PHPCensor\Plugin\Util\FilesPluginInformation;
|
|
|
|
use PHPCensor\Plugin\Util\PluginInformationCollection;
|
|
|
|
use PHPCensor\Controller;
|
2013-10-08 17:28:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plugin Controller - Provides support for installing Composer packages.
|
|
|
|
* @author Dan Cryer <dan@block8.co.uk>
|
|
|
|
* @package PHPCI
|
|
|
|
* @subpackage Web
|
|
|
|
*/
|
2016-05-09 08:20:26 +02:00
|
|
|
class PluginController extends Controller
|
2013-10-08 17:28:46 +02:00
|
|
|
{
|
2014-12-08 12:25:33 +01:00
|
|
|
/**
|
|
|
|
* List all enabled plugins, installed and recommend packages.
|
|
|
|
* @return string
|
|
|
|
*/
|
2013-10-08 17:28:46 +02:00
|
|
|
public function index()
|
|
|
|
{
|
2014-12-02 17:26:55 +01:00
|
|
|
$this->requireAdmin();
|
2013-10-11 22:51:23 +02:00
|
|
|
|
2013-10-08 17:28:46 +02:00
|
|
|
$json = $this->getComposerJson();
|
2013-12-29 18:35:33 +01:00
|
|
|
$this->view->installedPackages = $json['require'];
|
|
|
|
|
2014-02-25 23:22:32 +01:00
|
|
|
$pluginInfo = new PluginInformationCollection();
|
2016-07-21 17:20:34 +02:00
|
|
|
$pluginInfo->add(FilesPluginInformation::newFromDir(SRC_DIR . "Plugin" . DIRECTORY_SEPARATOR));
|
2014-02-25 23:22:32 +01:00
|
|
|
$pluginInfo->add(ComposerPluginInformation::buildFromYaml(
|
2016-04-21 19:05:32 +02:00
|
|
|
ROOT_DIR . "vendor" . DIRECTORY_SEPARATOR . "composer" . DIRECTORY_SEPARATOR . "installed.json"
|
2014-02-25 23:22:32 +01:00
|
|
|
));
|
|
|
|
|
2013-12-29 18:35:33 +01:00
|
|
|
$this->view->plugins = $pluginInfo->getInstalledPlugins();
|
2013-10-08 17:28:46 +02:00
|
|
|
|
2014-12-04 15:40:28 +01:00
|
|
|
$this->layout->title = Lang::get('plugins');
|
2014-04-24 17:25:24 +02:00
|
|
|
|
2013-10-08 17:28:46 +02:00
|
|
|
return $this->view->render();
|
|
|
|
}
|
|
|
|
|
2014-12-08 12:25:33 +01:00
|
|
|
/**
|
|
|
|
* Get the json-decoded contents of the composer.json file.
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2013-10-08 17:28:46 +02:00
|
|
|
protected function getComposerJson()
|
|
|
|
{
|
2016-04-21 19:05:32 +02:00
|
|
|
$json = file_get_contents(ROOT_DIR . 'composer.json');
|
2013-10-08 17:28:46 +02:00
|
|
|
return json_decode($json, true);
|
|
|
|
}
|
|
|
|
}
|