Prevent fatal error while loading authors data

This commit is contained in:
Keegan Rankin 2023-07-03 14:25:23 -07:00
parent 3ddef4a97f
commit fa27dc1a4d

View file

@ -129,8 +129,8 @@ function agarica_languague_switch_link() {
function agarica_preprocess_field__field_title(&$variables) { function agarica_preprocess_field__field_title(&$variables) {
$parentEntity = $variables['element']['#object']->getParentEntity(); $parentEntity = $variables['element']['#object']->getParentEntity();
if ($parentEntity instanceof EntityInterface && $parentEntity->getEntityTypeId() === 'node') { if ($parentEntity instanceof EntityInterface && $parentEntity->getEntityTypeId() === 'node') {
if ($parentEntity->get('field_authors')) { if (isset($parentEntity->getFields()['field_authors'])) {
$field_authors = $parentEntity->get('field_authors'); $field_authors = $parentEntity->getFields()['field_authors'];
$authors = ''; $authors = '';
$date = $parentEntity->getCreatedTime(); $date = $parentEntity->getCreatedTime();
foreach ($field_authors as $author) { foreach ($field_authors as $author) {