class View in Drupal 8
Same name in this branch
- 8 core/modules/views/src/Element/View.php \Drupal\views\Element\View
 - 8 core/modules/views/src/Entity/View.php \Drupal\views\Entity\View
 - 8 core/modules/views/src/Plugin/views/area/View.php \Drupal\views\Plugin\views\area\View
 
Same name and namespace in other branches
- 9 core/modules/views/src/Element/View.php \Drupal\views\Element\View
 
Provides a render element to display a view.
Plugin annotation
@RenderElement("view");
  Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\Core\Render\Element\RenderElement implements ElementInterface
- class \Drupal\views\Element\View
 
 
 - class \Drupal\Core\Render\Element\RenderElement implements ElementInterface
 
 - class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
 
Expanded class hierarchy of View
1 file declares its use of View
- ViewsBlock.php in core/
modules/ views/ src/ Plugin/ Block/ ViewsBlock.php  
19 string references to 'View'
- aggregator.links.task.yml in core/
modules/ aggregator/ aggregator.links.task.yml  - core/modules/aggregator/aggregator.links.task.yml
 - BookAdminEditForm::bookAdminTableTree in core/
modules/ book/ src/ Form/ BookAdminEditForm.php  - Helps build the main table in the book administration page form.
 - BookTest::testAdminBookNodeListing in core/
modules/ book/ tests/ src/ Functional/ BookTest.php  - Tests the administrative listing of all book pages in a book.
 - dblog.links.task.yml in core/
modules/ dblog/ dblog.links.task.yml  - core/modules/dblog/dblog.links.task.yml
 - DynamicLocalTasks::getDerivativeDefinitions in core/
modules/ media/ src/ Plugin/ Derivative/ DynamicLocalTasks.php  - Gets the definition of all derivatives of a base plugin.
 
13 #type uses of View
- DisplayPluginBase::buildBasicRenderable in core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php  - Builds a basic render array which can be properly render cached.
 - DisplayPluginBase::buildRenderable in core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php  - Builds a renderable array of the view.
 - FieldRenderedEntityTest::testRenderedEntityWithField in core/
modules/ views/ tests/ src/ Kernel/ Handler/ FieldRenderedEntityTest.php  - Tests the rendered entity output with the test field configured to show.
 - FieldRenderedEntityTest::testRenderedEntityWithoutField in core/
modules/ views/ tests/ src/ Kernel/ Handler/ FieldRenderedEntityTest.php  - Tests the default rendered entity output.
 - ViewPageControllerTest::testHandleWithArgumentsOnOverriddenRoute in core/
modules/ views/ tests/ src/ Unit/ Routing/ ViewPageControllerTest.php  - Tests the page controller with arguments of a overridden page view.
 
File
- core/
modules/ views/ src/ Element/ View.php, line 13  
Namespace
Drupal\views\ElementView source
class View extends RenderElement {
  /**
   * {@inheritdoc}
   */
  public function getInfo() {
    $class = get_class($this);
    return [
      '#pre_render' => [
        [
          $class,
          'preRenderViewElement',
        ],
      ],
      '#name' => NULL,
      '#display_id' => 'default',
      '#arguments' => [],
      '#embed' => TRUE,
      '#cache' => [],
    ];
  }
  /**
   * View element pre render callback.
   */
  public static function preRenderViewElement($element) {
    // Allow specific Views displays to explicitly perform pre-rendering, for
    // those displays that need to be able to know the fully built render array.
    if (!empty($element['#pre_rendered'])) {
      return $element;
    }
    if (!isset($element['#view'])) {
      $view = Views::getView($element['#name']);
    }
    else {
      $view = $element['#view'];
    }
    $element += $view->element;
    $view->element =& $element;
    // Mark the element as being prerendered, so other code like
    // \Drupal\views\ViewExecutable::setCurrentPage knows that its no longer
    // possible to manipulate the $element.
    $view->element['#pre_rendered'] = TRUE;
    if (isset($element['#response'])) {
      $view
        ->setResponse($element['#response']);
    }
    if ($view && $view
      ->access($element['#display_id'])) {
      if (!empty($element['#embed'])) {
        $element['view_build'] = $view
          ->preview($element['#display_id'], $element['#arguments']);
      }
      else {
        // Add contextual links to the view. We need to attach them to the dummy
        // $view_array variable, since contextual_preprocess() requires that they
        // be attached to an array (not an object) in order to process them. For
        // our purposes, it doesn't matter what we attach them to, since once they
        // are processed by contextual_preprocess() they will appear in the
        // $title_suffix variable (which we will then render in
        // views-view.html.twig).
        $view
          ->setDisplay($element['#display_id']);
        // Add the result of the executed view as a child element so any
        // #pre_render elements for the view will get processed. A #pre_render
        // element cannot be added to the main element as this is already inside
        // a #pre_render callback.
        $element['view_build'] = $view
          ->executeDisplay($element['#display_id'], $element['#arguments']);
        if (isset($element['view_build']['#title'])) {
          $element['#title'] =& $element['view_build']['#title'];
        }
        if (empty($view->display_handler
          ->getPluginDefinition()['returns_response'])) {
          // views_add_contextual_links() needs the following information in
          // order to be attached to the view.
          $element['#view_id'] = $view->storage
            ->id();
          $element['#view_display_show_admin_links'] = $view
            ->getShowAdminLinks();
          $element['#view_display_plugin_id'] = $view->display_handler
            ->getPluginId();
          views_add_contextual_links($element, 'view', $view->current_display);
        }
      }
      if (empty($view->display_handler
        ->getPluginDefinition()['returns_response'])) {
        $element['#attributes']['class'][] = 'views-element-container';
        $element['#theme_wrappers'] = [
          'container',
        ];
      }
    }
    return $element;
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            DependencySerializationTrait:: | 
                  protected | property | An array of entity type IDs keyed by the property name of their storages. | |
| 
            DependencySerializationTrait:: | 
                  protected | property | An array of service IDs keyed by property name used for serialization. | |
| 
            DependencySerializationTrait:: | 
                  public | function | 1 | |
| 
            DependencySerializationTrait:: | 
                  public | function | 2 | |
| 
            MessengerTrait:: | 
                  protected | property | The messenger. | 29 | 
| 
            MessengerTrait:: | 
                  public | function | Gets the messenger. | 29 | 
| 
            MessengerTrait:: | 
                  public | function | Sets the messenger. | |
| 
            PluginBase:: | 
                  protected | property | Configuration information passed into the plugin. | 1 | 
| 
            PluginBase:: | 
                  protected | property | The plugin implementation definition. | 1 | 
| 
            PluginBase:: | 
                  protected | property | The plugin_id. | |
| 
            PluginBase:: | 
                  constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
| 
            PluginBase:: | 
                  public | function | 
            Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: | 
                  |
| 
            PluginBase:: | 
                  public | function | 
            Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: | 
                  |
| 
            PluginBase:: | 
                  public | function | 
            Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: | 
                  3 | 
| 
            PluginBase:: | 
                  public | function | 
            Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: | 
                  |
| 
            PluginBase:: | 
                  public | function | Determines if the plugin is configurable. | |
| 
            PluginBase:: | 
                  public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 | 
| 
            RenderElement:: | 
                  public static | function | Adds Ajax information about an element to communicate with JavaScript. | |
| 
            RenderElement:: | 
                  public static | function | Adds members of this group as actual elements for rendering. | |
| 
            RenderElement:: | 
                  public static | function | Form element processing handler for the #ajax form property. | 1 | 
| 
            RenderElement:: | 
                  public static | function | Arranges elements into groups. | |
| 
            RenderElement:: | 
                  public static | function | 
            Sets a form element's class attribute. Overrides ElementInterface:: | 
                  |
| 
            StringTranslationTrait:: | 
                  protected | property | The string translation service. | 1 | 
| 
            StringTranslationTrait:: | 
                  protected | function | Formats a string containing a count of items. | |
| 
            StringTranslationTrait:: | 
                  protected | function | Returns the number of plurals supported by a given language. | |
| 
            StringTranslationTrait:: | 
                  protected | function | Gets the string translation service. | |
| 
            StringTranslationTrait:: | 
                  public | function | Sets the string translation service to use. | 2 | 
| 
            StringTranslationTrait:: | 
                  protected | function | Translates a string to the current language or to a given language. | |
| 
            View:: | 
                  public | function | 
            Returns the element properties for this element. Overrides ElementInterface:: | 
                  |
| 
            View:: | 
                  public static | function | View element pre render callback. |