Skip to content
Snippets Groups Projects
Commit 0d4d94d4 authored by Adrian Lorenc's avatar Adrian Lorenc
Browse files

ISAICP-9055: Limit duplications.

parent 22dcfd0c
No related branches found
No related tags found
1 merge request!207Release 2.1.1
......@@ -21,7 +21,14 @@ class EuOssCatalogueInstallHelper {
public static function createTerms(array $items, array &$context): void {
$termStorage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
foreach ($items as $item) {
$termStorage->create($item)->save();
$existingTerms = $termStorage->loadByProperties([
'name' => $item['name'],
'vid' => $item['vid'],
]);
if (empty($existingTerms)) {
$termStorage->create($item)->save();
}
}
$context['message'] = t('Imported @count terms in controlled vocabularies', [
'@count' => count($items),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment