Airship\Cabin\Hull\Blueprint\CustomPages::getDirectoryId PHP Method

getDirectoryId() public method

Get the directory ID for a given path
public getDirectoryId ( string $dir, integer $parent, string $cabin = '' ) : integer
$dir string
$parent integer
$cabin string
return integer
    public function getDirectoryId(string $dir, int $parent = 0, string $cabin = '') : int
    {
        if (empty($cabin)) {
            $cabin = $this->cabin;
        }
        if (empty($parent)) {
            $res = $this->db->cell("SELECT\n                     directoryid\n                 FROM\n                     airship_custom_dir\n                 WHERE\n                         active\n                     AND cabin = ?\n                     AND url = ?\n                     AND parent IS NULL\n                ", $cabin, $dir);
        } else {
            $res = $this->db->cell("SELECT\n                 directoryid\n             FROM\n                 airship_custom_dir\n             WHERE\n                     active\n                 AND cabin = ?\n                 AND url = ?\n                 AND parent = ?\n            ", $cabin, $dir, $parent);
        }
        if ($res === false) {
            throw new CustomPageNotFoundException(\trk('errors.pages.directory_does_not_exist'));
        }
        return (int) $res;
    }