Users.php 2.26 KB
Newer Older
merlinofchaos's avatar
merlinofchaos committed
1 2
<?php

3
namespace Drupal\user\Plugin\views\wizard;
4

5
use Drupal\views\Plugin\views\wizard\WizardPluginBase;
6 7 8 9

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

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

22 23
  /**
   * Set the created column.
24 25
   *
   * @var string
26 27 28 29 30 31
   */
  protected $createdColumn = 'created';

  /**
   * Set default values for the filters.
   */
32 33
  protected $filters = [
    'status' => [
34
      'value' => TRUE,
35
      'table' => 'users_field_data',
36
      'field' => 'status',
37
      'plugin_id' => 'boolean',
38 39
      'entity_type' => 'user',
      'entity_field' => 'status',
40 41
    ]
  ];
42

43
  /**
44
   * {@inheritdoc}
45
   */
46 47
  protected function defaultDisplayOptions() {
    $display_options = parent::defaultDisplayOptions();
merlinofchaos's avatar
merlinofchaos committed
48 49 50

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

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

    /* Field: User: Name */
    $display_options['fields']['name']['id'] = 'name';
58
    $display_options['fields']['name']['table'] = 'users_field_data';
merlinofchaos's avatar
merlinofchaos committed
59
    $display_options['fields']['name']['field'] = 'name';
60 61
    $display_options['fields']['name']['entity_type'] = 'user';
    $display_options['fields']['name']['entity_field'] = 'name';
merlinofchaos's avatar
merlinofchaos committed
62 63 64 65 66 67 68 69 70 71 72
    $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;
73
    $display_options['fields']['name']['plugin_id'] = 'field';
merlinofchaos's avatar
merlinofchaos committed
74 75 76

    return $display_options;
  }
77

merlinofchaos's avatar
merlinofchaos committed
78
}