From 13822ec957d5514b2d8d1a3b8352b8648ab3ac07 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 4 Aug 2019 19:40:57 +0200 Subject: [PATCH] FIX articoli senza body --- src/Controller/CalendarRorController.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Controller/CalendarRorController.php b/src/Controller/CalendarRorController.php index 020b683..04545f9 100644 --- a/src/Controller/CalendarRorController.php +++ b/src/Controller/CalendarRorController.php @@ -34,9 +34,15 @@ class CalendarRorController extends ControllerBase { $nodes_e = \Drupal\node\Entity\Node::loadMultiple($nids); $data['nodes'] = array(); foreach($nodes_e as $nid => $node) { - $data['nodes'][$nid] = $node->toArray(); + $na = $node->toArray(); + if(count($na['body']) > 0) { // c'e' gente che pubblica articoli senza body + $body = $na['body'][0]['value']; + } else { + $body = ''; + } + $data['nodes'][$nid] = $na; $data['nodes'][$nid]['summary'] = htmlspecialchars(substr( - html_entity_decode(strip_tags($data['nodes'][$nid]['body'][0]['value'])), + html_entity_decode(strip_tags($body)), 0, 3500), ENT_XML1, 'UTF-8'); }