You are here

public function AchVersionAttribute::onBuildClientCdf in Acquia Content Hub 8.2

Method called on the BUILD_CLIENT_CDF event.

Adds ACH module version attribute to the cdf.

Parameters

\Drupal\acquia_contenthub\Event\BuildClientCdfEvent $event: The event being dispatched.

Throws

\Exception

File

src/EventSubscriber/CdfAttributes/AchVersionAttribute.php, line 63

Class

AchVersionAttribute
Adds ACH module version attribute to client CDF.

Namespace

Drupal\acquia_contenthub\EventSubscriber\CdfAttributes

Code

public function onBuildClientCdf(BuildClientCdfEvent $event) {
  $cdf = $event
    ->getCdf();
  $ach_attributes['current'] = $this
    ->getAchVersion();
  $ch_latest_versions = $this->pvClient
    ->getContentHubReleases();
  if (!empty($ch_latest_versions)) {
    $ch_latest_version = $ch_latest_versions['latest'];
    $ch_latest_version = substr($ch_latest_version, strpos($ch_latest_version, '-') + 1);
    $ach_attributes['latest'] = $ch_latest_version;
  }
  $cdf
    ->addAttribute('ch_version', CDFAttribute::TYPE_ARRAY_STRING);
  $attribute = $cdf
    ->getAttribute('ch_version');
  $attribute
    ->setValue($ach_attributes);
}