class NodeRevision

Tests creating node revision views with the wizard.

Plugin annotation


@Plugin(
  id = "node_revision",
  module = "node",
  base_table = "node_field_revision",
  title = @Translation("Content revisions")
)

Hierarchy

Expanded class hierarchy of NodeRevision

File

drupal/core/modules/node/lib/Drupal/node/Plugin/views/wizard/NodeRevision.php, line 28
Definition of Drupal\node\Plugin\views\wizard\NodeRevision.

Namespace

Drupal\node\Plugin\views\wizard
View source
class NodeRevision extends WizardPluginBase {

  /**
   * Set the created column.
   */
  protected $createdColumn = 'timestamp';

  /**
   * Set default values for the path field options.
   */
  protected $pathField = array(
    'id' => 'vid',
    'table' => 'node_field_revision',
    'field' => 'vid',
    'exclude' => TRUE,
    'alter' => array(
      'alter_text' => TRUE,
      'text' => 'node/[nid]/revisions/[vid]/view',
    ),
  );

  /**
   * Set the additional information for the pathField property.
   */
  protected $pathFieldsSupplemental = array(
    array(
      'id' => 'nid',
      'table' => 'node',
      'field' => 'nid',
      'exclude' => TRUE,
      'link_to_node' => FALSE,
    ),
  );

  /**
   * Set default values for the filters.
   */
  protected $filters = array(
    'status' => array(
      'value' => TRUE,
      'table' => 'node_field_revision',
      'field' => 'status',
    ),
  );

  /**
   * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::rowStyleOptions().
   *
   * Node revisions do not support full posts or teasers, so remove them.
   */
  protected function rowStyleOptions() {
    $options = parent::rowStyleOptions();
    unset($options['teasers']);
    unset($options['full_posts']);
    return $options;
  }

  /**
   * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayOptions().
   */
  protected function defaultDisplayOptions() {
    $display_options = parent::defaultDisplayOptions();

    // Add permission-based access control.
    $display_options['access']['type'] = 'perm';
    $display_options['access']['perm'] = 'view revisions';

    // Remove the default fields, since we are customizing them here.
    unset($display_options['fields']);

    /* Field: Content revision: Created date */
    $display_options['fields']['timestamp']['id'] = 'timestamp';
    $display_options['fields']['timestamp']['table'] = 'node_field_revision';
    $display_options['fields']['timestamp']['field'] = 'timestamp';
    $display_options['fields']['timestamp']['alter']['alter_text'] = 0;
    $display_options['fields']['timestamp']['alter']['make_link'] = 0;
    $display_options['fields']['timestamp']['alter']['absolute'] = 0;
    $display_options['fields']['timestamp']['alter']['trim'] = 0;
    $display_options['fields']['timestamp']['alter']['word_boundary'] = 0;
    $display_options['fields']['timestamp']['alter']['ellipsis'] = 0;
    $display_options['fields']['timestamp']['alter']['strip_tags'] = 0;
    $display_options['fields']['timestamp']['alter']['html'] = 0;
    $display_options['fields']['timestamp']['hide_empty'] = 0;
    $display_options['fields']['timestamp']['empty_zero'] = 0;

    /* Field: Content revision: Title */
    $display_options['fields']['title']['id'] = 'title';
    $display_options['fields']['title']['table'] = 'node_field_revision';
    $display_options['fields']['title']['field'] = 'title';
    $display_options['fields']['title']['label'] = '';
    $display_options['fields']['title']['alter']['alter_text'] = 0;
    $display_options['fields']['title']['alter']['make_link'] = 0;
    $display_options['fields']['title']['alter']['absolute'] = 0;
    $display_options['fields']['title']['alter']['trim'] = 0;
    $display_options['fields']['title']['alter']['word_boundary'] = 0;
    $display_options['fields']['title']['alter']['ellipsis'] = 0;
    $display_options['fields']['title']['alter']['strip_tags'] = 0;
    $display_options['fields']['title']['alter']['html'] = 0;
    $display_options['fields']['title']['hide_empty'] = 0;
    $display_options['fields']['title']['empty_zero'] = 0;
    $display_options['fields']['title']['link_to_node'] = 0;
    $display_options['fields']['title']['link_to_node_revision'] = 1;
    return $display_options;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContainerFactoryPluginBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 11
NodeRevision::$createdColumn protected property Set the created column. Overrides WizardPluginBase::$createdColumn
NodeRevision::$filters protected property Set default values for the filters. Overrides WizardPluginBase::$filters
NodeRevision::$pathField protected property Set default values for the path field options. Overrides WizardPluginBase::$pathField
NodeRevision::$pathFieldsSupplemental protected property Set the additional information for the pathField property. Overrides WizardPluginBase::$pathFieldsSupplemental
NodeRevision::defaultDisplayOptions protected function Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayOptions(). Overrides WizardPluginBase::defaultDisplayOptions
NodeRevision::rowStyleOptions protected function Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::rowStyleOptions(). Overrides WizardPluginBase::rowStyleOptions
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$definition public property Plugins's definition
PluginBase::$displayHandler public property The display object this plugin is for.
PluginBase::$options public property Options for this plugin will be held here.
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::$usesOptions protected property Denotes whether the plugin has an additional options form. 8
PluginBase::$view public property The top object of a view. 1
PluginBase::buildOptionsForm public function Provide a form to edit options for this plugin. 15
PluginBase::defineOptions protected function Information about options for all kinds of purposes will be held here. @code 'option_name' => array( 14
PluginBase::destroy public function Clears a plugin. 2
PluginBase::getAvailableGlobalTokens public function Returns an array of available token replacements.
PluginBase::getPluginDefinition public function Returns the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::globalTokenForm public function Adds elements for available core tokens to a form.
PluginBase::globalTokenReplace public function Returns a string with any core tokens replaced.
PluginBase::init public function Initialize the plugin. 8
PluginBase::pluginTitle public function Return the human readable name of the display.
PluginBase::query public function Add anything to the query that we might need to. 13
PluginBase::setOptionDefaults protected function Fills up the options of the plugin with defaults.
PluginBase::submitOptionsForm public function Handle any special handling on the validate form. 11
PluginBase::summaryTitle public function Returns the summary of the settings in the display. 6
PluginBase::themeFunctions public function Provide a full list of possible theme templates used by this style. 1
PluginBase::unpackOptions public function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.
PluginBase::usesOptions public function Returns the usesOptions property. 8
PluginBase::validate public function Validate that the plugin is correct and can be saved. 4
PluginBase::validateOptionsForm public function Validate the options form. 11
WizardPluginBase::$availableSorts protected property The available store criteria.
WizardPluginBase::$base_table protected property The base table connected with the wizard.
WizardPluginBase::$entity_info protected property Contains the information from entity_get_info of the $entity_type.
WizardPluginBase::$entity_type protected property The entity type connected with the wizard.
WizardPluginBase::$filter_defaults protected property Default values for filters.
WizardPluginBase::$sorts protected property Views items configuration arrays for sorts added by the wizard.
WizardPluginBase::$validated_views protected property An array of validated view objects, keyed by a hash.
WizardPluginBase::addDisplays protected function Adds the array of display options to the view, with appropriate overrides.
WizardPluginBase::alterDisplayOptions protected function Alters the full array of display options before they are added to the view.
WizardPluginBase::blockDisplayOptions protected function Retrieves the block display options. 2
WizardPluginBase::buildDisplayOptions protected function Builds an array of display options for the view.
WizardPluginBase::buildFilters protected function Builds the form structure for selecting the view's filters. 1
WizardPluginBase::buildForm public function Drupal\views\Plugin\views\wizard\WizardInterface::buildForm(). Overrides WizardInterface::buildForm
WizardPluginBase::buildFormStyle protected function Adds the style options to the wizard form. 2
WizardPluginBase::buildSorts protected function Builds the form structure for selecting the view's sort order.
WizardPluginBase::createView public function Creates a view from values that have already been validated. Overrides WizardInterface::createView
WizardPluginBase::defaultDisplayFilters protected function Retrieves all filter information used by the default display.
WizardPluginBase::defaultDisplayFiltersUser protected function Retrieves filter information based on user input for the default display. 1
WizardPluginBase::defaultDisplaySorts protected function Retrieves all sort information used by the default display.
WizardPluginBase::defaultDisplaySortsUser protected function Retrieves sort information based on user input for the default display.
WizardPluginBase::getAvailableSorts public function Gets the availableSorts property. 1
WizardPluginBase::getCreatedColumn public function Gets the createdColumn property.
WizardPluginBase::getFilters public function Gets the filters property.
WizardPluginBase::getPathField public function Gets the pathField property.
WizardPluginBase::getPathFieldsSupplemental public function Gets the pathFieldsSupplemental property.
WizardPluginBase::getSelected public static function Gets the current value of a #select element, from within a form constructor function.
WizardPluginBase::getSorts public function Gets the sorts property.
WizardPluginBase::instantiateView protected function Instantiates a view object from form values.
WizardPluginBase::pageDisplayOptions protected function Retrieves the page display options. 2
WizardPluginBase::pageFeedDisplayOptions protected function Retrieves the feed display options.
WizardPluginBase::retrieveValidatedView protected function Retrieves a validated view for a form submission.
WizardPluginBase::setDefaultOptions protected function Sets options for a display and makes them the default options if possible.
WizardPluginBase::setOverrideOptions protected function Sets options for a display, inheriting from the defaults when possible.
WizardPluginBase::setValidatedView protected function Stores a validated view from a form submission.
WizardPluginBase::validateView public function Implements Drupal\views\Plugin\views\wizard\WizardInterface::validate(). Overrides WizardInterface::validateView
WizardPluginBase::__construct public function Constructs a WizardPluginBase object. Overrides PluginBase::__construct