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

ISAICP-9055: Re-import spdx-licenses.

parent 0d4d94d4
No related branches found
No related tags found
1 merge request!207Release 2.1.1
<?php
/**
* @file
* Install, update, install functionality for Joinup OSS Catalogue module.
*/
declare(strict_types=1);
use Drupal\Component\Serialization\Json;
use Drupal\Core\Batch\BatchBuilder;
use Drupal\eu_oss_catalogue\EuOssCatalogueInstallHelper;
/**
* Re-import spdx-licenses.
*/
function joinup_oss_catalogue_update_200101(): void {
$terms = [];
$licencesJsonFile = DRUPAL_ROOT . "/../vendor/composer/spdx-licenses/res/spdx-licenses.json";
$licences = Json::decode(file_get_contents($licencesJsonFile));
foreach ($licences as $name => $licence) {
$terms[] = ['vid' => 'oss_licence', 'name' => $name];
}
$pathResolver = \Drupal::getContainer()->get('extension.path.resolver');
$batchBuilder = (new BatchBuilder())
->setFile($pathResolver->getPath('module', 'joinup_oss_catalogue') . '/joinup_oss_catalogue.install')
->setProgressive(FALSE);
foreach (array_chunk($terms, 50) as $chunk) {
$batchBuilder->addOperation(EuOssCatalogueInstallHelper::class . '::createTerms', [$chunk]);
}
batch_set($batchBuilder->toArray());
}
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