You are here

protected function CmisElement::prepareElement in CMIS API 3.0.x

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

Set element to render array.

Parameters

string $theme: Render theme.

string $data: Data.

string $id: CMIS Object id.

1 call to CmisElement::prepareElement()
CmisElement::prepare in src/CmisElement.php
Prepare element data.

File

src/CmisElement.php, line 160

Class

CmisElement
Description of CmisElement.

Namespace

Drupal\cmis

Code

protected function prepareElement($theme, $data, $id = '') {
  $author = $this->element
    ->getCreatedBy();
  $created = $this->element
    ->getCreationDate()
    ->format('Y-m-d H:i:s');
  $description = $this->element
    ->getDescription();
  $title = '';
  if ($title_property = $this->element
    ->getProperty('cm:title')) {
    $title = $title_property
      ->getFirstValue();
  }
  $size = 0;
  if ($size_property = $this->element
    ->getProperty('cmis:contentStreamLength')) {
    $size = $size_property
      ->getFirstValue();
  }
  $mime_type = '';
  $operations = '';
  if ($theme == 'cmis_browser_folder_item') {
    $this
      ->prepareFolderElement($data, $operations, $id);
  }
  if ($theme == 'cmis_browser_document_item') {
    $this
      ->prepareDocumentElement($data, $operations, $id);
  }
  if (!$this->popup) {
    $this
      ->preparePropertiesLink($operations);
  }
  $element = [
    '#theme' => $theme,
    '#element' => $data,
  ];
  $details = [
    '#theme' => 'cmis_browser_document_details',
    '#title' => $title,
    '#mime_type' => $mime_type,
    '#size' => number_format($size, 0, '', ' '),
  ];
  $this->data = [
    render($element),
    render($details),
    $author,
    $created,
    $description,
    $operations,
  ];
}