public static function TaxonomiesController::deleteDeletedTaxonomies in Structure Sync 8
Same name and namespace in other branches
- 2.x src/Controller/TaxonomiesController.php \Drupal\structure_sync\Controller\TaxonomiesController::deleteDeletedTaxonomies()
Function to delete the taxonomies that should be removed in this import.
1 call to TaxonomiesController::deleteDeletedTaxonomies()
- TaxonomiesController::importTaxonomies in src/
Controller/ TaxonomiesController.php - Function to import taxonomy terms.
File
- src/
Controller/ TaxonomiesController.php, line 295
Class
- TaxonomiesController
- Controller for syncing taxonomy terms.
Namespace
Drupal\structure_sync\ControllerCode
public static function deleteDeletedTaxonomies($taxonomies, &$context) {
$uuidsInConfig = [];
foreach ($taxonomies as $voc) {
foreach ($voc as $taxonomy) {
$uuidsInConfig[] = $taxonomy['uuid'];
}
}
if (!empty($uuidsInConfig)) {
$query = StructureSyncHelper::getEntityQuery('taxonomy_term');
$query
->condition('uuid', $uuidsInConfig, 'NOT IN');
$tids = $query
->execute();
$controller = StructureSyncHelper::getEntityManager()
->getStorage('taxonomy_term');
$entities = $controller
->loadMultiple($tids);
$controller
->delete($entities);
}
if (array_key_exists('drush', $context) && $context['drush'] === TRUE) {
drush_log('Deleted taxonomies that were not in config', 'ok');
}
StructureSyncHelper::logMessage('Deleted taxonomies that were not in config');
}