refactoring and adding more dependency injection through ioc container.

This commit is contained in:
Taylor Otwell
2011-08-24 22:51:32 -05:00
parent 99adf09ac7
commit 6a8aafc259
46 changed files with 1039 additions and 1276 deletions

View File

@@ -71,7 +71,9 @@ class File {
array_unshift($file, '');
$length = ($line - ($start = $line - $padding)) + $padding + 1;
$start = $line - $padding;
$length = ($line - $start) + $padding + 1;
return array_slice($file, ($start > 0) ? $start : 0, ($length > 0) ? $length : 0, true);
}
@@ -128,32 +130,4 @@ class File {
return (is_array($mimes[$extension])) ? in_array($mime, $mimes[$extension]) : $mime === $mimes[$extension];
}
/**
* Create a response that will force a file to be downloaded.
*
* @param string $path
* @param string $name
* @return Response
*/
public static function download($path, $name = null)
{
if (is_null($name))
{
$name = basename($path);
}
$response = Response::make(static::get($path));
$response->header('Content-Description', 'File Transfer');
$response->header('Content-Type', static::mime(static::extension($path)));
$response->header('Content-Disposition', 'attachment; filename="'.$name.'"');
$response->header('Content-Transfer-Encoding', 'binary');
$response->header('Expires', 0);
$response->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
$response->header('Pragma', 'public');
$response->header('Content-Length', filesize($path));
return $response;
}
}