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

deleteFile() public method

Delete a file
public deleteFile ( array $fileInfo ) : boolean
$fileInfo array
return boolean
    public function deleteFile(array $fileInfo) : bool
    {
        $this->db->beginTransaction();
        if (\file_exists(\AIRSHIP_UPLOADS . $fileInfo['realname'])) {
            \unlink(\AIRSHIP_UPLOADS . $fileInfo['realname']);
        }
        // Remove associations with this file
        $this->db->update('hull_blog_author_photos', ['file' => null], ['file' => $fileInfo['fileid']]);
        $this->db->delete('airship_files', ['fileid' => $fileInfo['fileid']]);
        return $this->db->commit();
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Confirm file deletion
  *
  * @param string $file
  * @param string $path
  * @param string $cabin
  */
 protected function commonConfirmDeleteFile(string $file, string $path, string $cabin)
 {
     if (!$this->permCheck()) {
         \Airship\redirect($this->airship_cabin_prefix);
     }
     list($publicPath, $root) = $this->loadCommonData($path, $cabin);
     if (empty($root)) {
         $fileInfo = $this->files->getFileInfo($cabin, null, $file);
     } else {
         $fileInfo = $this->files->getFileInfo($cabin, $root, $file);
     }
     $post = $this->post();
     if (!empty($post)) {
         $this->files->deleteFile($fileInfo);
         \Airship\redirect($this->airship_cabin_prefix . '/' . $this->path_middle . '/' . $cabin, ['dir' => $path]);
     }
     $this->lens('files/delete', ['cabins' => $this->getCabinNamespaces(), 'file' => $fileInfo, 'root_dir' => $this->root_dir, 'dir' => $this->root_dir . '/' . $path, 'cabin' => $cabin, 'pathinfo' => $publicPath]);
 }