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

35
laravel/download.php Normal file
View File

@@ -0,0 +1,35 @@
<?php namespace Laravel;
class Download extends Response {
/**
* Create a new download response instance.
*
* <code>
* // Return a download response for a given file
* return new Download('path/to/image.jpg');
*
* // Return a download response for a given file and assign a name
* return new Download('path/to/image.jpg', 'you.jpg');
* </code>
*
* @param string $path
* @param string $name
*/
public function __construct($path, $name = null)
{
if (is_null($name)) $name = basename($path);
parent::__construct(file_get_contents($path));
$this->header('Content-Description', 'File Transfer');
$this->header('Content-Type', File::mime(File::extension($path)));
$this->header('Content-Disposition', 'attachment; filename="'.$name.'"');
$this->header('Content-Transfer-Encoding', 'binary');
$this->header('Expires', 0);
$this->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
$this->header('Pragma', 'public');
$this->header('Content-Length', filesize($path));
}
}