Airship\Cabin\Bridge\Landing\Proto\FileManager::createDir PHP Method

createDir() protected method

Create a new directory for file uploads
protected createDir ( integer $directoryId = null, string $cabin = '', array $post = [] ) : array
$directoryId integer
$cabin string
$post array
return array
    protected function createDir($directoryId = null, string $cabin = '', array $post = []) : array
    {
        if (!\array_key_exists('directory', $post)) {
            return ['status' => 'ERROR', 'message' => 'Directory names cannot be empty'];
        }
        if (!$this->files->isValidName($post['directory'])) {
            return ['status' => 'ERROR', 'message' => 'Invalid directory name'];
        }
        if ($this->files->dirExists($directoryId, $cabin, $post['directory'])) {
            return ['status' => 'ERROR', 'message' => 'This directory already exists'];
        }
        if ($this->files->createDirectory($directoryId, $cabin, $post['directory'])) {
            return ['status' => 'SUCCESS', 'message' => 'This directory has been created sucessfully'];
        }
        return ['status' => 'UNKNOWN', 'message' => 'An unknown error has occurred.'];
    }