Thanks @VasyOK for the tip, working perfectly.
Ok, so if anyone search a quick answer to this problem, I solved it like this.
Because I have a IDXFetcherResult extending FetcherResult, I can override the "cleanUp" method.
I have a IDXFileFetcher too, with fetch() method. I used this fetch method to pass to the IDXFetcherResult constructor the $feed and the "update_non_existent" state :
return new IDXFetcherResult(
$path,
$feed,
$this->feedType->getProcessor()->getConfiguration('update_non_existent')
);
Now, on my IDXFetcherResult, I implemented the cleanUp method like this :
public function cleanUp() {
// Get file content as string.
$content = file_get_contents($this->filePath);
// Check if file is empty.
// If it's the case, and only if it's the case, we must
// clean ALL previously imported items.
// We must add this process because the standard feeds system
// doesn't clean items when it encount an empty list.
if (empty(trim($content))) {
$storage = \Drupal::entityTypeManager()
->getStorage('my-entity-type');
// Get list of entities to clean.
$ids = $storage
->getQuery()
->accessCheck(FALSE)
->condition('feeds_item.target_id', $this->feed->id())
->condition('feeds_item.hash', $this->updateNonExistent, '<>')
->execute();
if (!empty($ids)) {
/** @var \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $dispatcher */
$dispatcher = \Drupal::service('event_dispatcher');
$entities = $storage->loadMultiple($ids);
// Iterate over each entity and mimic the clean process.
// We use the same process to avoid potential errors.
foreach ($entities as $entity) {
$dispatcher->dispatch(new InitEvent($this->feed, 'clean'), FeedsEvents::INIT_IMPORT);
$dispatcher->dispatch(new CleanEvent($this->feed, $entity), FeedsEvents::CLEAN);
}
}
}
}
Hope this can help.
titouille β created an issue.
Hi Jaypan !
This is unfortunately not the case. If you don't declare "uuid" => "uuid" in primary keys of your custom entity, the uuid column will be not added to the database "base_table" of your entity.
And if you declare it after deployment, Drupal add this column into the "data_table" instead of "base_table" if your entity declare data_table, and this break the use of uuid...
I finally found exactly what I need with this post that explain how to add uuid property / column to a deployed entity : https://drupal.stackexchange.com/questions/302719/how-can-i-add-a-proper...
Best regards.
same problem as megadesk3000 on #5. After upgrading to 1.3.0-beta1, I can't add new modules if symfony_mailer is enabled, it cause a Circular reference detected error :
PHP Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "entity_type.manager", path: "user_last_access_subscriber -> entity_type.manager -> string_translation -> string_translator.locale.lookup -> config.factory -> plugin.manager.email_builder".
downgrading to 1.2.1 resolve the problem.
titouille β created an issue.