1: <?php
2:
3: /*
4: * This file is part of the library "PhpMimeType".
5: *
6: * (c) Dennis Fridrich <fridrich.dennis@gmail.com>
7: *
8: * For the full copyright and license information,
9: * please view LICENSE.
10: */
11:
12: namespace Defr\PhpMimeType;
13:
14: use Symfony\Component\HttpFoundation\ResponseHeaderBag;
15:
16: class FileAsResponse
17: {
18: /**
19: * @param $file
20: * @param string $disposition
21: * @param null $fileName
22: *
23: * @throws MimeTypeException
24: *
25: * @return \Symfony\Component\HttpFoundation\Response
26: */
27: public static function get($file, $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT, $fileName = null)
28: {
29: return MimeType::response($file, $disposition, $fileName);
30: }
31:
32: /**
33: * @param $file
34: * @param string $disposition
35: * @param null $fileName
36: *
37: * @throws MimeTypeException
38: *
39: * @return \Symfony\Component\HttpFoundation\Response
40: */
41: public static function send($file, $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT, $fileName = null)
42: {
43: return MimeType::response($file, $disposition, $fileName)->send();
44: }
45: }
46: