- Issue created by @eduardo morales alberti
- Merge request !15Issue #3509161 by eduardo morales alberti: Do not delete rows on translation add → (Merged) created by eduardo morales alberti
- 🇪🇸Spain eduardo morales alberti Spain, 🇪🇺
Full trace:
entity_mesh_entity_insert => entity_mesh_process_entity => $entity_mesh->processEntity($entity); => processTranslatableEntity => processEntityItem => $this->entityMeshRepository->saveSource($source); => if (!$this->deleteSource($source))
public function processEntity(EntityInterface $entity) { // Check if entity is translatable. if ($entity instanceof TranslatableInterface && $entity->isTranslatable()) { $this->processTranslatableEntity($entity); return; } $this->processEntityItem($entity); }
protected function processTranslatableEntity(EntityInterface $entity) { // @phpstan-ignore-next-line $translations = $entity->getTranslationLanguages(); $langcodes = array_keys($translations); foreach ($langcodes as $langcode) { // @phpstan-ignore-next-line $translation = $entity->getTranslation($langcode); if ($translation instanceof EntityInterface) { $this->processEntityItem($translation); } } }
protected function processEntityItem(EntityInterface $entity) { $source = $this->createSourceFromEntity($entity); if (!$source instanceof SourceInterface) { return; } $this->entityMeshRepository->saveSource($source); }
public function saveSource(SourceInterface $source): bool { // Remove source rows from the database to avoid duplicates. if (!$this->deleteSource($source)) { return FALSE; } if (!$this->insertSource($source)) { return FALSE; } return TRUE; }
public function deleteSource(SourceInterface $source): bool { try { $this->database ->delete(self::ENTITY_MESH_TABLE) ->condition('type', $source->getType()) ->condition('source_entity_type', $source->getSourceEntityType()) ->condition('source_entity_id', $source->getSourceEntityId()) ->execute(); } catch (\Exception $e) { $this->logger->error($e->getMessage()); return FALSE; } return TRUE; }
- 🇪🇸Spain lpeidro Madrid
It works as expected. Thank you Edu, I merged the branch.
-
lpeidro →
committed a4f17fb7 on 1.0.x authored by
eduardo morales alberti →
Issue #3509161 by eduardo morales alberti: Do not delete rows on...
-
lpeidro →
committed a4f17fb7 on 1.0.x authored by
eduardo morales alberti →
Automatically closed - issue fixed for 2 weeks with no activity.