Skip to content
DefaultDisplay.php 2.01 KiB
Newer Older
Earl Miles's avatar
Earl Miles committed
<?php

/**
 * @file
 * Definition of Drupal\views\Plugin\views\display\DefaultDisplay.
namespace Drupal\views\Plugin\views\display;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;

Earl Miles's avatar
Earl Miles committed
/**
 * A plugin to handle defaults on a view.
 *
 * @ingroup views_display_plugins
Bram Goffings's avatar
Bram Goffings committed
 *   id = "default",
 *   title = @Translation("Master"),
 *   help = @Translation("Default settings for this view."),
 *   theme = "views_view",
class DefaultDisplay extends DisplayPluginBase {
  /**
   * Whether the display allows attachments.
   *
   * @var bool
   */
  protected $usesAttachments = TRUE;

Earl Miles's avatar
Earl Miles committed
  /**
   * Determine if this display is the 'default' display which contains
   * fallback settings
   */
  public function isDefaultDisplay() { return TRUE; }
Earl Miles's avatar
Earl Miles committed

  /**
   * The default execute handler fully renders the view.
   *
   * For the simplest use:
   * @code
   *   $output = $view->executeDisplay('default', $args);
Earl Miles's avatar
Earl Miles committed
   * @endcode
   *
   * For more complex usages, a view can be partially built:
   * @code
Earl Miles's avatar
Earl Miles committed
   *   $view->build('default'); // Build the query
   *   $view->preExecute(); // Pre-execute the query.
Earl Miles's avatar
Earl Miles committed
   *   $view->execute(); // Run the query
   *   $output = $view->render(); // Render the view
   * @endcode
   *
   * If short circuited at any point, look in $view->build_info for
   * information about the query. After execute, look in $view->result
   * for the array of objects returned from db_query.
   *
   * You can also do:
   * @code
Earl Miles's avatar
Earl Miles committed
   *   $output = $view->render('default'); // Render the view
   * @endcode
   *
   * This illustrates that render is smart enough to call build and execute
   * if these items have not already been accomplished.
   *
   * Note that execute also must accomplish other tasks, such
   * as setting page titles, breadcrumbs, and generating exposed filter
   * data if necessary.
   */
    return $this->view->render($this->display['id']);