Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. public function build() {
  2. if ($entity_id = $this->configuration['entity']) {
  3. if (($entity = $this->entityStorage->load($entity_id)) && $entity->access('view')) {
  4. $render_controller = Drupal::entityTypeManager()->getViewBuilder($entity->getEntityTypeId());
  5. $view_mode = isset($this->configuration['view_mode']) ? $this->configuration['view_mode'] : 'default';
  6.  
  7. if (isset($this->configuration['card_colour'])) {
  8. $entity->card_colour = $this->configuration['card_colour'];
  9. }
  10. if (isset($this->configuration['card_layout'])) {
  11. $entity->card_layout = $this->configuration['card_layout'];
  12. }
  13.  
  14. return $render_controller->view($entity, $view_mode);
  15. }
  16. }
  17.  
  18. return [];
  19.  
  20. {%
  21. set classes = [
  22. 'node-card',
  23. 'card-' ~ node.card_layout|clean_class,
  24. node.card_colour|clean_class,
  25. 'clearfix'
  26. ]
  27. %}
  28. <article{{ attributes.addClass(classes) }}>
  29. <div{{ content_attributes.addClass('bg-img', 'clearfix') }} style="background-image: url()">
  30. <div class="summary">
  31. {{ content.body }}
  32. </div>
  33. </div>
  34. </article>
  35.  
  36. $entity = clone $entity;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement