public function MediaDirectoriesController::directoryDelete in Media Directories 2.x
Same name and namespace in other branches
- 8 modules/media_directories_ui/src/Controller/MediaDirectoriesController.php \Drupal\media_directories_ui\Controller\MediaDirectoriesController::directoryDelete()
- 3.x modules/media_directories_ui/src/Controller/MediaDirectoriesController.php \Drupal\media_directories_ui\Controller\MediaDirectoriesController::directoryDelete()
Delete directory.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request.
Return value
\Drupal\Core\Ajax\AjaxResponse An AJAX response.
1 string reference to 'MediaDirectoriesController::directoryDelete'
- media_directories_ui.routing.yml in modules/
media_directories_ui/ media_directories_ui.routing.yml - modules/media_directories_ui/media_directories_ui.routing.yml
File
- modules/
media_directories_ui/ src/ Controller/ MediaDirectoriesController.php, line 317
Class
- MediaDirectoriesController
- Main controller class.
Namespace
Drupal\media_directories_ui\ControllerCode
public function directoryDelete(Request $request) {
$response = new AjaxResponse();
$directory_id = (int) $request->request
->get('directory_id');
$target_bundles = $request->request
->get('target_bundles');
$directory = Term::load($directory_id);
if ($directory === NULL) {
return $response;
}
if ($directory
->access('delete')) {
$context = [
'directory' => $directory,
'target_bundles' => $target_bundles,
];
$form = $this->formBuilder
->getForm(DirectoryDeleteForm::class, $context);
$response
->addCommand(new OpenModalDialogCommand($this
->t('Delete directory @name', [
'@name' => $directory
->getName(),
]), $form, [
'width' => '500',
]));
}
else {
$this
->messenger()
->addError($this
->t('No permission found to delete this directory.'));
$this
->addMessagesToResponse($response);
}
return $response;
}