-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try rolling post-update hook to update deps.
- Loading branch information
1 parent
4f002a8
commit 0f95fce
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Post-update hooks. | ||
*/ | ||
|
||
use Drupal\dgi_actions\Plugin\Action\IdentifierAction; | ||
|
||
/** | ||
* Resave `dgi_actions` entities to recalculate dependencies. | ||
*/ | ||
function dgi_actions_post_update_ddst_322_dependencies() : void { | ||
$entity_type_manager = \Drupal::entityTypeManager(); | ||
|
||
$to_resave = function () use ($entity_type_manager) { | ||
yield from $entity_type_manager->getStorage('dgiactions_dataprofile')->loadMultiple(); | ||
yield from $entity_type_manager->getStorage('dgiactions_servicedata')->loadMultiple(); | ||
yield from $entity_type_manager->getStorage('dgiactions_identifier')->loadMultiple(); | ||
|
||
foreach ($entity_type_manager->getStorage('action')->loadByProperties(['type' => 'entity']) as $id => $action) { | ||
if ($action instanceof IdentifierAction) { | ||
yield $id => $action; | ||
} | ||
} | ||
|
||
/** | ||
* @var string $id | ||
* @var \Drupal\context\ContextInterface $context | ||
*/ | ||
foreach ($entity_type_manager->getStorage('context')->loadMultiple() as $id => $context) { | ||
if ( | ||
$context->hasCondition('dgi_actions_entity_persistent_identifier_populated') || | ||
$context->hasReaction('dgi_actions_entity_mint_reaction') || | ||
$context->hasReaction('dgi_actions_entity_delete_reaction') | ||
) { | ||
yield $id => $context; | ||
} | ||
} | ||
}; | ||
|
||
/** @var \Drupal\Core\Entity\EntityInterface $config_entity */ | ||
foreach ($to_resave() as $config_entity) { | ||
$config_entity->save(); | ||
} | ||
|
||
} |