You are here

class AcquiaContentHubMappingCommands in Acquia Content Hub 8.2

Drush commands for printing Acquia Content Hub mappings.

@package Drupal\acquia_contenthub\Commands

Hierarchy

Expanded class hierarchy of AcquiaContentHubMappingCommands

1 string reference to 'AcquiaContentHubMappingCommands'
drush.services.yml in ./drush.services.yml
drush.services.yml
1 service uses AcquiaContentHubMappingCommands
acquia_contenthub.commands.mapping in ./drush.services.yml
Drupal\acquia_contenthub\Commands\AcquiaContentHubMappingCommands

File

src/Commands/AcquiaContentHubMappingCommands.php, line 13

Namespace

Drupal\acquia_contenthub\Commands
View source
class AcquiaContentHubMappingCommands extends DrushCommands {

  /**
   * The client factory.
   *
   * @var \Drupal\acquia_contenthub\Client\ClientFactory
   */
  protected $clientFactory;

  /**
   * AcquiaContentHubMappingCommands constructor.
   *
   * @param \Drupal\acquia_contenthub\Client\ClientFactory $client_factory
   *   The client factory.
   */
  public function __construct(ClientFactory $client_factory) {
    $this->clientFactory = $client_factory;
  }

  /**
   * Shows Elastic Search field mappings from Content Hub.
   *
   * @command acquia:contenthub-mapping
   * @aliases ach-mapping,acquia-contenthub-mapping
   *
   * @throws \Exception
   */
  public function contenthubMapping() {
    $client = $this->clientFactory
      ->getClient();
    if (!$client) {
      throw new \Exception(dt('Error trying to connect to the Content Hub. Make sure this site is registered to Content hub.'));
    }
    $output = $client
      ->mapping();
    if ($output) {
      $this
        ->output()
        ->writeln(print_r($output, TRUE));
    }
    else {
      throw new \Exception(dt("Error trying to print the elastic search field mappings."));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AcquiaContentHubMappingCommands::$clientFactory protected property The client factory.
AcquiaContentHubMappingCommands::contenthubMapping public function Shows Elastic Search field mappings from Content Hub.
AcquiaContentHubMappingCommands::__construct public function AcquiaContentHubMappingCommands constructor.