123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <?php
- /**
- * @file
- * Install, update and uninstall functions for the media_library module.
- */
- use Drupal\media\Entity\MediaType;
- /**
- * Implements hook_install().
- */
- function media_library_install($is_syncing) {
- if (!$is_syncing) {
- foreach (MediaType::loadMultiple() as $type) {
- _media_library_configure_form_display($type);
- _media_library_configure_view_display($type);
- }
- }
- }
- /**
- * Create the 'media_library' image style.
- */
- function media_library_update_8701() {
- // This update function has been moved to
- // media_library_post_update_add_media_library_image_style().
- }
- /**
- * 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(TRUE);
- }
- }
- /**
- * This update has been removed and will not run.
- */
- function media_library_update_8703() {
- // This update function previously added 'edit' and 'delete' buttons to media
- // items in the 'media' view. It has been converted to a post-update hook.
- // @see media_library_post_update_add_buttons_to_page_view()
- }
- /**
- * Creates the media_library.settings config object.
- */
- function media_library_update_8704() {
- \Drupal::configFactory()
- ->getEditable('media_library.settings')
- // Enable the advanced UI by default, to preserve existing behavior.
- ->set('advanced_ui', TRUE)
- ->save();
- }
|