public function HashCdfAttribute::onBuildClientCdf in Acquia Content Hub 8.2
On Build ClientCdf.
Parameters
\Drupal\acquia_contenthub\Event\BuildClientCdfEvent $event: The BuildClientCdfEvent object.
Throws
\Exception
File
- src/
EventSubscriber/ CdfAttributes/ HashCdfAttribute.php, line 50
Class
- HashCdfAttribute
- Calculates a hash value of the entity and stores it as an attribute.
Namespace
Drupal\acquia_contenthub\EventSubscriber\CdfAttributesCode
public function onBuildClientCdf(BuildClientCdfEvent $event) {
$cdf = $event
->getCdf();
$data = $cdf
->toArray();
unset($data['created'], $data['modified']);
$cdf
->addAttribute('hash', CDFAttribute::TYPE_KEYWORD, sha1(json_encode($data)));
$event
->stopPropagation();
}