diff --git a/config/install/entity_browser.browser.tide_media_browser_iframe.yml b/config/install/entity_browser.browser.tide_media_browser_iframe.yml index 700578524..3d0c10b9d 100644 --- a/config/install/entity_browser.browser.tide_media_browser_iframe.yml +++ b/config/install/entity_browser.browser.tide_media_browser_iframe.yml @@ -69,3 +69,14 @@ widgets: weight: -9 label: 'Add audio' id: entity_form + 514a147d-5e8c-4006-8bdd-6959b6239548: + id: entity_form + uuid: 514a147d-5e8c-4006-8bdd-6959b6239548 + label: 'Add secure file' + weight: 6 + settings: + submit_text: 'Save secure file' + entity_type: media + bundle: secure_file + form_mode: default + diff --git a/modules/tide_media/tide_media.install b/modules/tide_media/tide_media.install index dc5a250da..052421211 100644 --- a/modules/tide_media/tide_media.install +++ b/modules/tide_media/tide_media.install @@ -81,3 +81,36 @@ function tide_media_update_10005() { $config->set('track_enabled_target_entity_types', $result); $config->save(); } + +/** + * Adds secure file widget to entity browser. + */ +function tide_media_update_10006() { + if (\Drupal::moduleHandler()->moduleExists('tide_media_secure_files')) { + $uuid = \Drupal::service('uuid')->generate(); + $secure_file_widget = [ + 'id' => 'entity_form', + 'uuid' => $uuid, + 'label' => 'Add secure file', + 'weight' => 6, + 'settings' => [ + 'submit_text' => 'Save secure file', + 'entity_type' => 'media', + 'bundle' => 'secure_file', + 'form_mode' => 'default', + ], + ]; + + $config = \Drupal::configFactory()->getEditable('entity_browser.browser.tide_media_browser_iframe'); + $widgets = $config->get('widgets'); + if (!is_array($widgets)) { + $widgets = []; + } + if (!in_array($secure_file_widget, $widgets)) { + $widgets[$uuid] = $secure_file_widget; + $config->set('widgets', $widgets); + $config->save(); + } + } +} +