ItemViewBuilder.php 826 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Drupal\aggregator;
  3. use Drupal\Core\Entity\EntityViewBuilder;
  4. /**
  5. * View builder handler for aggregator feed items.
  6. */
  7. class ItemViewBuilder extends EntityViewBuilder {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
  12. parent::buildComponents($build, $entities, $displays, $view_mode);
  13. foreach ($entities as $id => $entity) {
  14. $bundle = $entity->bundle();
  15. $display = $displays[$bundle];
  16. if ($display->getComponent('description')) {
  17. $build[$id]['description'] = [
  18. '#markup' => $entity->getDescription(),
  19. '#allowed_tags' => _aggregator_allowed_tags(),
  20. '#prefix' => '<div class="item-description">',
  21. '#suffix' => '</div>',
  22. ];
  23. }
  24. }
  25. }
  26. }