5 use Drupal\views\EntityViewsData;
8 * Provides the views data for the user entity type.
10 class UserViewsData extends EntityViewsData {
15 public function getViewsData() {
16 $data = parent::getViewsData();
18 $data['users_field_data']['table']['base']['help'] = $this->t('Users who have created accounts on your site.');
19 $data['users_field_data']['table']['base']['access query tag'] = 'user_access';
21 $data['users_field_data']['table']['wizard_id'] = 'user';
23 $data['users_field_data']['uid']['argument']['id'] = 'user_uid';
24 $data['users_field_data']['uid']['argument'] += [
25 'name table' => 'users_field_data',
26 'name field' => 'name',
27 'empty field name' => \Drupal::config('user.settings')->get('anonymous'),
29 $data['users_field_data']['uid']['filter']['id'] = 'user_name';
30 $data['users_field_data']['uid']['filter']['title'] = $this->t('Name (autocomplete)');
31 $data['users_field_data']['uid']['filter']['help'] = $this->t('The user or author name. Uses an autocomplete widget to find a user name, the actual filter uses the resulting user ID.');
32 $data['users_field_data']['uid']['relationship'] = [
33 'title' => $this->t('Content authored'),
34 'help' => $this->t('Relate content to the user who created it. This relationship will create one record for each content item created by the user.'),
36 'base' => 'node_field_data',
37 'base field' => 'uid',
39 'label' => $this->t('nodes'),
42 $data['users_field_data']['uid_raw'] = [
43 'help' => $this->t('The raw numeric user ID.'),
44 'real field' => 'uid',
46 'title' => $this->t('The user ID'),
51 $data['users_field_data']['uid_representative'] = [
53 'title' => $this->t('Representative node'),
54 'label' => $this->t('Representative node'),
55 'help' => $this->t('Obtains a single representative node for each user, according to a chosen sort criterion.'),
56 'id' => 'groupwise_max',
57 'relationship field' => 'uid',
58 'outer field' => 'users_field_data.uid',
59 'argument table' => 'users_field_data',
60 'argument field' => 'uid',
61 'base' => 'node_field_data',
63 'relationship' => 'node_field_data:uid'
67 $data['users']['uid_current'] = [
68 'real field' => 'uid',
69 'title' => $this->t('Current'),
70 'help' => $this->t('Filter the view to the currently logged in user.'),
72 'id' => 'user_current',
77 $data['users_field_data']['name']['help'] = $this->t('The user or author name.');
78 $data['users_field_data']['name']['field']['default_formatter'] = 'user_name';
79 $data['users_field_data']['name']['filter']['title'] = $this->t('Name (raw)');
80 $data['users_field_data']['name']['filter']['help'] = $this->t('The user or author name. This filter does not check if the user exists and allows partial matching. Does not use autocomplete.');
82 // Note that this field implements field level access control.
83 $data['users_field_data']['mail']['help'] = $this->t('Email address for a given user. This field is normally not shown to users, so be cautious when using it.');
85 $data['users_field_data']['langcode']['help'] = $this->t('Original language of the user information');
86 $data['users_field_data']['langcode']['help'] = $this->t('Language of the translation of user information');
88 $data['users_field_data']['preferred_langcode']['title'] = $this->t('Preferred language');
89 $data['users_field_data']['preferred_langcode']['help'] = $this->t('Preferred language of the user');
90 $data['users_field_data']['preferred_admin_langcode']['title'] = $this->t('Preferred admin language');
91 $data['users_field_data']['preferred_admin_langcode']['help'] = $this->t('Preferred administrative language of the user');
93 $data['users_field_data']['created_fulldate'] = [
94 'title' => $this->t('Created date'),
95 'help' => $this->t('Date in the form of CCYYMMDD.'),
98 'id' => 'date_fulldate',
102 $data['users_field_data']['created_year_month'] = [
103 'title' => $this->t('Created year + month'),
104 'help' => $this->t('Date in the form of YYYYMM.'),
106 'field' => 'created',
107 'id' => 'date_year_month',
111 $data['users_field_data']['created_year'] = [
112 'title' => $this->t('Created year'),
113 'help' => $this->t('Date in the form of YYYY.'),
115 'field' => 'created',
120 $data['users_field_data']['created_month'] = [
121 'title' => $this->t('Created month'),
122 'help' => $this->t('Date in the form of MM (01 - 12).'),
124 'field' => 'created',
125 'id' => 'date_month',
129 $data['users_field_data']['created_day'] = [
130 'title' => $this->t('Created day'),
131 'help' => $this->t('Date in the form of DD (01 - 31).'),
133 'field' => 'created',
138 $data['users_field_data']['created_week'] = [
139 'title' => $this->t('Created week'),
140 'help' => $this->t('Date in the form of WW (01 - 53).'),
142 'field' => 'created',
147 $data['users_field_data']['status']['filter']['label'] = $this->t('Active');
148 $data['users_field_data']['status']['filter']['type'] = 'yes-no';
150 $data['users_field_data']['changed']['title'] = $this->t('Updated date');
152 $data['users_field_data']['changed_fulldate'] = [
153 'title' => $this->t('Updated date'),
154 'help' => $this->t('Date in the form of CCYYMMDD.'),
156 'field' => 'changed',
157 'id' => 'date_fulldate',
161 $data['users_field_data']['changed_year_month'] = [
162 'title' => $this->t('Updated year + month'),
163 'help' => $this->t('Date in the form of YYYYMM.'),
165 'field' => 'changed',
166 'id' => 'date_year_month',
170 $data['users_field_data']['changed_year'] = [
171 'title' => $this->t('Updated year'),
172 'help' => $this->t('Date in the form of YYYY.'),
174 'field' => 'changed',
179 $data['users_field_data']['changed_month'] = [
180 'title' => $this->t('Updated month'),
181 'help' => $this->t('Date in the form of MM (01 - 12).'),
183 'field' => 'changed',
184 'id' => 'date_month',
188 $data['users_field_data']['changed_day'] = [
189 'title' => $this->t('Updated day'),
190 'help' => $this->t('Date in the form of DD (01 - 31).'),
192 'field' => 'changed',
197 $data['users_field_data']['changed_week'] = [
198 'title' => $this->t('Updated week'),
199 'help' => $this->t('Date in the form of WW (01 - 53).'),
201 'field' => 'changed',
206 $data['users']['data'] = [
207 'title' => $this->t('Data'),
208 'help' => $this->t('Provides access to the user data service.'),
209 'real field' => 'uid',
215 $data['users']['user_bulk_form'] = [
216 'title' => $this->t('Bulk update'),
217 'help' => $this->t('Add a form element that lets you run operations on multiple users.'),
219 'id' => 'user_bulk_form',
223 $data['user__roles']['table']['group'] = $this->t('User');
225 $data['user__roles']['table']['join'] = [
226 'users_field_data' => [
227 'left_field' => 'uid',
228 'field' => 'entity_id',
232 $data['user__roles']['roles_target_id'] = [
233 'title' => $this->t('Roles'),
234 'help' => $this->t('Roles that a user belongs to.'),
236 'id' => 'user_roles',
237 'no group by' => TRUE,
240 'id' => 'user_roles',
241 'allow empty' => TRUE,
244 'id' => 'user__roles_rid',
245 'name table' => 'role',
246 'name field' => 'name',
247 'empty field name' => $this->t('No role'),
248 'zero is null' => TRUE,
253 $data['user__roles']['permission'] = [
254 'title' => $this->t('Permission'),
255 'help' => $this->t('The user permissions.'),
257 'id' => 'user_permissions',
258 'no group by' => TRUE,
261 'id' => 'user_permissions',
262 'real field' => 'roles_target_id',