You are here

public function ImceFolder::setPath in IMCE 8

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

Sets the folder path.

File

src/ImceFolder.php, line 97

Class

ImceFolder
Imce Folder.

Namespace

Drupal\imce

Code

public function setPath($path) {
  $oldpath = $this->path;
  if ($path !== $oldpath) {

    // Remove oldpath references.
    if (isset($oldpath)) {
      unset($this
        ->fm()->tree[$oldpath]);
      foreach ($this->subfolders as $name => $item) {
        $item
          ->setPath(NULL);
      }
    }

    // Add new path references.
    $this->path = $path;
    if (isset($path)) {
      $this
        ->fm()->tree[$path] = $this;
      foreach ($this->subfolders as $name => $item) {
        $item
          ->setPath(Imce::joinPaths($path, $name));
      }
    }
  }
}