DefaultDisplay.php 2.06 KB
Newer Older
merlinofchaos's avatar
merlinofchaos committed
1 2 3 4
<?php

/**
 * @file
5
 * Definition of Drupal\views\Plugins\views\display\DefaultDisplay.
merlinofchaos's avatar
merlinofchaos committed
6 7
 */

8 9
namespace Drupal\views\Plugins\views\display;

10 11 12
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;

merlinofchaos's avatar
merlinofchaos committed
13 14 15 16 17
/**
 * A plugin to handle defaults on a view.
 *
 * @ingroup views_display_plugins
 */
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

/**
 * @Plugin(
 *   plugin_id = "standard",
 *   title = @Translation("Master"),
 *   help = @Translation("Default settings for this view."),
 *   theme = "views_view",
 *   no_ui = TRUE,
 *   no_remove = TRUE,
 *   use_ajax = TRUE,
 *   use_pager = TRUE,
 *   use_more = TRUE,
 *   accept_attachments = TRUE,
 *   help_topic = "display-default"
 * )
 */
34
class DefaultDisplay extends DisplayPluginBase {
merlinofchaos's avatar
merlinofchaos committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
  /**
   * Determine if this display is the 'default' display which contains
   * fallback settings
   */
  function is_default_display() { return TRUE; }

  /**
   * The default execute handler fully renders the view.
   *
   * For the simplest use:
   * @code
   *   $output = $view->execute_display('default', $args);
   * @endcode
   *
   * For more complex usages, a view can be partially built:
   * @code
   *   $view->set_arguments($args);
   *   $view->build('default'); // Build the query
   *   $view->pre_execute(); // Pre-execute the query.
   *   $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
   *   $view->set_arguments($args);
   *   $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.
   */
  function execute() {
    return $this->view->render($this->display->id);
  }
}