Skip to content

Instantly share code, notes, and snippets.

@kerasai
Created July 11, 2025 02:25
Show Gist options
  • Save kerasai/3cf2861fa4498caa9535af81c905b96e to your computer and use it in GitHub Desktop.
Save kerasai/3cf2861fa4498caa9535af81c905b96e to your computer and use it in GitHub Desktop.
Patch to allow default content to be reran and avoid error by skipping previously created content.
diff --git a/src/Importer.php b/src/Importer.php
index 423c8ff..cbc19e1 100644
--- a/src/Importer.php
+++ b/src/Importer.php
@@ -288,6 +288,11 @@ class Importer implements ImporterInterface {
$entity = $this->contentEntityNormalizer->denormalize(Yaml::decode($contents));
}
+ // Skip if exists.
+ if (\Drupal::service('entity.repository')->loadEntityByUuid($entity->getEntityTypeId(), $entity->uuid())) {
+ continue;
+ }
+
$entity->enforceIsNew(TRUE);
// Ensure that the entity is not owned by the anonymous user.
if ($entity instanceof EntityOwnerInterface && empty($entity->getOwnerId())) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment