BlogViewsData.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Drupal\dr8_zth;
  3. use Drupal\views\EntityViewsData;
  4. /**
  5. * Provides the views data for the blog entity type.
  6. */
  7. class BlogViewsData extends EntityViewsData {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function getViewsData() {
  12. $data = parent::getViewsData();
  13. $data['blog_field_data']['table']['base']['help'] = $this->t('Blog items.');
  14. $data['blog_field_data']['table']['base']['access query tag'] = 'blog_access';
  15. $data['blog_field_data']['uid']['argument']['id'] = 'user_uid';
  16. $data['blog_field_data']['uid']['argument'] += [
  17. 'name table' => 'blog_field_data',
  18. 'name field' => 'name',
  19. 'empty field name' => \Drupal::config('user.settings')->get('anonymous'),
  20. ];
  21. $data['blog_field_data']['uid']['filter']['id'] = 'user_name';
  22. $data['blog_field_data']['uid']['filter']['title'] = $this->t('Author name (autocomplete)');
  23. $data['blog_field_data']['uid']['filter']['help'] = $this->t('The name of the blog author name. Uses an autocomplete widget to find a user name, the actual filter uses the resulting user ID.');
  24. $data['blog_field_data']['blog_id_raw'] = array(
  25. 'help' => $this->t('The raw numeric blog ID.'),
  26. 'real field' => 'blog_id',
  27. 'filter' => array(
  28. 'title' => $this->t('The blog ID'),
  29. 'id' => 'numeric',
  30. ),
  31. );
  32. $data['users']['uid_current'] = array(
  33. 'real field' => 'uid',
  34. 'title' => $this->t('Current'),
  35. 'help' => $this->t('Filter the view to the currently logged in user.'),
  36. 'filter' => array(
  37. 'id' => 'user_current',
  38. 'type' => 'yes-no',
  39. ),
  40. );
  41. $data['blog_field_data']['langcode']['help'] = $this->t('Original language of the blog entity');
  42. $data['blog_field_data']['langcode']['help'] = $this->t('Language of the translation of the blog entity');
  43. return $data;
  44. }
  45. }