You are here

public function ImceFolder::appendItem in IMCE 8

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

Appends an item to the item list.

1 call to ImceFolder::appendItem()
ImceFolder::createItem in src/ImceFolder.php
Creates and returns a child file/folder object by name.

File

src/ImceFolder.php, line 149

Class

ImceFolder
Imce Folder.

Namespace

Drupal\imce

Code

public function appendItem(ImceItem $item) {
  $parent = $item->parent;
  if ($item !== $this && $parent !== $this) {
    if ($parent) {
      $parent
        ->removeItem($item);
    }
    $item->parent = $this;
    $name = $item->name;
    $this->items[$name] = $item;
    if ($item->type === 'folder') {
      $this->subfolders[$name] = $item;
      $path = ($this->parent ? $this
        ->getPath() . '/' : '') . $name;
      $item
        ->setPath($path);
    }
    else {
      $this->files[$name] = $item;
    }
  }
  return $item;
}