Skip to content

Commit

Permalink
add secure file widget to entity browser
Browse files Browse the repository at this point in the history
  • Loading branch information
yeniatencio committed Dec 18, 2024
1 parent c4c0ddd commit eb6e9cb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

33 changes: 33 additions & 0 deletions modules/tide_media/tide_media.install
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

0 comments on commit eb6e9cb

Please sign in to comment.