Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / src / ParagraphViewBuilder.php
1 <?php
2
3 namespace Drupal\paragraphs;
4
5 use Drupal\Core\Entity\Entity\EntityViewDisplay;
6 use Drupal\Core\Entity\EntityViewBuilder;
7 use Drupal\Core\Render\Element;
8
9 /**
10  * Render controller for paragraphs.
11  */
12 class ParagraphViewBuilder extends EntityViewBuilder {
13
14   /**
15    * {@inheritdoc}
16    */
17   public function buildMultiple(array $build_list) {
18     $build_list = parent::buildMultiple($build_list);
19
20     // Allow enabled behavior plugin to alter the rendering.
21     foreach (Element::children($build_list) as $key) {
22       $build = $build_list[$key];
23       $display = EntityViewDisplay::load('paragraph.' . $build['#paragraph']->bundle() . '.' . $build['#view_mode']) ?: EntityViewDisplay::load('paragraph.' . $build['#paragraph']->bundle() . '.default');
24       $paragraph_type = $build['#paragraph']->getParagraphType();
25
26       // In case we use paragraphs type with no fields the EntityViewDisplay
27       // might not be available yet.
28       if (!$display) {
29         $display = EntityViewDisplay::create([
30           'targetEntityType' => 'paragraph',
31           'bundle' => $build['#paragraph']->bundle(),
32           'mode' => 'default',
33           'status' => TRUE,
34         ]);
35       }
36
37       foreach ($paragraph_type->getEnabledBehaviorPlugins() as $plugin_id => $plugin_value) {
38         $plugin_value->view($build_list[$key], $build['#paragraph'], $display, $build['#view_mode']);
39       }
40     }
41     return $build_list;
42   }
43
44 }