You are here

public function CmisRepositoryController::objectDeleteVerify in CMIS API 8

Same name and namespace in other branches
  1. 8.2 src/Controller/CmisRepositoryController.php \Drupal\cmis\Controller\CmisRepositoryController::objectDeleteVerify()
  2. 3.0.x src/Controller/CmisRepositoryController.php \Drupal\cmis\Controller\CmisRepositoryController::objectDeleteVerify()

Object delete verify popup.

Parameters

string $config:

string $document_id:

1 string reference to 'CmisRepositoryController::objectDeleteVerify'
cmis.routing.yml in ./cmis.routing.yml
cmis.routing.yml

File

src/Controller/CmisRepositoryController.php, line 73

Class

CmisRepositoryController
Class CmisRepositoryController.

Namespace

Drupal\cmis\Controller

Code

public function objectDeleteVerify($config = '', $object_id = '') {
  $parameters = \Drupal::request()->query
    ->all();
  unset($parameters['_wrapper_format']);
  $type = '';
  $name = '';
  if (!empty($parameters['type']) && !empty($config) && !empty($object_id) && (!empty($parameters['parent']) || !empty($parameters['query_string']))) {
    $this
      ->setConnection($config);
    if ($this->connection) {
      if ($current = $this->connection
        ->getObjectById($object_id)) {
        $type = $current
          ->getBaseTypeId()
          ->__toString();
        $name = $current
          ->getName();
      }
      else {
        return [
          '#theme' => 'cmis_object_delete_verify',
          '#title' => $this
            ->t("Object can't delete"),
          '#description' => $this
            ->t('Object not found in repository.'),
          '#link' => '',
        ];
      }
    }
  }
  else {
    return [
      '#theme' => 'cmis_object_delete_verify',
      '#title' => $this
        ->t("Object can't delete"),
      '#description' => $this
        ->t('Argument or parameter missed.'),
      '#link' => '',
    ];
  }
  $args = [
    '@type' => str_replace('cmis:', '', $type),
    '@name' => $name,
  ];
  $url = \Drupal\Core\Url::fromUserInput('/cmis/object-delete/' . $config . '/' . $object_id);
  $link_options = [
    'query' => $parameters,
  ];
  $url
    ->setOptions($link_options);
  $path = \Drupal\Core\Link::fromTextAndUrl(t('Delete'), $url)
    ->toRenderable();
  $link = render($path);
  return [
    '#theme' => 'cmis_object_delete_verify',
    '#title' => $this
      ->t('Are you sure you want to delete @type name @name', $args),
    '#description' => $this
      ->t('This action cannot be undone.'),
    '#link' => $link,
  ];
}