You are here

class PageVariantViewBuilder in Page Manager 8

Same name and namespace in other branches
  1. 8.4 src/Entity/PageVariantViewBuilder.php \Drupal\page_manager\Entity\PageVariantViewBuilder

Provides a view builder for page variant entities.

Hierarchy

Expanded class hierarchy of PageVariantViewBuilder

File

src/Entity/PageVariantViewBuilder.php, line 20
Contains \Drupal\page_manager\Entity\PageVariantViewBuilder.

Namespace

Drupal\page_manager\Entity
View source
class PageVariantViewBuilder implements EntityViewBuilderInterface {

  /**
   * {@inheritdoc}
   */
  public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {

    /** @var \Drupal\page_manager\PageVariantInterface $entity */
    $variant_plugin = $entity
      ->getVariantPlugin();
    if ($variant_plugin instanceof ContextAwareVariantInterface) {
      $variant_plugin
        ->setContexts($entity
        ->getContexts());
    }
    if ($variant_plugin instanceof RefinableCacheableDependencyInterface) {
      $variant_plugin
        ->addCacheableDependency($entity);
    }
    return $variant_plugin
      ->build();
  }

  /**
   * {@inheritdoc}
   */
  public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL) {
    $build = [];
    foreach ($entities as $key => $entity) {
      $build[$key] = $this
        ->view($entity, $view_mode, $langcode);
    }
    return $build;
  }

  /**
   * {@inheritdoc}
   */
  public function resetCache(array $entities = NULL) {

    // Intentionally empty.
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {

    // Intentionally empty.
  }

  /**
   * {@inheritdoc}
   */
  public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
    throw new \LogicException();
  }

  /**
   * {@inheritdoc}
   */
  public function viewField(FieldItemListInterface $items, $display_options = array()) {
    throw new \LogicException();
  }

  /**
   * {@inheritdoc}
   */
  public function viewFieldItem(FieldItemInterface $item, $display_options = array()) {
    throw new \LogicException();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PageVariantViewBuilder::buildComponents public function Builds the component fields and properties of a set of entities. Overrides EntityViewBuilderInterface::buildComponents
PageVariantViewBuilder::getCacheTags public function The cache tag associated with this entity view builder. Overrides EntityViewBuilderInterface::getCacheTags
PageVariantViewBuilder::resetCache public function Resets the entity render cache. Overrides EntityViewBuilderInterface::resetCache
PageVariantViewBuilder::view public function Builds the render array for the provided entity. Overrides EntityViewBuilderInterface::view
PageVariantViewBuilder::viewField public function Builds a renderable array for the value of a single field in an entity. Overrides EntityViewBuilderInterface::viewField
PageVariantViewBuilder::viewFieldItem public function Builds a renderable array for a single field item. Overrides EntityViewBuilderInterface::viewFieldItem
PageVariantViewBuilder::viewMultiple public function Builds the render array for the provided entities. Overrides EntityViewBuilderInterface::viewMultiple