public function elFinderDrupal::__construct in elFinder file manager 8.2
File
- src/
Controller/ elFinderDrupal.php, line 14 - elFinder conenctor class
Class
- elFinderDrupal
- @file
Namespace
Drupal\elfinder\ControllerCode
public function __construct($opts) {
$this->time = $this
->utime();
$this->debug = isset($opts['debug']) && $opts['debug'] ? true : false;
setlocale(LC_ALL, !empty($opts['locale']) ? $opts['locale'] : 'en_US.UTF-8');
// bind events listeners
if (!empty($opts['bind']) && is_array($opts['bind'])) {
foreach ($opts['bind'] as $cmd => $handler) {
$this
->bind($cmd, $handler);
}
}
if (!isset($opts['roots']) || !is_array($opts['roots'])) {
$opts['roots'] = array();
}
// check for net volumes stored in session
if (method_exists($this, 'getNetVolumes')) {
foreach ($this
->getNetVolumes() as $root) {
$opts['roots'][] = $root;
}
}
// "mount" volumes
foreach ($opts['roots'] as $i => $o) {
$class = 'elFinderVolume' . (isset($o['driver']) ? $o['driver'] : '');
if (class_exists($class)) {
$volume = new $class();
if ($volume
->mount($o)) {
// unique volume id (ends on "_") - used as prefix to files hash
$id = $volume
->id();
$this->volumes[$id] = $volume;
if (!$this->default && $volume
->isReadable()) {
$this->default = $this->volumes[$id];
}
}
else {
$this->mountErrors[] = 'Driver "' . $class . '" : ' . implode(' ', $volume
->error());
}
}
else {
$this->mountErrors[] = 'Driver "' . $class . '" does not exists';
}
}
// if at least one redable volume - ii desu >_<
$this->loaded = !empty($this->default);
/* Adding new command */
$this->commands['desc'] = array(
'target' => TRUE,
'content' => FALSE,
);
$this->commands['owner'] = array(
'target' => TRUE,
'content' => FALSE,
);
$this->commands['downloadcount'] = array(
'target' => TRUE,
);
}