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

Commit

Permalink
Updated hook update
Browse files Browse the repository at this point in the history
  • Loading branch information
yeniatencio committed Sep 11, 2024
1 parent 39b0dcf commit 68876e1
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tide_media.install
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

use Drupal\field\Entity\FieldConfig;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Config\FileStorage;
use Drupal\tide_media\TideOperation;

/**
Expand Down Expand Up @@ -70,25 +72,30 @@ function tide_media_update_10004() {
$module_installer = \Drupal::service('module_installer');
$module_installer->install(['pfdp']);

// Creates new secure file user role.
$secure_file_role = 'user.role.secure_file_user';
$config_path = drupal_get_path('module', 'tide_core') . '/config/install';
$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');
$config_storage->write($secure_file_role, $source->read($secure_file_role));

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

// Add field.
$configs = [
'pfdp.pfdp_directory.secure' => 'field_config',
'media.type.secure_file' => 'field_config',
$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 ($configs as $config => $type) {
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);
Expand Down

0 comments on commit 68876e1

Please sign in to comment.