You are here

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

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

Prepare folder element.

Parameters

string $data: Get data.

string $operations: Get render.

string $id: CMIS object id.

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

File

src/CmisElement.php, line 251

Class

CmisElement
Description of CmisElement.

Namespace

Drupal\cmis

Code

private function prepareFolderElement(&$data, &$operations, $id) {
  switch ($this->type) {
    case 'browser':
      $url = Url::fromUserInput('/cmis/browser/nojs/' . $this->config . '/' . $id);
      $link_options = [
        'attributes' => [
          'class' => [
            'use-ajax',
          ],
        ],
      ];
      break;
    case 'query':
      $url = Url::fromUserInput('/cmis/browser/' . $this->config . '/' . $id);
      break;
  }
  if ($this->popup) {
    $url_operation = Url::fromUserInput('/');
    $link_options_operations = [
      'attributes' => [
        'class' => [
          'cmis-field-insert',
        ],
        'id' => $this->element
          ->getProperty('cmis:objectId')
          ->getFirstValue(),
        'name' => $data,
      ],
    ];
    $url_operation
      ->setOptions($link_options_operations);
    $path = Link::fromTextAndUrl($this
      ->t('Choose folder'), $url_operation)
      ->toRenderable();
    $operations = render($path);
    $link_options['query'] = [
      'type' => 'popup',
    ];
  }
  if (!empty($link_options)) {
    $url
      ->setOptions($link_options);
  }
  $data = Link::fromTextAndUrl($data, $url)
    ->toRenderable();
}