2013-10-08 17:28:46 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
|
|
namespace PHPCI\Controller;
|
|
|
|
|
|
|
|
use b8;
|
2014-12-04 15:40:28 +01:00
|
|
|
use PHPCI\Helper\Lang;
|
2014-02-25 20:33:00 +01:00
|
|
|
use PHPCI\Plugin\Util\ComposerPluginInformation;
|
2014-02-25 23:22:32 +01:00
|
|
|
use PHPCI\Plugin\Util\FilesPluginInformation;
|
|
|
|
use PHPCI\Plugin\Util\PluginInformationCollection;
|
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
|
|
|
|
*/
|
|
|
|
class PluginController extends \PHPCI\Controller
|
|
|
|
{
|
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();
|
|
|
|
$pluginInfo->add(FilesPluginInformation::newFromDir(
|
|
|
|
PHPCI_DIR . "PHPCI/Plugin/"
|
|
|
|
));
|
|
|
|
$pluginInfo->add(ComposerPluginInformation::buildFromYaml(
|
2013-12-29 18:35:33 +01:00
|
|
|
PHPCI_DIR . "vendor/composer/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()
|
|
|
|
{
|
|
|
|
$json = file_get_contents(APPLICATION_PATH . 'composer.json');
|
|
|
|
return json_decode($json, true);
|
|
|
|
}
|
|
|
|
}
|