Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / media_entity / src / Plugin / views / wizard / Media.php
1 <?php
2
3 namespace Drupal\media_entity\Plugin\views\wizard;
4
5 use Drupal\views\Plugin\views\wizard\WizardPluginBase;
6
7 /**
8  * Tests creating media views with the wizard.
9  *
10  * @ViewsWizard(
11  *   id = "media",
12  *   base_table = "media_field_data",
13  *   title = @Translation("Media")
14  * )
15  */
16 class Media extends WizardPluginBase {
17
18   /**
19    * Set the created column.
20    */
21   protected $createdColumn = 'media_field_data-created';
22
23   /**
24    * Set default values for the filters.
25    */
26   protected $filters = [
27     'status' => [
28       'value' => TRUE,
29       'table' => 'media_field_data',
30       'field' => 'status',
31       'plugin_id' => 'boolean',
32       'entity_type' => 'media',
33       'entity_field' => 'status',
34     ],
35   ];
36
37   /**
38    * {@inheritdoc}
39    */
40   public function getAvailableSorts() {
41     return [
42       'media_field_data-name:DESC' => $this->t('Media name'),
43     ];
44   }
45
46   /**
47    * {@inheritdoc}
48    */
49   protected function defaultDisplayOptions() {
50     $display_options = parent::defaultDisplayOptions();
51
52     // Add permission-based access control.
53     $display_options['access']['type'] = 'perm';
54     $display_options['access']['options']['perm'] = 'access content';
55
56     // Remove the default fields, since we are customizing them here.
57     unset($display_options['fields']);
58
59     // Add the name field, so that the display has content if the user switches
60     // to a row style that uses fields.
61     /* Field: Media: Name */
62     $display_options['fields']['name']['id'] = 'name';
63     $display_options['fields']['name']['table'] = 'media_field_data';
64     $display_options['fields']['name']['field'] = 'name';
65     $display_options['fields']['name']['entity_type'] = 'media';
66     $display_options['fields']['name']['entity_field'] = 'media';
67     $display_options['fields']['name']['label'] = '';
68     $display_options['fields']['name']['alter']['alter_text'] = 0;
69     $display_options['fields']['name']['alter']['make_link'] = 0;
70     $display_options['fields']['name']['alter']['absolute'] = 0;
71     $display_options['fields']['name']['alter']['trim'] = 0;
72     $display_options['fields']['name']['alter']['word_boundary'] = 0;
73     $display_options['fields']['name']['alter']['ellipsis'] = 0;
74     $display_options['fields']['name']['alter']['strip_tags'] = 0;
75     $display_options['fields']['name']['alter']['html'] = 0;
76     $display_options['fields']['name']['hide_empty'] = 0;
77     $display_options['fields']['name']['empty_zero'] = 0;
78     $display_options['fields']['name']['settings']['link_to_entity'] = 1;
79     $display_options['fields']['name']['plugin_id'] = 'field';
80
81     return $display_options;
82   }
83
84 }