public function CmisRepositoryController::objectDelete in CMIS API 8
Same name and namespace in other branches
- 8.2 src/Controller/CmisRepositoryController.php \Drupal\cmis\Controller\CmisRepositoryController::objectDelete()
- 3.0.x src/Controller/CmisRepositoryController.php \Drupal\cmis\Controller\CmisRepositoryController::objectDelete()
Object delete popup.
Parameters
string $config:
string $document_id:
1 string reference to 'CmisRepositoryController::objectDelete'
File
- src/
Controller/ CmisRepositoryController.php, line 131
Class
- CmisRepositoryController
- Class CmisRepositoryController.
Namespace
Drupal\cmis\ControllerCode
public function objectDelete($config = '', $object_id = '') {
$parameters = \Drupal::request()->query
->all();
$type = '';
$name = '';
if (!empty($parameters['type']) && !empty($config) && !empty($object_id) && (!empty($parameters['parent']) || !empty($parameters['query_string']))) {
switch ($parameters['type']) {
case 'browser':
$redirect = $this
->redirect('cmis.cmis_repository_controller_browser', [
'config' => $config,
]);
break;
case 'query':
$parameters += [
'config' => $config,
];
$redirect = $this
->redirect('cmis.cmis_query_form_callback', [], [
'query' => $parameters,
]);
break;
default:
// Back to frontpage if not browser or not query.
$redirect = new \Symfony\Component\HttpFoundation\RedirectResponse('/');
}
$this
->setConnection($config);
if ($this->connection) {
$root = $this->connection
->getRootFolder();
if ($root
->getId() != $object_id && ($current = $this->connection
->getObjectById($object_id))) {
// Exists object and not root folder.
$type = $current
->getBaseTypeId()
->__toString();
$name = $current
->getName();
$args = [
'@type' => str_replace('cmis:', '', $type),
'@name' => $name,
];
$current
->delete(TRUE);
drupal_set_message($this
->t('The @type name @name has now been deleted.', $args));
if ($parameters['type'] == 'browser') {
$redirect = $this
->redirect('cmis.cmis_repository_controller_browser', [
'config' => $config,
'folder_id' => $parameters['parent'],
]);
}
}
else {
if ($root
->getId() != $object_id) {
drupal_set_message($this
->t("Could not delete object. Object is not exists in repositoty."), 'warning');
}
else {
drupal_set_message($this
->t("Could not delete root folder."), 'warning');
}
}
}
}
else {
drupal_set_message($this
->t('Argument or parameter missed.'), 'warning');
// Back to frontpage.
$redirect = new \Symfony\Component\HttpFoundation\RedirectResponse('/');
}
return $redirect;
}