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

getPage() public method

Get information about a custom page.
public getPage ( string $file, integer $directoryId, string $cabin = '' ) : array
$file string
$directoryId integer
$cabin string
return array
    public function getPage(string $file, int $directoryId = 0, string $cabin = '') : array
    {
        if (empty($cabin)) {
            $cabin = $this->cabin;
        }
        if ($directoryId > 0) {
            $page = $this->db->row("SELECT\n                    *\n                FROM\n                    airship_custom_page\n                WHERE\n                        active\n                    AND cabin = ?\n                    AND directory = ?\n                    AND url = ?\n                ", $cabin, $directoryId, $file);
        } else {
            // No directory? Only look for when it's null then!
            $page = $this->db->row("SELECT\n                    *\n                FROM\n                    airship_custom_page\n                WHERE\n                        active\n                    AND cabin = ?\n                    AND directory IS NULL\n                    AND url = ?\n                ", $cabin, $file);
        }
        if (empty($page)) {
            throw new CustomPageNotFoundException();
        }
        return $page;
    }

Usage Example

Example #1
0
 /**
  * Serve a file
  *
  * @param string $file
  * @param int $directoryId
  * @return bool
  */
 protected function serveFile(string $file, int $directoryId) : bool
 {
     $page = $this->pages->getPage($file, $directoryId);
     if (!empty($page)) {
         return $this->serveLatestVersion($page);
     }
     return false;
 }