public function ImportPartialForm::deleteContent in Tome 8
Batch callback to delete content or a content translation.
Parameters
string $name: A content name.
File
- modules/
tome_sync/ src/ Form/ ImportPartialForm.php, line 260
Class
- ImportPartialForm
- Contains a form for performing a partial import.
Namespace
Drupal\tome_sync\FormCode
public function deleteContent($name) {
list($entity_type_id, $uuid, $langcode) = TomeSyncHelper::getPartsFromContentName($name);
$results = $this->entityTypeManager
->getStorage($entity_type_id)
->loadByProperties([
'uuid' => $uuid,
]);
if (count($results) === 1) {
$entity = reset($results);
if ($langcode) {
if ($translation = $entity
->getTranslation($langcode)) {
$entity
->removeTranslation($langcode);
$entity
->save();
}
}
else {
$entity
->delete();
}
}
}