/** * * @param File $file * @return boolean */ public function canSendToBrowser(File $file = null) { $canViewFront = true; if ($file instanceof File) { // Implement all file extensions with canViewFront() $cans = $file->extend('canViewFront'); if ($cans && is_array($cans)) { foreach ($cans as $can) { $canViewFront = $can && $canViewFront; } } else { $canViewFront = false; } } else { $canViewFront = false; } return $canViewFront; }
public function canDownloadFile(File $file = null) { if ($file instanceof File) { // Implement a FileExtension with canDownload(), and we'll test that first $results = $file->extend('canDownload'); if ($results && is_array($results)) { if (!min($results)) { return false; } else { return true; } } // If an extension with canDownload() can't be found, fallback to using canView if ($file->canView()) { return true; } return false; } return false; }