You are here

public function ImceFM::addItemToJs in IMCE 8

Same name and namespace in other branches
  1. 8.2 src/ImceFM.php \Drupal\imce\ImceFM::addItemToJs()

Add an item to the response.

File

src/ImceFM.php, line 421

Class

ImceFM
Imce File Manager.

Namespace

Drupal\imce

Code

public function addItemToJs(ImceItem $item) {
  if ($parent = $item->parent) {
    if ($path = $parent
      ->getPath()) {
      $name = $item->name;
      $uri = $item
        ->getUri();
      if ($item->type === 'folder') {
        $this->response['added'][$path]['subfolders'][$name] = $this
          ->getFolderProperties($uri);
      }
      else {
        $props = $this
          ->getFileProperties($uri);
        if (isset($item->uuid)) {
          $props['uuid'] = $item->uuid;
        }
        $this->response['added'][$path]['files'][$name] = $props;
      }
    }
  }
}