You are here

public function JsonapiHelper::clearImportedEntities in Entity Share 8.2

Allow to clear imported entities counter.

So the same entity can be reimported multiple times during the same PHP process.

Without argument, all imported entities counter are deleted.

If a langcode is passed, all imported entities counter in this langcode are deleted.

If an entity UUID is passed, the imported entity counter is deleted for all languages.

If a langcode and an entity UUID are passed, the imported entity counter is deleted for the specified language.

Parameters

string $langcode: The langcode for which to clear the imported entities.

string $entity_uuid: The UUID of the entity to clear the langcode for.

Overrides JsonapiHelperInterface::clearImportedEntities

File

modules/entity_share_client/src/Service/JsonapiHelper.php, line 537

Class

JsonapiHelper
Class JsonapiHelper.

Namespace

Drupal\entity_share_client\Service

Code

public function clearImportedEntities($langcode = '', $entity_uuid = '') {
  if (empty($langcode) && empty($entity_uuid)) {
    $this->importedEntities = [];
  }
  elseif (!empty($langcode) && empty(!$entity_uuid) && isset($this->importedEntities[$langcode][$entity_uuid])) {
    unset($this->importedEntities[$langcode][$entity_uuid]);
  }
  elseif (!empty($langcode) && isset($this->importedEntities[$langcode])) {
    $this->importedEntities[$langcode] = [];
  }
  elseif (!empty($entity_uuid)) {
    foreach ($this->importedEntities as $imported_entities_langcode => $imported_entities_uuids) {
      if (isset($this->importedEntities[$imported_entities_langcode][$entity_uuid])) {
        unset($this->importedEntities[$imported_entities_langcode][$entity_uuid]);
      }
    }
  }
}