Skip to content

Commit

Permalink
#1059: Prevent error when Media lacks a File (#1060)
Browse files Browse the repository at this point in the history
  • Loading branch information
xurizaemon authored Oct 28, 2024
1 parent c104e45 commit 9e0d874
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Plugin/ContextReaction/JsonldSelfReferenceReaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ public function execute(EntityInterface $entity = NULL, array &$normalized = NUL
if (isset($normalized['@graph']) && is_array($normalized['@graph'])) {
foreach ($normalized['@graph'] as &$graph) {
if (isset($graph['@id']) && $graph['@id'] == $url) {
// Swap media and file urls.
// If a file URL is available, swap it in as the ID.
if ($entity instanceof MediaInterface) {
$file = $this->mediaSource->getSourceFile($entity);
$graph['@id'] = $this->utils->getDownloadUrl($file);
if ($file = $this->mediaSource->getSourceFile($entity)) {
$graph['@id'] = $this->utils->getDownloadUrl($file);
}
}
if (isset($graph[$self_ref_predicate])) {
if (!is_array($graph[$self_ref_predicate])) {
Expand Down

0 comments on commit 9e0d874

Please sign in to comment.