Skip to content

Commit

Permalink
Clear the correct cache and fix coder issues
Browse files Browse the repository at this point in the history
  • Loading branch information
whikloj committed Sep 14, 2022
1 parent b6da7a5 commit debab30
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Form/IslandoraSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,22 +357,23 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
}

/**
* Removes the Fedora Pseudo field from any entity bundles that have be unselected.
* Removes the Fedora URI field from entity bundles that have be unselected.
*
* @param array $current_config
* The current set of entity type & bundle to have the pseudo field, format {bundle}:{entity_type}
* The current set of entity types & bundles to have the pseudo field,
* format {bundle}:{entity_type}.
* @param array $new_config
* The new set of entity type & bundle to have the pseudo field, format {bundle}:{entity_type}
* The new set of entity types & bundles to have the pseudo field, format
* {bundle}:{entity_type}.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* @throws \Drupal\Core\Entity\EntityStorageException
*/
private function updateEntityViewConfiguration(array $current_config, array $new_config) {
$cache_tags = [];
$removed = array_diff($current_config, $new_config);
$added = array_diff($new_config, $current_config);
$entity_view_display = $this->entityTypeManager->getStorage('entity_view_display');
// types being removed
foreach ($removed as $bundle_type) {
[$bundle, $type_id] = explode(":", $bundle_type);
$results = $entity_view_display->getQuery()
Expand All @@ -384,10 +385,13 @@ private function updateEntityViewConfiguration(array $current_config, array $new
foreach ($entities as $entity) {
$entity->removeComponent(self::GEMINI_PSEUDO_FIELD);
$entity->save();
$cache_tags = array_merge($cache_tags, $entity->getCacheTags());
}
}
$entity_view_display->resetCache();
Cache::invalidateTags($cache_tags);
if (count($removed) > 0 || count($added) > 0) {
// If we added or cleared a type then clear the extra_fields cache.
// @see Drupal/Core/Entity/EntityFieldManager::getExtraFields
Cache::invalidateTags(["entity_field_info"]);
}
}

}

0 comments on commit debab30

Please sign in to comment.