xtcentity-2.x-dev/src/Entity/XtendedContentViewBuilder.php

src/Entity/XtendedContentViewBuilder.php
<?php


namespace Drupal\xtcentity\Entity;

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityViewBuilder;

class XtendedContentViewBuilder extends EntityViewBuilder
{

  /**
   * @var XtendedContent
   */
  var $xtcentity;

  /**
   * {@inheritdoc}
   */
  public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
    $this->xtcentity = $entity;
    $build_list = $this->viewMultiple([$entity], $view_mode, $langcode);

    // The default ::buildMultiple() #pre_render callback won't run, because we
    // extract a child element of the default renderable array. Thus we must
    // assign an alternative #pre_render callback that applies the necessary
    // transformations and then still calls ::buildMultiple().
    $build = $build_list[0];
    $build['#pre_render'][] = [$this, 'build'];

    return $build;
  }

  }

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc