public function delete($condition, $check = true)
    {
        $result = null;
        $this->hook->attach('file.delete.before', $condition, $check, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        if (!is_array($condition)) {
            $condition = array('file_id' => $condition);
        }

        if ($check && isset($condition['file_id']) && !$this->canDelete($condition['file_id'])) {
            return false;
        }

        $result = (bool) $this->db->delete('file', $condition);

        if ($result && isset($condition['file_id'])) {
            $this->deleteLinked($condition['file_id']);
        }

        $this->hook->attach('file.delete.after', $condition, $check, $result, $this);
        return (bool) $result;
    }
public function delete($condition, $check = true)
    {
        $result = null;
        $this->hook->attach('file.delete.before', $condition, $check, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        if (!is_array($condition)) {
            $condition = array('file_id' => $condition);
        }

        if ($check && isset($condition['file_id']) && !$this->canDelete($condition['file_id'])) {
            return false;
        }

        $result = (bool) $this->db->delete('file', $condition);

        if ($result && isset($condition['file_id'])) {
            $this->deleteLinked($condition['file_id']);
        }

        $this->hook->attach('file.delete.after', $condition, $check, $result, $this);
        return (bool) $result;
    }
public function delete ( $ condition , $ check = true ) { $ result = null ; $ this -> hook -> attach ( 'file.delete.before' , $ condition , $ check , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( bool ) $ result ; } if ( ! is_array ( $ condition ) ) { $ condition = array ( 'file_id' => $ condition ) ; } if ( $ check && isset ( $ condition [ 'file_id' ] ) && ! $ this -> canDelete ( $ condition [ 'file_id' ] ) ) { return false ; } $ result = ( bool ) $ this -> db -> delete ( 'file' , $ condition ) ; if ( $ result && isset ( $ condition [ 'file_id' ] ) ) { $ this -> deleteLinked ( $ condition [ 'file_id' ] ) ; } $ this -> hook -> attach ( 'file.delete.after' , $ condition , $ check , $ result , $ this ) ; return ( bool ) $ result ; }
Deletes a file from the database
@param int|array $condition
@param bool $check
@return boolean
Deletes a file from the database