Commit 54dfefef authored by Masami  Suzuki's avatar Masami Suzuki Committed by Yas Naoi
Browse files

Issue #3274216 by Masami, yas: Remove Cloud Project when K8s Cloud Service Provider is deleted

parent 4e71aa45
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -478,6 +478,17 @@ function cloud_mail($key, array &$message, array $params): void {
 * Implements hook_cloud_config_predelete().
 */
function cloud_cloud_config_predelete(CloudConfig $cloud_config): void {
  // Delete all cloud project entities.
  $storage = \Drupal::entityTypeManager()->getStorage('cloud_project');
  $entities = $storage->loadByProperties([
    'cloud_context' => $cloud_config->getCloudContext(),
    'type' => $cloud_config->bundle(),
  ]);

  if (!empty($entities)) {
    $storage->delete($entities);
  }

  // Delete cached operation data, if exists.
  $cache_service = \Drupal::service('cloud.cache');
  $cache_service->clearOperationAccessCache($cloud_config->getCloudContext());