You are here

public function AcquiaContenthubCommands::contenthubRemote in Acquia Content Hub 8

Prints the CDF from a remote source (Content Hub)

@command acquia:contenthub-remote @aliases ach-re,acquia-contenthub-remote

Parameters

$uuid: Entity's UUID

File

src/Commands/AcquiaContenthubCommands.php, line 88

Class

AcquiaContenthubCommands
A Drush commandfile.

Namespace

Drupal\acquia_contenthub\Commands

Code

public function contenthubRemote($uuid) {
  if (Uuid::isValid($uuid)) {

    /** @var \Drupal\acquia_contenthub\Client\ClientManager $client_manager */
    $client_manager = \Drupal::service('acquia_contenthub.client_manager');
    if ($entity = $client_manager
      ->createRequest('readEntity', [
      $uuid,
    ])) {
      return $this
        ->output()
        ->writeln(print_r((array) $entity, TRUE));
    }
    else {
      $this
        ->output()
        ->writeln(dt("The Content Hub does not have an entity with UUID = @uuid.", [
        '@uuid' => $uuid,
      ]));
    }
  }
  else {
    throw new \Exception(dt("Argument provided is not a UUID."));
  }
  return FALSE;
}