phpci/PHPCI/Controller/PluginController.php

62 lines
1.6 KiB
PHP
Raw Normal View History

2013-10-08 17:28:46 +02:00
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
2013-10-08 17:28:46 +02:00
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @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;
use PHPCI\Plugin\Util\ComposerPluginInformation;
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
{
/**
* List all enabled plugins, installed and recommend packages.
* @return string
*/
2013-10-08 17:28:46 +02:00
public function index()
{
$this->requireAdmin();
2013-10-08 17:28:46 +02:00
$json = $this->getComposerJson();
$this->view->installedPackages = $json['require'];
$pluginInfo = new PluginInformationCollection();
$pluginInfo->add(FilesPluginInformation::newFromDir(
PHPCI_DIR . "PHPCI/Plugin/"
));
$pluginInfo->add(ComposerPluginInformation::buildFromYaml(
PHPCI_DIR . "vendor/composer/installed.json"
));
$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');
2013-10-08 17:28:46 +02:00
return $this->view->render();
}
/**
* 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);
}
}