Skip to content

Commit

Permalink
Do not pass null to entity load as it generates a warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelgbanks committed Aug 7, 2020
1 parent a1b0479 commit 66259d3
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ function islandora_text_extraction_media_presave(MediaInterface $media) {
$text = $media->get('field_edited_text')->getValue();
if (!$text) {
$file_id = $media->get('field_media_file')->getValue()[0]['target_id'];
$file = File::load($file_id);
if ($file) {
$data = file_get_contents($file->getFileUri());
$data = nl2br($data);
$media->set('field_edited_text', $data);
$media->field_edited_text->format = 'basic_html';
if ($file_id) {
$file = File::load($file_id);
if ($file) {
$data = file_get_contents($file->getFileUri());
$data = nl2br($data);
$media->set('field_edited_text', $data);
$media->field_edited_text->format = 'basic_html';
}
}
}
}
Expand Down

0 comments on commit 66259d3

Please sign in to comment.