Browse Source

Merge pull request #15 from chrismacdonaldw/bcir_270

BCIR-270: Delete fixity_check entities if there aren't any files attached
pull/18/head v1.2.1
Noel Chiasson 11 months ago committed by GitHub
parent
commit
c89fe47e16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      src/Entity/FixityCheck.php

8
src/Entity/FixityCheck.php

@ -208,7 +208,13 @@ class FixityCheck extends ContentEntityBase implements FixityCheckInterface {
public function getFile(): ?File { public function getFile(): ?File {
/** @var \Drupal\Core\Field\EntityReferenceFieldItemList $file */ /** @var \Drupal\Core\Field\EntityReferenceFieldItemList $file */
$file = $this->file; $file = $this->file;
return $file->isEmpty() ? NULL : $file->referencedEntities()[0];
if ($file->isEmpty()) {
return NULL;
}
$referenced_entities = $file->referencedEntities();
return !empty($referenced_entities) ? reset($referenced_entities) : NULL;
} }
/** /**

Loading…
Cancel
Save