You are here

private function CmisElement::preparePropertiesLink in CMIS API 3.0.x

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

Prepare properties link.

Parameters

string $operations: Get render.

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

File

src/CmisElement.php, line 298

Class

CmisElement
Description of CmisElement.

Namespace

Drupal\cmis

Code

private function preparePropertiesLink(&$operations) {
  $url = Url::fromUserInput('/cmis/object-properties/' . $this->config . '/' . $this->element
    ->getId());
  $link_options = [
    'attributes' => [
      'class' => [
        'use-ajax',
      ],
      'data-dialog-type' => 'modal',
      'data-dialog-options' => Json::encode([
        'height' => 400,
        'width' => 700,
      ]),
    ],
  ];
  $url
    ->setOptions($link_options);
  $path = Link::fromTextAndUrl($this
    ->t('Properties'), $url)
    ->toRenderable();
  $links[] = [
    '#markup' => render($path),
    '#wrapper_attributes' => [
      'class' => [
        'object-properties',
      ],
    ],
  ];
  $cmis_connection_api = new CmisConnectionApi($this->config);
  $cmis_connection_api
    ->setDefaultParameters();
  $element_id = $this->element
    ->getId();
  if ($this->rootId != $element_id && $cmis_connection_api
    ->hasAllowableActionById($element_id, Action::CAN_DELETE_OBJECT)) {
    $url = Url::fromUserInput('/cmis/object-delete-verify/' . $this->config . '/' . $element_id);
    $link_options = [
      'attributes' => [
        'class' => [
          'use-ajax',
        ],
        'data-dialog-type' => 'modal',
        'data-dialog-options' => 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->queryString;
        break;
    }
    $url
      ->setOptions($link_options);
    $path = Link::fromTextAndUrl($this
      ->t('Delete'), $url)
      ->toRenderable();
    $links[] = [
      '#markup' => render($path),
      '#wrapper_attributes' => [
        'class' => [
          'object-delete',
        ],
      ],
    ];
  }
  $list = [
    '#theme' => 'item_list',
    '#items' => $links,
    '#type' => 'ul',
  ];
  $operations = render($list);
}