Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function build() {
- if ($entity_id = $this->configuration['entity']) {
- if (($entity = $this->entityStorage->load($entity_id)) && $entity->access('view')) {
- $render_controller = Drupal::entityTypeManager()->getViewBuilder($entity->getEntityTypeId());
- $view_mode = isset($this->configuration['view_mode']) ? $this->configuration['view_mode'] : 'default';
- if (isset($this->configuration['card_colour'])) {
- $entity->card_colour = $this->configuration['card_colour'];
- }
- if (isset($this->configuration['card_layout'])) {
- $entity->card_layout = $this->configuration['card_layout'];
- }
- return $render_controller->view($entity, $view_mode);
- }
- }
- return [];
- {%
- set classes = [
- 'node-card',
- 'card-' ~ node.card_layout|clean_class,
- node.card_colour|clean_class,
- 'clearfix'
- ]
- %}
- <article{{ attributes.addClass(classes) }}>
- <div{{ content_attributes.addClass('bg-img', 'clearfix') }} style="background-image: url()">
- <div class="summary">
- {{ content.body }}
- </div>
- </div>
- </article>
- $entity = clone $entity;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement