comparison core/modules/media_library/media_library.install @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
3 /** 3 /**
4 * @file 4 * @file
5 * Install, update and uninstall functions for the media_library module. 5 * Install, update and uninstall functions for the media_library module.
6 */ 6 */
7 7
8 use Drupal\image\Entity\ImageStyle;
9 use Drupal\media\Entity\MediaType;
8 use Drupal\views\Entity\View; 10 use Drupal\views\Entity\View;
9 11
10 /** 12 /**
11 * Implements hook_install(). 13 * Implements hook_install().
12 */ 14 */
17 $display = &$view->getDisplay('media_page_list'); 19 $display = &$view->getDisplay('media_page_list');
18 if (!empty($display)) { 20 if (!empty($display)) {
19 $display['display_options']['path'] = 'admin/content/media-table'; 21 $display['display_options']['path'] = 'admin/content/media-table';
20 unset($display['display_options']['menu']); 22 unset($display['display_options']['menu']);
21 $view->trustData()->save(); 23 $view->trustData()->save();
24 }
25 }
26 if (!\Drupal::isConfigSyncing()) {
27 foreach (MediaType::loadMultiple() as $type) {
28 _media_library_configure_form_display($type);
29 _media_library_configure_view_display($type);
22 } 30 }
23 } 31 }
24 } 32 }
25 33
26 /** 34 /**
45 ]; 53 ];
46 $view->trustData()->save(); 54 $view->trustData()->save();
47 } 55 }
48 } 56 }
49 } 57 }
58
59 /**
60 * Create the 'media_library' image style.
61 */
62 function media_library_update_8701() {
63 $image_style = ImageStyle::create([
64 'name' => 'media_library',
65 'label' => 'Media Library (220x220)',
66 ]);
67 // Add a scale effect.
68 $image_style->addImageEffect([
69 'id' => 'image_scale',
70 'weight' => 0,
71 'data' => [
72 'width' => 220,
73 'height' => 220,
74 'upscale' => FALSE,
75 ],
76 ]);
77 $image_style->save();
78 }
79
80 /**
81 * Updates the media library view widget display (contextual) filters.
82 */
83 function media_library_update_8702() {
84 $view = \Drupal::configFactory()->getEditable('views.view.media_library');
85 if ($view && $view->get('display.widget')) {
86 $view->set('display.widget.display_options.defaults.filters', FALSE);
87 $view->set('display.widget.display_options.defaults.filter_groups', FALSE);
88 $view->set('display.widget.display_options.defaults.arguments', FALSE);
89 $view->set('display.widget.display_options.filters', [
90 'status' => [
91 'id' => 'status',
92 'table' => 'media_field_data',
93 'field' => 'status',
94 'relationship' => 'none',
95 'group_type' => 'group',
96 'admin_label' => '',
97 'operator' => '=',
98 'value' => '1',
99 'group' => 1,
100 'exposed' => FALSE,
101 'expose' => [
102 'operator_id' => '',
103 'label' => '',
104 'description' => '',
105 'use_operator' => FALSE,
106 'operator' => '',
107 'identifier' => '',
108 'required' => FALSE,
109 'remember' => FALSE,
110 'multiple' => FALSE,
111 'remember_roles' => [
112 'authenticated' => 'authenticated',
113 ],
114 ],
115 'is_grouped' => FALSE,
116 'group_info' => [
117 'label' => '',
118 'description' => '',
119 'identifier' => '',
120 'optional' => TRUE,
121 'widget' => 'select',
122 'multiple' => FALSE,
123 'remember' => FALSE,
124 'default_group' => 'All',
125 'default_group_multiple' => [],
126 'group_items' => [],
127 ],
128 'entity_type' => 'media',
129 'entity_field' => 'status',
130 'plugin_id' => 'boolean',
131 ],
132 'name' => [
133 'id' => 'name',
134 'table' => 'media_field_data',
135 'field' => 'name',
136 'relationship' => 'none',
137 'group_type' => 'group',
138 'admin_label' => '',
139 'operator' => 'contains',
140 'value' => '',
141 'group' => 1,
142 'exposed' => TRUE,
143 'expose' => [
144 'operator_id' => 'name_op',
145 'label' => 'Name',
146 'description' => '',
147 'use_operator' => FALSE,
148 'operator' => 'name_op',
149 'identifier' => 'name',
150 'required' => FALSE,
151 'remember' => FALSE,
152 'multiple' => FALSE,
153 'remember_roles' => [
154 'authenticated' => 'authenticated',
155 'anonymous' => '0',
156 'administrator' => '0',
157 ],
158 ],
159 'is_grouped' => FALSE,
160 'group_info' => [
161 'label' => '',
162 'description' => '',
163 'identifier' => '',
164 'optional' => TRUE,
165 'widget' => 'select',
166 'multiple' => FALSE,
167 'remember' => FALSE,
168 'default_group' => 'All',
169 'default_group_multiple' => [],
170 'group_items' => [],
171 ],
172 'entity_type' => 'media',
173 'entity_field' => 'name',
174 'plugin_id' => 'string',
175 ],
176 ]);
177 $view->set('display.widget.display_options.filter_groups', [
178 'operator' => 'AND',
179 'groups' => [
180 1 => 'AND',
181 ],
182 ]);
183 $view->set('display.widget.display_options.arguments', [
184 'bundle' => [
185 'id' => 'bundle',
186 'table' => 'media_field_data',
187 'field' => 'bundle',
188 'relationship' => 'none',
189 'group_type' => 'group',
190 'admin_label' => '',
191 'default_action' => 'ignore',
192 'exception' => [
193 'value' => 'all',
194 'title_enable' => FALSE,
195 'title' => 'All',
196 ],
197 'title_enable' => FALSE,
198 'title' => '',
199 'default_argument_type' => 'fixed',
200 'default_argument_options' => [
201 'argument' => '',
202 ],
203 'default_argument_skip_url' => FALSE,
204 'summary_options' => [
205 'base_path' => '',
206 'count' => TRUE,
207 'items_per_page' => 25,
208 'override' => FALSE,
209 ],
210 'summary' => [
211 'sort_order' => 'asc',
212 'number_of_records' => 0,
213 'format' => 'default_summary',
214 ],
215 'specify_validation' => FALSE,
216 'validate' => [
217 'type' => 'none',
218 'fail' => 'not found',
219 ],
220 'validate_options' => [],
221 'glossary' => FALSE,
222 'limit' => 0,
223 'case' => 'none',
224 'path_case' => 'none',
225 'transform_dash' => FALSE,
226 'break_phrase' => FALSE,
227 'entity_type' => 'media',
228 'entity_field' => 'bundle',
229 'plugin_id' => 'string',
230 ],
231 ]);
232 $view->save();
233 }
234 }