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

/**
 * @file
5
 * Definition of Drupal\user\Plugin\views\wizard\Users.
merlinofchaos's avatar
merlinofchaos committed
6 7
 */

8
namespace Drupal\user\Plugin\views\wizard;
9

10
use Drupal\views\Plugin\views\wizard\WizardPluginBase;
11 12 13 14

/**
 * @todo: replace numbers with constants.
 */
15

merlinofchaos's avatar
merlinofchaos committed
16 17
/**
 * Tests creating user views with the wizard.
18
 *
19
 * @ViewsWizard(
aspilicious's avatar
aspilicious committed
20
 *   id = "users",
21
 *   base_table = "users_field_data",
22
 *   title = @Translation("Users")
23
 * )
merlinofchaos's avatar
merlinofchaos committed
24
 */
25
class Users extends WizardPluginBase {
26

27 28 29 30 31 32 33 34 35 36 37
  /**
   * Set the created column.
   */
  protected $createdColumn = 'created';

  /**
   * Set default values for the filters.
   */
  protected $filters = array(
    'status' => array(
      'value' => TRUE,
38
      'table' => 'users_field_data',
39
      'field' => 'status',
40
      'plugin_id' => 'boolean',
41 42
      'entity_type' => 'user',
      'entity_field' => 'status',
43 44 45
    )
  );

46
  /**
47
   * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayOptions().
48
   */
49 50
  protected function defaultDisplayOptions() {
    $display_options = parent::defaultDisplayOptions();
merlinofchaos's avatar
merlinofchaos committed
51 52 53

    // Add permission-based access control.
    $display_options['access']['type'] = 'perm';
54
    $display_options['access']['options']['perm'] = 'access user profiles';
merlinofchaos's avatar
merlinofchaos committed
55 56 57 58 59 60

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

    /* Field: User: Name */
    $display_options['fields']['name']['id'] = 'name';
61
    $display_options['fields']['name']['table'] = 'users_field_data';
merlinofchaos's avatar
merlinofchaos committed
62
    $display_options['fields']['name']['field'] = 'name';
63 64
    $display_options['fields']['name']['entity_type'] = 'user';
    $display_options['fields']['name']['entity_field'] = 'name';
merlinofchaos's avatar
merlinofchaos committed
65 66 67 68 69 70 71 72 73 74 75
    $display_options['fields']['name']['label'] = '';
    $display_options['fields']['name']['alter']['alter_text'] = 0;
    $display_options['fields']['name']['alter']['make_link'] = 0;
    $display_options['fields']['name']['alter']['absolute'] = 0;
    $display_options['fields']['name']['alter']['trim'] = 0;
    $display_options['fields']['name']['alter']['word_boundary'] = 0;
    $display_options['fields']['name']['alter']['ellipsis'] = 0;
    $display_options['fields']['name']['alter']['strip_tags'] = 0;
    $display_options['fields']['name']['alter']['html'] = 0;
    $display_options['fields']['name']['hide_empty'] = 0;
    $display_options['fields']['name']['empty_zero'] = 0;
76
    $display_options['fields']['name']['plugin_id'] = 'field';
merlinofchaos's avatar
merlinofchaos committed
77 78 79

    return $display_options;
  }
80

merlinofchaos's avatar
merlinofchaos committed
81
}