You are here

private function CmisElement::preparePropertiesLink in CMIS API 8

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

Prepare properties link.

Parameters

string $operations:

1 call to CmisElement::preparePropertiesLink()
CmisElement::prepareElement in src/CmisElement.php
Set element to render array.

File

src/CmisElement.php, line 258

Class

CmisElement
Description of CmisElement

Namespace

Drupal\cmis

Code

private function preparePropertiesLink(&$operations) {
  $url = \Drupal\Core\Url::fromUserInput('/cmis/object-properties/' . $this->config . '/' . $this->element
    ->getId());
  $link_options = array(
    'attributes' => array(
      'class' => [
        'use-ajax',
      ],
      'data-dialog-type' => 'modal',
      'data-dialog-options' => \Drupal\Component\Serialization\Json::encode([
        'height' => 400,
        'width' => 700,
      ]),
    ),
  );
  $url
    ->setOptions($link_options);
  $path = \Drupal\Core\Link::fromTextAndUrl(t('Properties'), $url)
    ->toRenderable();
  $links[] = [
    '#markup' => render($path),
    '#wrapper_attributes' => [
      'class' => [
        'object-properties',
      ],
    ],
  ];
  if ($this->rootId != $this->element
    ->getId() && \Drupal::currentUser()
    ->hasPermission('access cmis operations')) {
    $url = \Drupal\Core\Url::fromUserInput('/cmis/object-delete-verify/' . $this->config . '/' . $this->element
      ->getId());
    $link_options = array(
      'attributes' => array(
        'class' => [
          'use-ajax',
        ],
        'data-dialog-type' => 'modal',
        'data-dialog-options' => \Drupal\Component\Serialization\Json::encode([
          'height' => 120,
          'width' => 600,
        ]),
      ),
      'query' => [
        'type' => $this->type,
      ],
    );
    switch ($this->type) {
      case 'browser':
        $link_options['query']['parent'] = $this->parent
          ->getId();
        break;
      case 'query':
        $link_options['query']['query_string'] = $this->query_string;
        break;
    }
    $url
      ->setOptions($link_options);
    $path = \Drupal\Core\Link::fromTextAndUrl(t('Delete'), $url)
      ->toRenderable();
    $links[] = [
      '#markup' => render($path),
      '#wrapper_attributes' => [
        'class' => [
          'object-delete',
        ],
      ],
    ];
  }
  $list = [
    '#theme' => 'item_list',
    '#items' => $links,
    '#type' => 'ul',
  ];
  $operations = render($list);
}