From e186874eba25b50f6e645eb33e00ea280a9a5aa2 Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Thu, 8 Oct 2015 16:29:29 +0100 Subject: [PATCH] Removing the ability to install 'plugins' via the web interface. --- PHPCI/Controller/PluginController.php | 144 ----------------- PHPCI/View/Plugin/index.phtml | 212 ++++---------------------- 2 files changed, 32 insertions(+), 324 deletions(-) diff --git a/PHPCI/Controller/PluginController.php b/PHPCI/Controller/PluginController.php index cefcdbb5..64cb1463 100644 --- a/PHPCI/Controller/PluginController.php +++ b/PHPCI/Controller/PluginController.php @@ -23,24 +23,6 @@ use PHPCI\Plugin\Util\PluginInformationCollection; */ class PluginController extends \PHPCI\Controller { - protected $required = array( - 'php', - 'ext-pdo', - 'ext-pdo_mysql', - 'block8/b8framework', - 'ircmaxell/password-compat', - 'swiftmailer/swiftmailer', - 'symfony/yaml', - 'symfony/console', - 'psr/log', - 'monolog/monolog', - 'pimple/pimple', - 'robmorgan/phinx', - ); - - protected $canInstall; - protected $composerPath; - /** * List all enabled plugins, installed and recommend packages. * @return string @@ -49,12 +31,8 @@ class PluginController extends \PHPCI\Controller { $this->requireAdmin(); - $this->view->canWrite = is_writable(APPLICATION_PATH . 'composer.json'); - $this->view->required = $this->required; - $json = $this->getComposerJson(); $this->view->installedPackages = $json['require']; - $this->view->suggestedPackages = $json['suggest']; $pluginInfo = new PluginInformationCollection(); $pluginInfo->add(FilesPluginInformation::newFromDir( @@ -71,49 +49,6 @@ class PluginController extends \PHPCI\Controller return $this->view->render(); } - /** - * Remove a given package. - */ - public function remove() - { - $this->requireAdmin(); - - $package = $this->getParam('package', null); - $json = $this->getComposerJson(); - - $response = new b8\Http\Response\RedirectResponse(); - - if (!in_array($package, $this->required)) { - unset($json['require'][$package]); - $this->setComposerJson($json); - - $response->setHeader('Location', PHPCI_URL . 'plugin?r=' . $package); - return $response; - } - - $response->setHeader('Location', PHPCI_URL); - return $response; - } - - /** - * Install a given package. - */ - public function install() - { - $this->requireAdmin(); - - $package = $this->getParam('package', null); - $version = $this->getParam('version', '*'); - - $json = $this->getComposerJson(); - $json['require'][$package] = $version; - $this->setComposerJson($json); - - $response = new b8\Http\Response\RedirectResponse(); - $response->setHeader('Location', PHPCI_URL . 'plugin?w=' . $package); - return $response; - } - /** * Get the json-decoded contents of the composer.json file. * @return mixed @@ -123,83 +58,4 @@ class PluginController extends \PHPCI\Controller $json = file_get_contents(APPLICATION_PATH . 'composer.json'); return json_decode($json, true); } - - /** - * Convert array to json and save composer.json - * - * @param $array - */ - protected function setComposerJson($array) - { - if (defined('JSON_PRETTY_PRINT')) { - $json = json_encode($array, JSON_PRETTY_PRINT); - } else { - $json = json_encode($array); - } - - file_put_contents(APPLICATION_PATH . 'composer.json', $json); - } - - /** - * Find a system binary. - * @param $binary - * @return null|string - */ - protected function findBinary($binary) - { - if (is_string($binary)) { - $binary = array($binary); - } - - foreach ($binary as $bin) { - // Check project root directory: - if (is_file(APPLICATION_PATH . $bin)) { - return APPLICATION_PATH . $bin; - } - - // Check Composer bin dir: - if (is_file(APPLICATION_PATH . 'vendor/bin/' . $bin)) { - return APPLICATION_PATH . 'vendor/bin/' . $bin; - } - - // Use "which" - $which = trim(shell_exec('which ' . $bin)); - - if (!empty($which)) { - return $which; - } - } - - return null; - } - - /** - * Perform a search on packagist.org. - */ - public function packagistSearch() - { - $searchQuery = $this->getParam('q', ''); - $http = new \b8\HttpClient(); - $http->setHeaders(array('User-Agent: PHPCI/1.0 (+https://www.phptesting.org)')); - $res = $http->get('https://packagist.org/search.json', array('q' => $searchQuery)); - - $response = new b8\Http\Response\JsonResponse(); - $response->setContent($res['body']); - return $response; - } - - /** - * Look up available versions of a given package on packagist.org - */ - public function packagistVersions() - { - $name = $this->getParam('p', ''); - $http = new \b8\HttpClient(); - $http->setHeaders(array('User-Agent: PHPCI/1.0 (+https://www.phptesting.org)')); - $res = $http->get('https://packagist.org/packages/'.$name.'.json'); - - $response = new b8\Http\Response\JsonResponse(); - $response->setContent($res['body']); - return $response; - } } diff --git a/PHPCI/View/Plugin/index.phtml b/PHPCI/View/Plugin/index.phtml index b595a4df..5c186012 100644 --- a/PHPCI/View/Plugin/index.phtml +++ b/PHPCI/View/Plugin/index.phtml @@ -1,45 +1,40 @@ - -

- - -

- - - -

- - -
-
-

-
- - - - - - - - - - - - - - - - - - -
name; ?>class; ?>source; ?>
+
+

Adding requirements to the PHPCI composer.json file is no longer recommended as a method of installing your required testing tools.
+ For this reason, we have removed the ability for PHPCI to modify the composer.json file for you. + We recommend that you install testing tools using your project's own composer.json file, by adding them to the "require-dev" section of the file.

- -
-
+
+
+
+

+
+ + + + + + + + + + + + + + + + + + +
name; ?>class; ?>source; ?>
+
+
+ +

@@ -58,44 +53,6 @@ - - - - - - - - - -
- -
- -
-
-
-

-
- - - - - - - - - - - $version): ?> - - - - - @@ -105,108 +62,3 @@ -
-
-

-
- -
-
- - - - -
- -
- - - -
- - - - - - - - - - -
-
-
- -
- - - -