You are here

public function ImceFM::addItemToJs in IMCE 8.2

Same name and namespace in other branches
  1. 8 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) {
    $path = $parent
      ->getPath();
    if (isset($path)) {
      $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;
      }
    }
  }
}