/** * Gives the URL for the given thumbnail * * @param string $thumbnail_type * @param string $relative_path * @return string */ public function getUrl($thumbnail_type = 'full', $relative_path = null) { if (is_null($relative_path)) { if (!($folder = $this->getFolder())) { throw new Exception(sprintf('You must set define the folder for an asset prior to getting its path. Asset %d doesn\'t have a folder yet.', $this->getFilename())); } $relative_path = $folder->getRelativePath(); } $url = sfAssetsLibraryTools::getMediaDir(); if ($thumbnail_type == 'full') { $url .= $relative_path . DIRECTORY_SEPARATOR . $this->getFilename(); } else { $url .= sfAssetsLibraryTools::getThumbnailDir($relative_path) . $thumbnail_type . '_' . $this->getFilename(); } return $url; }
/** * Also delete all contents * * @param Connection $con * @param Boolean $force If true, do not throw an exception if the physical directories cannot be removed */ public function delete(PropelPDO $con = null, $force = false) { $success = true; foreach ($this->getDescendants() as $descendant) { $success = $descendant->delete($con, $force) && $success; } foreach ($this->getsfAssets() as $asset) { $success = $asset->delete() && $success; } // Remove thumbnail subdir $success = rmdir(sfAssetsLibraryTools::getThumbnailDir($this->getFullPath())) && $success; // Remove dir itself $success = rmdir($this->getFullPath()) && $success; if ($success || $force) { parent::delete($con); } else { throw new sfAssetException('Impossible to delete folder "%name%"', array('%name%' => $this->getName())); } }