Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
Moved files to submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
yeniatencio committed Sep 19, 2024
1 parent e5d4874 commit 73512db
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 86 deletions.
5 changes: 5 additions & 0 deletions modules/tide_media_secure_files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# tide_media_secure_files
Allows author to create secure private files

## Purpose
- media
19 changes: 19 additions & 0 deletions modules/tide_media_secure_files/tide_media_secure_files.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Tide Media Secure Files'
description: 'Gives the author option to create secure files.'
type: module
package: Tide
core_version_requirement: ^9 || ^10
dependencies:
- dpc-sdp:tide_core
- dpc-sdp:tide_media
- pfdp:pfdp
config_devel:
install:
- core.entity_form_display.media.secure_file.default
- core.entity_view_display.media.secure_file.default
- field.field.media.secure_file.field_secure_file
- field.storage.media.field_secure_file
- media.type.secure_file
- pfdp.pfdp_directory.secure
- user.role.dtf_secure_file_user
optional: { }
98 changes: 98 additions & 0 deletions modules/tide_media_secure_files/tide_media_secure_files.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

/**
* @file
* Tide Media Secure Files.
*/

/**
* Implements hook_uninstall().
*/
function tide_media_secure_files_uninstall() {
}

/**
* Implements hook_install().
*/
function tide_media_secure_files_install() {
if (!\Drupal::moduleHandler()->moduleExists('pfdp')) {
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
$module_installer = \Drupal::service('module_installer');
$module_installer->install(['pfdp']);
}
}

/**
* Enable Private files download permission module.
*/
/* function tide_media_update_10004() {
if (!\Drupal::moduleHandler()->moduleExists('pfdp')) {
$module_installer = \Drupal::service('module_installer');
$module_installer->install(['pfdp']);

$configs = [
'pfdp.pfdp_directory.secure',
'media.type.secure_file',
'user.role.secure_file_user',
];

$config_path = \Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install';
$source = new FileStorage($config_path);
$config_storage = \Drupal::service('config.storage');

foreach ($configs as $config) {
$config_storage->write($config, $source->read($config));
}

// Add field.
$field_configs = [
'field.storage.media.field_secure_file' => 'field_storage_config',
'field.field.media.secure_file.field_secure_file' => 'field_config',
];
module_load_include('inc', 'tide_core', 'includes/helpers');
$config_location = [\Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install'];

// Check if field already exported to config/sync.
foreach ($field_configs as $config => $type) {
$config_read = _tide_read_config($config, $config_location, TRUE);
$storage = \Drupal::entityTypeManager()->getStorage($type);
$id = substr($config, strrpos($config, '.') + 1);
if ($storage->load($id) == NULL) {
$config_entity = $storage->createFromStorageRecord($config_read);
$config_entity->save();
}
}

$update_configs = [
'core.entity_form_display.media.secure_file.default' => 'entity_form_display',
'core.entity_view_display.media.secure_file.default' => 'entity_view_display',
];
$skipped_settings = [
'uuid',
'langcode',
'status',
'id',
'bundle',
];
foreach ($update_configs as $update_config => $type) {
$config_read = _tide_read_config($update_config, $config_location, FALSE);
$config = \Drupal::configFactory()->getEditable($update_config);
if (!$config) {
continue;
}
$data = $config->getRawData();
foreach ($config_read as $key => $item) {
if (in_array($key, $skipped_settings)) {
continue;
}
NestedArray::setValue($data, [
$key,
], NestedArray::getValue($config_read, [
$key,
]));
}
$config->setData($data)->save();
}
}
} */

12 changes: 1 addition & 11 deletions tide_media.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies:
- entity_browser:entity_browser_entity_form
- entity_usage:entity_usage
- focal_point:focal_point
- pfdp:pfdp
- svg_image:svg_image
- video_embed_field:video_embed_field
- video_embed_field:video_embed_media
Expand All @@ -31,7 +30,6 @@ config_devel:
- core.entity_form_display.media.embedded_video.default
- core.entity_form_display.media.file.default
- core.entity_form_display.media.image.default
- core.entity_form_display.media.secure_file.default
- core.entity_form_display.media.video.default
- core.entity_form_display.paragraph.call_to_action_image.default
- core.entity_view_display.media.audio.default
Expand All @@ -41,7 +39,7 @@ config_devel:
- core.entity_view_display.media.document.default
- core.entity_view_display.media.document.embedded
- core.entity_view_display.media.document.media_browser_preview
- core.entity_view_display.media.embedded_video.defailt
- core.entity_view_display.media.embedded_video.default
- core.entity_view_display.media.embedded_video.embedded
- core.entity_view_display.media.embedded_video.embedded_with_transcript
- core.entity_view_display.media.embedded_video.media_browser_preview
Expand All @@ -50,7 +48,6 @@ config_devel:
- core.entity_view_display.media.image.embedded
- core.entity_view_display.media.image.embedded_with_caption
- core.entity_view_display.media.image.media_browser_preview
- core.entity_view_display.media.secure_file.default
- core.entity_view_display.media.video.default
- core.entity_view_display.media.video.embedded
- core.entity_view_display.media.video.embedded_with_transcript
Expand Down Expand Up @@ -105,7 +102,6 @@ config_devel:
- field.field.media.image.field_media_department
- field.field.media.image.field_media_image
- field.field.media.image.field_media_topic
- field.field.media.secure_file.field_secure_file
- field.field.media.video.field_license_type
- field.field.media.video.field_media_link
- field.field.media.video.field_media_audience
Expand Down Expand Up @@ -136,7 +132,6 @@ config_devel:
- field.storage.media.field_media_image
- field.storage.media.field_media_length
- field.storage.media.field_media_link
- field.storage.media.field_secure_file
- field.storage.media.field_media_show_transcript
- field.storage.media.field_media_summary
- field.storage.media.field_media_topic
Expand All @@ -150,16 +145,11 @@ config_devel:
- media.type.embedded_video
- media.type.file
- media.type.image
- media.type.secure_file
- media.type.video
- paragraphs.paragraphs_type.call_to_action_image
- pfdp.pfdp_directory.secure
- taxonomy.vocabulary.license_type
- tide_media.settings
- views.view.tide_media_browser
- system.action.user_add_role_action.dtf_secure_file_user
- system.action.user_remove_role_action.dtf_secure_file_user
- user.role.dtf_secure_file_user
optional:
- jsonapi_extras.jsonapi_resource_config.paragraph--call_to_action_image
- jsonapi_extras.jsonapi_resource_config.paragraph--timeline
Expand Down
75 changes: 0 additions & 75 deletions tide_media.install
Original file line number Diff line number Diff line change
Expand Up @@ -62,78 +62,3 @@ function tide_media_update_10003() {
$config = $config_factory->getEditable('embed.button.tide_media');
$config->set('icon', [])->save();
}

/**
* Enable Private files download permission module.
*/
function tide_media_update_10004() {
if (!\Drupal::moduleHandler()->moduleExists('pfdp')) {
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
$module_installer = \Drupal::service('module_installer');
$module_installer->install(['pfdp']);

$configs = [
'pfdp.pfdp_directory.secure',
'media.type.secure_file',
'user.role.secure_file_user',
];

$config_path = \Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install';
$source = new FileStorage($config_path);
$config_storage = \Drupal::service('config.storage');

foreach ($configs as $config) {
$config_storage->write($config, $source->read($config));
}

// Add field.
$field_configs = [
'field.storage.media.field_secure_file' => 'field_storage_config',
'field.field.media.secure_file.field_secure_file' => 'field_config',
];
module_load_include('inc', 'tide_core', 'includes/helpers');
$config_location = [\Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install'];

// Check if field already exported to config/sync.
foreach ($field_configs as $config => $type) {
$config_read = _tide_read_config($config, $config_location, TRUE);
$storage = \Drupal::entityTypeManager()->getStorage($type);
$id = substr($config, strrpos($config, '.') + 1);
if ($storage->load($id) == NULL) {
$config_entity = $storage->createFromStorageRecord($config_read);
$config_entity->save();
}
}

$update_configs = [
'core.entity_form_display.media.secure_file.default' => 'entity_form_display',
'core.entity_view_display.media.secure_file.default' => 'entity_view_display',
];
$skipped_settings = [
'uuid',
'langcode',
'status',
'id',
'bundle',
];
foreach ($update_configs as $update_config => $type) {
$config_read = _tide_read_config($update_config, $config_location, FALSE);
$config = \Drupal::configFactory()->getEditable($update_config);
if (!$config) {
continue;
}
$data = $config->getRawData();
foreach ($config_read as $key => $item) {
if (in_array($key, $skipped_settings)) {
continue;
}
NestedArray::setValue($data, [
$key,
], NestedArray::getValue($config_read, [
$key,
]));
}
$config->setData($data)->save();
}
}
}

0 comments on commit 73512db

Please sign in to comment.