Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
acquia_dam-3499668
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
acquia_dam-3499668
Commits
967b186a
Commit
967b186a
authored
2 months ago
by
Pravin Gaikwad
Committed by
Jakob P
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Resolve
#3494927
"Acquia dam configs"
parent
3094d5c8
Branches
1.1.x
Branches containing commit
Tags
1.1.0-rc3
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
acquia_dam.install
+106
-2
106 additions, 2 deletions
acquia_dam.install
with
106 additions
and
2 deletions
acquia_dam.install
+
106
−
2
View file @
967b186a
...
...
@@ -579,8 +579,112 @@ function acquia_dam_update_9010() {
}
/**
*
Inform Drupal about new configuration during 1.0.x -> 1.1.x upgrade proces
s.
*
Add Audio and Generic media type
s.
*/
function
acquia_dam_update_9012
()
{
\Drupal
::
service
(
'config.installer'
)
->
installDefaultConfig
(
'module'
,
'acquia_dam'
);
$source
=
new
FileStorage
(
__DIR__
.
'/config/install'
);
// Update Existing views.
$update_views
=
[
'acquia_dam_asset_library'
,
'dam_content_overview'
,
'acquia_dam_links'
,
];
// Update existing configurations.
$entity_storage
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
'view'
);
$configs_to_update
=
$entity_storage
->
loadMultiple
(
$update_views
);
foreach
(
$configs_to_update
as
$config
)
{
$entity
=
$entity_storage
->
updateFromStorageRecord
(
$config
,
$source
->
read
(
'views.view.'
.
$config
->
id
()));
$entity
->
save
();
}
$config_to_add
=
[
'media_type'
=>
[
'media.type.acquia_dam_audio_asset'
,
'media.type.acquia_dam_generic_asset'
,
],
'entity_view_display'
=>
[
'core.entity_view_display.media.acquia_dam_audio_asset.default'
,
'core.entity_view_display.media.acquia_dam_audio_asset.media_library'
,
'core.entity_view_display.media.acquia_dam_generic_asset.default'
,
'core.entity_view_display.media.acquia_dam_generic_asset.media_library'
,
],
];
foreach
(
$config_to_add
as
$config_type
=>
$configs
)
{
$entity_storage
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
$config_type
);
// Add new configurations.
foreach
(
$configs
as
$config
)
{
$entity
=
$entity_storage
->
createFromStorageRecord
(
$source
->
read
(
$config
));
$entity
->
save
();
}
}
// Create the Check for asset update action.
// Define the action.
$action
=
[
'id'
=>
'asset_update_check_action'
,
'label'
=>
'Check for asset update'
,
'type'
=>
'system'
,
'plugin'
=>
'asset_update_check_action'
,
'config'
=>
[],
];
// Check if the action already exists.
if
(
!
\Drupal\system\Entity\Action
::
load
(
$action
[
'id'
]))
{
// Create the action.
$action_entity
=
\Drupal\system\Entity\Action
::
create
(
$action
);
$action_entity
->
save
();
}
}
/**
* DB update hook #9013.
*
* Issue #3477945: Update the existing media types with new configurations.
* Update the view with new configurations.
* Create the Check for asset update action.
*/
function
acquia_dam_update_9013
()
{
$config_map
=
[
'media_type'
=>
[
'acquia_dam_audio_asset'
,
'acquia_dam_generic_asset'
,
'acquia_dam_documents_asset'
,
'acquia_dam_image_asset'
,
'acquia_dam_pdf_asset'
,
'acquia_dam_spinset_asset'
,
'acquia_dam_video_asset'
,
],
'entity_view_display'
=>
[
'media.acquia_dam_documents_asset.default'
,
'media.acquia_dam_documents_asset.media_library'
,
'media.acquia_dam_image_asset.default'
,
'media.acquia_dam_image_asset.media_library'
,
'media.acquia_dam_pdf_asset.default'
,
'media.acquia_dam_pdf_asset.media_library'
,
'media.acquia_dam_spinset_asset.default'
,
'media.acquia_dam_spinset_asset.media_library'
,
'media.acquia_dam_video_asset.default'
,
'media.acquia_dam_video_asset.media_library'
,
'media.acquia_dam_audio_asset.default'
,
'media.acquia_dam_audio_asset.media_library'
,
'media.acquia_dam_generic_asset.default'
,
'media.acquia_dam_generic_asset.media_library'
,
],
];
$source
=
new
FileStorage
(
__DIR__
.
'/config/install'
);
foreach
(
$config_map
as
$config_type
=>
$configs
)
{
$entity_storage
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
$config_type
);
// Update existing configurations.
$configs_to_update
=
$entity_storage
->
loadMultiple
(
$configs
);
$prefix
=
$config_type
===
'media_type'
?
'media.type.'
:
'core.entity_view_display.'
;
foreach
(
$configs_to_update
as
$config
)
{
$entity
=
$entity_storage
->
updateFromStorageRecord
(
$config
,
$source
->
read
(
$prefix
.
$config
->
id
()));
$entity
->
save
();
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment