public function getDirectoryId(array $parts, string $cabin) : int
{
$part = \array_shift($parts);
$parent = $this->db->cell('SELECT
directoryid
FROM
airship_dirs
WHERE
parent IS NULL
AND name = ?
AND cabin = ?', $part, $cabin);
if (empty($parent)) {
throw new FileNotFound();
}
foreach ($parts as $part) {
$parent = $this->db->cell('SELECT
*
FROM
airship_dirs
WHERE
name = ?
AND parent = ?
AND cabin = ?', $part, $parent, $cabin);
if (empty($parent)) {
throw new FileNotFound();
}
}
return $parent;
}
/** * Reduce code duplication * * @param string $path * @param string $cabin * @return array (array $publicPath, int|null $root) */ protected function loadCommonData(string $path, string $cabin) : array { if (!$this->permCheck()) { \Airship\redirect($this->airship_cabin_prefix); } $root = null; $publicPath = \Airship\chunk($path); $pathInfo = $this->getPath($path); if (!empty($pathInfo)) { try { $root = $this->files->getDirectoryId($pathInfo, $cabin); } catch (FileNotFound $ex) { \Airship\redirect($this->airship_cabin_prefix); } } // return [$pathInfo, $publicPath, $root]; return [$publicPath, $root]; }