Airship\Cabin\Bridge\Blueprint\Files::getChildrenOf PHP Method

getChildrenOf() public method

Get all of the directories beneath the current one
public getChildrenOf ( mixed $directoryId = null, string $cabin = '' ) : array
$directoryId mixed (usually an integer, sometimes null)
$cabin string
return array
    public function getChildrenOf($directoryId = null, string $cabin = '') : array
    {
        if (empty($directoryId)) {
            $children = $this->db->run('SELECT
                     *
                 FROM
                     airship_dirs
                 WHERE
                         parent IS NULL
                     AND cabin = ?
                 ORDER BY name ASC', $cabin);
        } else {
            $children = $this->db->run('SELECT
                     *
                 FROM
                     airship_dirs
                 WHERE
                         parent = ?
                     AND cabin = ?
                 ORDER BY name ASC', $directoryId, $cabin);
        }
        if (empty($children)) {
            return [];
        }
        return $children;
    }

Usage Example

Example #1
0
 /**
  * Process the landing page.
  *
  * @param string $path
  * @param string $cabin
  */
 protected function commonIndex(string $path, string $cabin)
 {
     list($publicPath, $root) = $this->loadCommonData($path, $cabin);
     $post = $this->post(new NewDirFilter());
     if (!empty($post['submit_btn'])) {
         switch ($post['submit_btn']) {
             case 'new_dir':
                 $status = $this->createDir($root, $cabin, $post);
                 break;
             case 'upload':
                 $status = $this->uploadFiles($root, $cabin);
                 break;
             default:
                 $status = ['status' => 'ERROR', 'message' => \__('Unknown operation')];
         }
         if ($status['status'] === 'SUCCESS') {
             \Airship\redirect($this->airship_cabin_prefix . '/' . $this->path_middle . '/' . $cabin, ['dir' => $path]);
         }
         $this->storeLensVar('form_status', $status);
     }
     $this->lens('files/index', ['cabins' => $this->getCabinNamespaces(), 'subdirs' => $this->files->getChildrenOf($root, $cabin), 'files' => $this->files->getFilesInDirectory($root, $cabin), 'pathinfo' => $publicPath, 'current' => $path, 'cabin' => $cabin]);
 }