class Comment

Tests creating comment views with the wizard.

Plugin annotation


@Plugin(
  id = "comment",
  module = "comment",
  base_table = "comment",
  title = @Translation("Comments")
)

Hierarchy

Expanded class hierarchy of Comment

26 string references to 'Comment'
CommentActionsTest::getInfo in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php
CommentAnonymousTest::getInfo in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php
CommentApprovalTest::getInfo in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentApprovalTest.php
CommentBlockTest::getInfo in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php
CommentContentRebuildTest::getInfo in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php

... See full list

File

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

Namespace

Drupal\comment\Plugin\views\wizard
View source
class Comment extends WizardPluginBase {

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

  /**
   * Set default values for the path field options.
   */
  protected $pathField = array(
    'id' => 'cid',
    'table' => 'comment',
    'field' => 'cid',
    'exclude' => TRUE,
    'link_to_comment' => FALSE,
    'alter' => array(
      'alter_text' => TRUE,
      'text' => 'comment/[cid]#comment-[cid]',
    ),
  );

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

  /**
   * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::row_style_options().
   */
  protected function row_style_options() {
    $options = array();
    $options['comment'] = t('comments');
    $options['fields'] = t('fields');
    return $options;
  }
  protected function build_form_style(array &$form, array &$form_state, $type) {
    parent::build_form_style($form, $form_state, $type);
    $style_form =& $form['displays'][$type]['options']['style'];

    // Some style plugins don't support row plugins so stop here if that's the
    // case.
    if (!isset($style_form['row_plugin']['#default_value'])) {
      return;
    }
    $row_plugin = $style_form['row_plugin']['#default_value'];
    switch ($row_plugin) {
      case 'comment':
        $style_form['row_options']['links'] = array(
          '#type' => 'select',
          '#title_display' => 'invisible',
          '#title' => t('Should links be displayed below each comment'),
          '#options' => array(
            1 => t('with links (allow users to reply to the comment, etc.)'),
            0 => t('without links'),
          ),
          '#default_value' => 1,
        );
        break;
    }
  }

  /**
   * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::page_display_options().
   */
  protected function page_display_options(array $form, array &$form_state) {
    $display_options = parent::page_display_options($form, $form_state);
    $row_plugin = isset($form_state['values']['page']['style']['row_plugin']) ? $form_state['values']['page']['style']['row_plugin'] : NULL;
    $row_options = isset($form_state['values']['page']['style']['row_options']) ? $form_state['values']['page']['style']['row_options'] : array();
    $this
      ->display_options_row($display_options, $row_plugin, $row_options);
    return $display_options;
  }

  /**
   * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::page_display_options().
   */
  protected function block_display_options(array $form, array &$form_state) {
    $display_options = parent::block_display_options($form, $form_state);
    $row_plugin = isset($form_state['values']['block']['style']['row_plugin']) ? $form_state['values']['block']['style']['row_plugin'] : NULL;
    $row_options = isset($form_state['values']['block']['style']['row_options']) ? $form_state['values']['block']['style']['row_options'] : array();
    $this
      ->display_options_row($display_options, $row_plugin, $row_options);
    return $display_options;
  }

  /**
   * Set the row style and row style plugins to the display_options.
   */
  protected function display_options_row(&$display_options, $row_plugin, $row_options) {
    switch ($row_plugin) {
      case 'comment':
        $display_options['row']['type'] = 'comment';
        $display_options['row']['options']['links'] = !empty($row_options['links']);
        break;
    }
  }

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

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

    // Add a relationship to nodes.
    $display_options['relationships']['nid']['id'] = 'nid';
    $display_options['relationships']['nid']['table'] = 'comment';
    $display_options['relationships']['nid']['field'] = 'nid';
    $display_options['relationships']['nid']['required'] = 1;

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

    /* Field: Comment: Title */
    $display_options['fields']['subject']['id'] = 'subject';
    $display_options['fields']['subject']['table'] = 'comment';
    $display_options['fields']['subject']['field'] = 'subject';
    $display_options['fields']['subject']['label'] = '';
    $display_options['fields']['subject']['alter']['alter_text'] = 0;
    $display_options['fields']['subject']['alter']['make_link'] = 0;
    $display_options['fields']['subject']['alter']['absolute'] = 0;
    $display_options['fields']['subject']['alter']['trim'] = 0;
    $display_options['fields']['subject']['alter']['word_boundary'] = 0;
    $display_options['fields']['subject']['alter']['ellipsis'] = 0;
    $display_options['fields']['subject']['alter']['strip_tags'] = 0;
    $display_options['fields']['subject']['alter']['html'] = 0;
    $display_options['fields']['subject']['hide_empty'] = 0;
    $display_options['fields']['subject']['empty_zero'] = 0;
    $display_options['fields']['subject']['link_to_comment'] = 1;
    return $display_options;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Comment::$createdColumn protected property Set the created column. Overrides WizardPluginBase::$createdColumn
Comment::$filters protected property Set default values for the filters. Overrides WizardPluginBase::$filters
Comment::$pathField protected property Set default values for the path field options. Overrides WizardPluginBase::$pathField
Comment::block_display_options protected function Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::page_display_options(). Overrides WizardPluginBase::block_display_options
Comment::build_form_style protected function Adds the style options to the wizard form. Overrides WizardPluginBase::build_form_style
Comment::default_display_options protected function Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::default_display_options(). Overrides WizardPluginBase::default_display_options
Comment::display_options_row protected function Set the row style and row style plugins to the display_options.
Comment::page_display_options protected function Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::page_display_options(). Overrides WizardPluginBase::page_display_options
Comment::row_style_options protected function Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::row_style_options(). Overrides WizardPluginBase::row_style_options
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$definition public property Plugins's definition
PluginBase::$discovery protected property The discovery object.
PluginBase::$displayHandler public property The display object this plugin is for.
PluginBase::$options public property Options for this plugin will be held here.
PluginBase::$plugin_id 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::additionalThemeFunctions public function Provide a list of additional theme functions for the theme information page
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::getDefinition public function Implements Drupal\Component\Plugin\PluginInterface::getDefinition(). Overrides PluginInspectionInterface::getDefinition
PluginBase::getPluginId public function Implements Drupal\Component\Plugin\PluginInterface::getPluginId(). 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::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
PluginBase::submitOptionsForm public function Handle any special handling on the validate form. 10
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::$pathFieldsSupplemental protected property Additional fields required to generate the pathField. 1
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::alter_display_options protected function Alters the full array of display options before they are added to the view.
WizardPluginBase::build_display_options protected function Builds an array of display options for the view.
WizardPluginBase::build_filters protected function Builds the form structure for selecting the view's filters. 1
WizardPluginBase::build_form function Implements Drupal\views\Plugin\views\wizard\WizardInterface::build_form(). Overrides WizardInterface::build_form
WizardPluginBase::build_sorts protected function Builds the form structure for selecting the view's sort order.
WizardPluginBase::create_view function Implements Drupal\views\Plugin\views\wizard\WizardInterface::create_view(). Overrides WizardInterface::create_view
WizardPluginBase::default_display_filters protected function Retrieves all filter information used by the default display.
WizardPluginBase::default_display_filters_user protected function Retrieves filter information based on user input for the default display. 1
WizardPluginBase::default_display_sorts protected function Retrieves all sort information used by the default display.
WizardPluginBase::default_display_sorts_user 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::instantiate_view protected function Instantiates a view object from form values.
WizardPluginBase::page_feed_display_options protected function Retrieves the feed display options.
WizardPluginBase::retrieve_validated_view 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::set_override_options protected function Sets options for a display, inheriting from the defaults when possible.
WizardPluginBase::set_validated_view 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