Airship\Cabin\Bridge\Blueprint\Author::getAvailablePhotos PHP Method

getAvailablePhotos() public method

1. Get the directories for each cabin. 2. Get all of the file IDs for these directories. Our SQL query should automatically draw in the "context" parameter.
public getAvailablePhotos ( integer $authorID, string $cabin = '', boolean $includeId = false ) : array
$authorID integer
$cabin string
$includeId boolean
return array
    public function getAvailablePhotos(int $authorID, string $cabin = '', bool $includeId = false) : array
    {
        $slug = $this->db->cell('SELECT slug FROM hull_blog_authors WHERE authorid = ?', $authorID);
        $directoryIDs = [];
        if (empty($cabin)) {
            foreach ($this->getCabinNames() as $cabin) {
                $cabinDir = $this->getPhotoDirectory($slug, $cabin);
                if (!empty($cabinDir)) {
                    $directoryIDs[] = $cabinDir;
                }
            }
        } else {
            $cabinDir = $this->getPhotoDirectory($slug, $cabin);
            if (!empty($cabinDir)) {
                $directoryIDs[] = $cabinDir;
            }
        }
        if (empty($directoryIDs)) {
            return [];
        }
        $files = $this->db->run("SELECT\n                 " . ($includeId ? 'f.fileid,' : '') . "\n                 f.filename,\n                 p.context\n             FROM \n                 airship_files f\n             LEFT JOIN\n                 hull_blog_author_photos p\n                 ON p.file = f.fileid\n             WHERE\n                 (f.type LIKE 'image/%' OR f.type LIKE 'x-image/%') \n                     AND\n                 f.directory IN " . $this->db->escapeValueSet($directoryIDs, 'int'));
        if (empty($files)) {
            return [];
        }
        return $files;
    }