Contao\Dbafs::deleteResource PHP Метод

deleteResource() публичный статический Метод

Removes a file or folder
public static deleteResource ( string $strResource ) : null
$strResource string The path to the file or folder
Результат null Explicitly return null
    public static function deleteResource($strResource)
    {
        $objModel = \FilesModel::findByPath($strResource);
        // Remove the resource
        if ($objModel !== null) {
            $objModel->delete();
        }
        // Look for subfolders and files
        $objFiles = \FilesModel::findMultipleByBasepath($strResource . '/');
        // Remove subfolders and files as well
        if ($objFiles !== null) {
            while ($objFiles->next()) {
                $objFiles->delete();
            }
        }
        static::updateFolderHashes(dirname($strResource));
        return null;
    }

Usage Example

Пример #1
0
 /**
  * Rename the file
  *
  * @param string $strNewName The new path
  *
  * @return boolean True if the operation was successful
  */
 public function renameTo($strNewName)
 {
     $strParent = dirname($strNewName);
     // Create the parent folder if it does not exist
     if (!is_dir(TL_ROOT . '/' . $strParent)) {
         new \Folder($strParent);
     }
     $return = $this->Files->rename($this->strFile, $strNewName);
     // Update the database AFTER the file has been renamed
     $syncSource = \Dbafs::shouldBeSynchronized($this->strFile);
     $syncTarget = \Dbafs::shouldBeSynchronized($strNewName);
     // Synchronize the database
     if ($syncSource && $syncTarget) {
         $this->objModel = \Dbafs::moveResource($this->strFile, $strNewName);
     } elseif ($syncSource) {
         $this->objModel = \Dbafs::deleteResource($this->strFile);
     } elseif ($syncTarget) {
         $this->objModel = \Dbafs::addResource($strNewName);
     }
     // Reset the object AFTER the database has been updated
     if ($return != false) {
         $this->strFile = $strNewName;
         $this->arrImageSize = array();
         $this->arrPathinfo = array();
     }
     return $return;
 }
All Usage Examples Of Contao\Dbafs::deleteResource