Created
July 11, 2025 02:25
-
-
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.
This file contains hidden or 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
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