public function StorageManager::deleteField in Paragraph View Mode 8
Same name and namespace in other branches
- 2.x src/StorageManager.php \Drupal\paragraph_view_mode\StorageManager::deleteField()
Delete field from the given bundle.
Parameters
string $bundle: Paragraph entity bundle.
Return value
bool True if the field does not exist or was successfully deleted.
Overrides StorageManagerInterface::deleteField
File
- src/
StorageManager.php, line 99
Class
- StorageManager
- Provides fields and forms storage operations required by the module.
Namespace
Drupal\paragraph_view_modeCode
public function deleteField(string $bundle) : bool {
$field = $this
->getField($bundle);
if ($field) {
try {
$field
->delete();
$this
->messenger()
->addMessage($this
->t('%label field has been deleted on %type bundle %bundle', [
'%label' => StorageManagerInterface::FIELD_LABEL,
'%type' => StorageManagerInterface::ENTITY_TYPE,
'%bundle' => $bundle,
]));
return TRUE;
} catch (EntityStorageException $exception) {
$this
->messenger()
->addMessage($this
->t('Unable to delete %label for %type bundle %bundle', [
'%label' => StorageManagerInterface::FIELD_LABEL,
'%type' => StorageManagerInterface::ENTITY_TYPE,
'%bundle' => $bundle,
]), MessengerInterface::TYPE_ERROR);
return FALSE;
}
}
else {
return TRUE;
}
}