public function ImceFolder::scan in IMCE 8.2
Same name and namespace in other branches
- 8 src/ImceFolder.php \Drupal\imce\ImceFolder::scan()
Scans folder content.
1 call to ImceFolder::scan()
- ImceFolder::checkItem in src/
ImceFolder.php - Returns an item by name.
File
- src/
ImceFolder.php, line 238
Class
- ImceFolder
- Imce Folder.
Namespace
Drupal\imceCode
public function scan() {
if (!$this->scanned) {
$this->scanned = TRUE;
$options = [
'browse_files' => $this
->getPermission('browse_files'),
'browse_subfolders' => $this
->getPermission('browse_subfolders'),
];
$content = $this
->fm()
->scanDir($this
->getUri(), $options);
// Add files as raw data. We create the objects when needed.
$this->files = $this->items = $content['files'];
// Create the subfolder objects.
$subfolders = $this->subfolders;
$this->subfolders = [];
foreach ($content['subfolders'] as $name => $uri) {
// Check if previously created.
if (isset($subfolders[$name]) && is_object($subfolders[$name])) {
$this->subfolders[$name] = $this->items[$name] = $subfolders[$name];
}
else {
$this
->addSubfolder($name);
}
}
}
}