/** * deletes both filesystem file and metafile and removes instance from lookup array * filesystem file will be kept when $keepFilesystemFile is TRUE * * @param boolean $keepFilesystemFile * * @throws Exception */ public function delete($keepFilesystemFile = FALSE) { FileEvent::create(FileEvent::BEFORE_METAFILE_DELETE, $this)->trigger(); if (Application::getInstance()->getDb()->deleteRecord('files', $this->id)) { unset(self::$instancesById[$this->id]); unset(self::$instancesByPath[$this->filesystemFile->getPath()]); if (!$keepFilesystemFile) { $this->filesystemFile->delete(); } } else { throw new MetaFileException("Delete of metafile '{$this->filesystemFile->getPath()}' failed."); } }