You are here

public function ImceFM::addFolder in IMCE 8

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

Adds a folder to the tree.

2 calls to ImceFM::addFolder()
ImceFM::checkFolder in src/ImceFM.php
Checks if the user provided folder path is accessible.
ImceFM::getInitError in src/ImceFM.php
Performs the initialization and returns the first error message.

File

src/ImceFM.php, line 231

Class

ImceFM
Imce File Manager.

Namespace

Drupal\imce

Code

public function addFolder($path, array $conf = NULL) {

  // Existing.
  if ($folder = $this
    ->getFolder($path)) {
    if (isset($conf)) {
      $folder
        ->setConf($conf);
    }
    return $folder;
  }

  // New. Append to the parent.
  if ($parts = Imce::splitPath($path)) {
    list($parent_path, $name) = $parts;
    if ($parent = $this
      ->addFolder($parent_path)) {
      return $parent
        ->addSubfolder($name, $conf);
    }
  }
}