listCustomPages() public method

List all of the custom pages contained within a given cabin and directory
public listCustomPages ( string $dir = '', string $cabin = CABIN_NAME ) : array
$dir string
$cabin string
return array
Example #1
0
 /**
  * List all of the subdirectories and custom pages in a given directory
  *
  * @param pages /{string}
  * @param string $cabin
  */
 public function forCabin(string $cabin = '')
 {
     $path = $this->determinePath($cabin);
     $cabins = $this->getCabinNamespaces();
     if (!\in_array($cabin, $cabins)) {
         \Airship\redirect($this->airship_cabin_prefix);
     }
     $this->pg->setCabin($cabin);
     // Let's populate the subdirectories for the current directory
     try {
         $dirs = $this->pg->listSubDirectories($path, $cabin);
     } catch (CustomPageNotFoundException $ex) {
         if (!empty($path)) {
             \Airship\redirect($this->airship_cabin_prefix . '/pages/' . \trim($cabin, '/'));
         }
         $dirs = [];
     }
     // Let's populate the subdirectories for the current directory
     try {
         $pages = $this->pg->listCustomPages($path, $cabin);
     } catch (CustomPageNotFoundException $ex) {
         $pages = [];
     }
     $this->setTemplateExtraData($cabin);
     $this->lens('pages_list', ['cabins' => $cabins, 'dirs' => $dirs, 'pages' => $pages, 'current' => $path, 'cabin' => $cabin, 'path' => \Airship\chunk($path)]);
 }