You are here

public function FileEntityHandler::onCreateCdf in Acquia Content Hub 8.2

Add attributes to file entity CDF representations.

Parameters

\Drupal\acquia_contenthub\Event\CreateCdfEntityEvent $event: The create CDF entity event.

File

src/EventSubscriber/Cdf/FileEntityHandler.php, line 60

Class

FileEntityHandler
Manipulates file content entity CDF representation to better support files.

Namespace

Drupal\acquia_contenthub\EventSubscriber\Cdf

Code

public function onCreateCdf(CreateCdfEntityEvent $event) {
  if ($event
    ->getEntity()
    ->getEntityTypeId() == 'file') {

    /** @var \Drupal\file\FileInterface $entity */
    $entity = $event
      ->getEntity();
    $handler = $this->manager
      ->getHandlerForFile($entity);
    $handler
      ->addAttributes($event
      ->getCdf($entity
      ->uuid()), $entity);
  }
}