public function getAdapter($path = null)
{
$adapterServiceId = 'jarves.filesystem.adapter.local';
$params['root'] = realpath($this->jarves->getRootDir() . '/../web/');
if ($path && '/' !== $path[0]) {
$path = '/' . $path;
}
if ($path != '/') {
$sPos = strpos(substr($path, 1), '/');
if (false === $sPos) {
$firstFolder = substr($path, 1);
} else {
$firstFolder = substr($path, 1, $sPos);
}
} else {
$firstFolder = '/';
}
if ('/' !== $firstFolder) {
//todo
$mounts = $this->jarvesConfig->getSystemConfig()->getMountPoints(true);
//if firstFolder a mounted folder?
if ($mounts && $mounts->hasMount($firstFolder)) {
// $mountPoint = $mounts->getMount($firstFolder);
// $adapterClass = $mountPoint->getClass();
// $params = $mountPoint->getParams();
// $mountName = $firstFolder;
} else {
$firstFolder = '/';
}
}
if (isset($this->adapterInstances[$firstFolder])) {
return $this->adapterInstances[$firstFolder];
}
$adapter = $this->newAdapter($adapterServiceId, $firstFolder, $params);
$adapter->setMountPath($firstFolder);
if ($adapter instanceof ContainerAwareInterface) {
$adapter->setContainer($this->container);
}
$adapter->loadConfig();
return $this->adapterInstances[$firstFolder] = $adapter;
}