Skip to content

Commit

Permalink
Revert "Merge pull request #197 from palantirnet/the-build-coding-sta…
Browse files Browse the repository at this point in the history
…ndard"

This reverts commit 520f344, reversing
changes made to 0e54453.
  • Loading branch information
byrond committed Jan 6, 2023
1 parent f3280e1 commit 11cd797
Show file tree
Hide file tree
Showing 10 changed files with 311 additions and 411 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Install, update and uninstall functions for the-build utility module.
*/

use Drupal\user\Entity\User;
use Drupal\user\RoleInterface;
use Drupal\shortcut\Entity\Shortcut;

/**
Expand Down Expand Up @@ -52,34 +54,23 @@ function the_build_utility_install() {
$date_settings->save(TRUE);

// Install modules that we want but are not included with standard profile.
$install = [
'admin_toolbar',
'admin_toolbar_tools',
'config_split',
'devel',
'workbench',
'workbench_tabs',
];
$install = ['admin_toolbar', 'admin_toolbar_tools', 'config_split', 'devel', 'workbench', 'workbench_tabs'];
\Drupal::service('module_installer')->install($install);

// Remove comment fields so that comment module can be uninstalled.
// Remove any entity dependencies so we can uninstall modules.

// Begin Comment module.
// Remove the comment fields.
$fields = \Drupal::entityTypeManager()->getStorage('field_storage_config')->loadByProperties(['type' => 'comment']);
foreach ($fields as $field) {
$field->delete();
}

// Remove state variable from comment module.
// Remove state setting.
\Drupal::state()->delete('comment.node_comment_statistics_scale');
// End Comment module.

// Uninstall the modules from the standard profile that we don't want.
$uninstall = [
'automated_cron',
'big_pipe',
'comment',
'contact',
'history',
'search',
'tour',
];
$uninstall = ['automated_cron', 'big_pipe', 'comment', 'contact', 'history', 'search', 'tour'];
\Drupal::service('module_installer')->uninstall($uninstall);
}
35 changes: 0 additions & 35 deletions phpcs.xml

This file was deleted.

85 changes: 45 additions & 40 deletions src/TheBuild/Acquia/AcquiaTask.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,57 @@
<?php
/**
* @file AcquiaTask.php
*
* Abastract base task for creating Acquia Cloud API tasks.
*
* Loads the Acquia Cloud credentials from a JSON file and constructs
* authenticated requests against the Cloud API.
*
* This class will use the credentials file at ~/.acquia/cloudapi.conf if none
* is provided in the task call:
*
* @code
* <exampleTask credentialsFile="artifacts/cloudapi.conf" />
* @endcode
*
* Extending classes may also set the 'endpoint' property if it is necessary to
* use the v2 API instead of v1.
*
* @copyright 2018 Palantir.net, Inc.
*/

namespace TheBuild\Acquia;

/**
* Phing task for making queries against the Acquia Cloud v1 API.
*/
use BuildException;
use HTTP_Request2;
use PhingFile;

abstract class AcquiaTask extends \Task {

/**
* Required. The Acquia Cloud credentials file.
*
* This file can be downloaded from your Acquia user account area and contains
* a json array with 'mail' and 'key' values.
*
* Required. The Acquia Cloud credentials file containing a json array with
* 'mail' and 'key' values.
* @var \PhingFile
*/
protected $credentialsFile;

/**
* Email address associated with the Acquia Cloud access.
*
* This value is set from the credentials file.
*
* Email address associated with the Acquia Cloud access. This value is set
* from the credentials file.
* @var string
*/
protected $mail;

/**
* Secure key associated with the Acquia Cloud access.
*
* This value is set from the credentials file.
*
* Secure key associated with the Acquia Cloud access. This value is set from
* the credentials file.
* @var string
*/
protected $key;

/**
* The Acquia Cloud API v1 endpoint.
*
* The Acquia Cloud API endpoint. This code is specific to version 1 of the
* API.
* @var string
*/
protected $endpoint = 'https://cloudapi.acquia.com/v1';
Expand All @@ -53,11 +67,11 @@ abstract class AcquiaTask extends \Task {
protected function loadCredentials() {
if (empty($this->mail) || empty($this->key)) {
if (empty($this->credentialsFile)) {
$this->credentialsFile = new \PhingFile($_SERVER['HOME'] . '/.acquia/cloudapi.conf');
$this->credentialsFile = new PhingFile($_SERVER['HOME'] . '/.acquia/cloudapi.conf');
}

if (!file_exists($this->credentialsFile) || !is_readable($this->credentialsFile)) {
throw new \BuildException("Acquia Cloud credentials file '{$this->credentialsFile}' is not available.");
throw new BuildException("Acquia Cloud credentials file '{$this->credentialsFile}' is not available.");
}

$contents = file_get_contents($this->credentialsFile);
Expand All @@ -68,25 +82,22 @@ protected function loadCredentials() {
}

if (empty($this->mail) || empty($this->key)) {
throw new \BuildException('Missing Acquia Cloud API credentials.');
throw new BuildException('Missing Acquia Cloud API credentials.');
}
}

/**
* Build an HTTP request object against the Acquia Cloud API.
*
* @param string $path
* Acquia Cloud API path.
*
* @return \HTTP_Request2
* Request object.
* @param $path
* @return HTTP_Request2
*/
protected function createRequest(string $path) : \HTTP_Request2 {
protected function createRequest($path) {
$this->loadCredentials();

$uri = $this->endpoint . '/' . ltrim($path, '/');

$request = new \HTTP_Request2($uri);
$request = new HTTP_Request2($uri);
$request->setConfig('follow_redirects', TRUE);
$request->setAuth($this->mail, $this->key);

Expand All @@ -96,13 +107,11 @@ protected function createRequest(string $path) : \HTTP_Request2 {
/**
* Example of how to query the Acquia Cloud API.
*
* @param string $path
* Acquia Cloud API path.
*
* @param $path
* @return string
* API response.
* @throws \HTTP_Request2_Exception
*/
protected function getApiResponseBody(string $path) : string {
protected function getApiResponseBody($path) {
$request = $this->createRequest($path);

$this->log('GET ' . $request->getUrl());
Expand All @@ -111,16 +120,12 @@ protected function getApiResponseBody(string $path) : string {
}

/**
* Set the Acquia credentials file.
*
* @param \PhingFile $file
* Acquia credentials file.
*
* @param PhingFile $file
* @throws \IOException
* @throws \NullPointerException
*/
public function setCredentialsFile(\PhingFile $file) {
$this->credentialsFile = new \PhingFile($file);
public function setCredentialsFile(PhingFile $file) {
$this->credentialsFile = new PhingFile($file);
}

}
Loading

0 comments on commit 11cd797

Please sign in to comment.