Mercurial > hg > cmmr2012-drupal-site
diff 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 |
line wrap: on
line diff
--- a/core/modules/media_library/media_library.install Thu Feb 28 13:11:55 2019 +0000 +++ b/core/modules/media_library/media_library.install Thu May 09 15:34:47 2019 +0100 @@ -5,6 +5,8 @@ * Install, update and uninstall functions for the media_library module. */ +use Drupal\image\Entity\ImageStyle; +use Drupal\media\Entity\MediaType; use Drupal\views\Entity\View; /** @@ -21,6 +23,12 @@ $view->trustData()->save(); } } + if (!\Drupal::isConfigSyncing()) { + foreach (MediaType::loadMultiple() as $type) { + _media_library_configure_form_display($type); + _media_library_configure_view_display($type); + } + } } /** @@ -47,3 +55,180 @@ } } } + +/** + * Create the 'media_library' image style. + */ +function media_library_update_8701() { + $image_style = ImageStyle::create([ + 'name' => 'media_library', + 'label' => 'Media Library (220x220)', + ]); + // Add a scale effect. + $image_style->addImageEffect([ + 'id' => 'image_scale', + 'weight' => 0, + 'data' => [ + 'width' => 220, + 'height' => 220, + 'upscale' => FALSE, + ], + ]); + $image_style->save(); +} + +/** + * Updates the media library view widget display (contextual) filters. + */ +function media_library_update_8702() { + $view = \Drupal::configFactory()->getEditable('views.view.media_library'); + if ($view && $view->get('display.widget')) { + $view->set('display.widget.display_options.defaults.filters', FALSE); + $view->set('display.widget.display_options.defaults.filter_groups', FALSE); + $view->set('display.widget.display_options.defaults.arguments', FALSE); + $view->set('display.widget.display_options.filters', [ + 'status' => [ + 'id' => 'status', + 'table' => 'media_field_data', + 'field' => 'status', + 'relationship' => 'none', + 'group_type' => 'group', + 'admin_label' => '', + 'operator' => '=', + 'value' => '1', + 'group' => 1, + 'exposed' => FALSE, + 'expose' => [ + 'operator_id' => '', + 'label' => '', + 'description' => '', + 'use_operator' => FALSE, + 'operator' => '', + 'identifier' => '', + 'required' => FALSE, + 'remember' => FALSE, + 'multiple' => FALSE, + 'remember_roles' => [ + 'authenticated' => 'authenticated', + ], + ], + 'is_grouped' => FALSE, + 'group_info' => [ + 'label' => '', + 'description' => '', + 'identifier' => '', + 'optional' => TRUE, + 'widget' => 'select', + 'multiple' => FALSE, + 'remember' => FALSE, + 'default_group' => 'All', + 'default_group_multiple' => [], + 'group_items' => [], + ], + 'entity_type' => 'media', + 'entity_field' => 'status', + 'plugin_id' => 'boolean', + ], + 'name' => [ + 'id' => 'name', + 'table' => 'media_field_data', + 'field' => 'name', + 'relationship' => 'none', + 'group_type' => 'group', + 'admin_label' => '', + 'operator' => 'contains', + 'value' => '', + 'group' => 1, + 'exposed' => TRUE, + 'expose' => [ + 'operator_id' => 'name_op', + 'label' => 'Name', + 'description' => '', + 'use_operator' => FALSE, + 'operator' => 'name_op', + 'identifier' => 'name', + 'required' => FALSE, + 'remember' => FALSE, + 'multiple' => FALSE, + 'remember_roles' => [ + 'authenticated' => 'authenticated', + 'anonymous' => '0', + 'administrator' => '0', + ], + ], + 'is_grouped' => FALSE, + 'group_info' => [ + 'label' => '', + 'description' => '', + 'identifier' => '', + 'optional' => TRUE, + 'widget' => 'select', + 'multiple' => FALSE, + 'remember' => FALSE, + 'default_group' => 'All', + 'default_group_multiple' => [], + 'group_items' => [], + ], + 'entity_type' => 'media', + 'entity_field' => 'name', + 'plugin_id' => 'string', + ], + ]); + $view->set('display.widget.display_options.filter_groups', [ + 'operator' => 'AND', + 'groups' => [ + 1 => 'AND', + ], + ]); + $view->set('display.widget.display_options.arguments', [ + 'bundle' => [ + 'id' => 'bundle', + 'table' => 'media_field_data', + 'field' => 'bundle', + 'relationship' => 'none', + 'group_type' => 'group', + 'admin_label' => '', + 'default_action' => 'ignore', + 'exception' => [ + 'value' => 'all', + 'title_enable' => FALSE, + 'title' => 'All', + ], + 'title_enable' => FALSE, + 'title' => '', + 'default_argument_type' => 'fixed', + 'default_argument_options' => [ + 'argument' => '', + ], + 'default_argument_skip_url' => FALSE, + 'summary_options' => [ + 'base_path' => '', + 'count' => TRUE, + 'items_per_page' => 25, + 'override' => FALSE, + ], + 'summary' => [ + 'sort_order' => 'asc', + 'number_of_records' => 0, + 'format' => 'default_summary', + ], + 'specify_validation' => FALSE, + 'validate' => [ + 'type' => 'none', + 'fail' => 'not found', + ], + 'validate_options' => [], + 'glossary' => FALSE, + 'limit' => 0, + 'case' => 'none', + 'path_case' => 'none', + 'transform_dash' => FALSE, + 'break_phrase' => FALSE, + 'entity_type' => 'media', + 'entity_field' => 'bundle', + 'plugin_id' => 'string', + ], + ]); + $view->save(); + } +}