You are here

public function AcsfExtraCommands::getFactoryCreds in Acquia Cloud Site Factory Connector 8.2

Print credentials retrieved from the factory.

@command acsf-get-factory-creds @bootstrap root

Return value

\Consolidation\OutputFormatters\StructuredData\PropertyList Gives back the creds in json format.

Throws

\Drupal\acsf\AcsfException If the function couldn't retrieve the necessary creds.

File

src/Commands/AcsfExtraCommands.php, line 32

Class

AcsfExtraCommands
Provides drush commands for site related operations.

Namespace

Drush\Commands

Code

public function getFactoryCreds() {
  if (!class_exists('\\Drupal\\acsf\\AcsfConfigDefault')) {

    // Since there might not be a bootstrap, we need to find our config
    // objects.
    $include_path = realpath(dirname(__FILE__));
    require_once $include_path . '/src/AcsfConfig.php';
    require_once $include_path . '/src/AcsfConfigDefault.php';
    require_once $include_path . '/src/AcsfConfigIncompleteException.php';
    require_once $include_path . '/src/AcsfConfigMissingCredsException.php';
  }
  try {
    $config = new AcsfConfigDefault();
  } catch (\Exception $e) {
    throw new AcsfException('Failed to get config: ' . $e
      ->getMessage());
  }
  $creds = [
    'url' => $config
      ->getUrl(),
    'username' => $config
      ->getUsername(),
    'password' => $config
      ->getPassword(),
    'url_suffix' => $config
      ->getUrlSuffix(),
  ];
  return new PropertyList($creds);
}