Airship\Cabin\Bridge\Blueprint\Files::createDirectory PHP 메소드

createDirectory() 공개 메소드

Create a new directory
public createDirectory ( integer | null $parent = null, string $cabin = '', string $dirName = '' ) : boolean
$parent integer | null
$cabin string
$dirName string
리턴 boolean
    public function createDirectory($parent = null, string $cabin = '', string $dirName = '') : bool
    {
        $this->db->beginTransaction();
        $this->db->insert('airship_dirs', ['name' => $dirName, 'parent' => $parent > 0 ? $parent : null, 'cabin' => $cabin]);
        return $this->db->commit();
    }

Usage Example

예제 #1
0
 /**
  * Create a new directory for file uploads
  *
  * @param int $directoryId
  * @param string $cabin
  * @param array $post
  * @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.'];
 }