| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 19 | public function index(Request $request): Response |
||
| 20 | { |
||
| 21 | $fileSystem = new Filesystem(); |
||
| 22 | $asset = $request->offsetGet('asset'); |
||
| 23 | |||
| 24 | try { |
||
| 25 | $path = lara_gen_adv_dist_path($asset); |
||
| 26 | |||
| 27 | return (new Response( |
||
| 28 | $fileSystem->get($path), |
||
| 29 | 200, |
||
| 30 | [ |
||
| 31 | 'Content-Type' => pathinfo($asset, PATHINFO_EXTENSION) == 'css' |
||
| 32 | ? 'text/css' |
||
| 33 | : 'application/javascript', |
||
| 34 | ] |
||
| 35 | ))->setSharedMaxAge(31536000) |
||
| 36 | ->setMaxAge(31536000) |
||
| 37 | ->setExpires(new DateTime('+1 year')); |
||
| 38 | } catch (FileNotFoundException $e) { |
||
| 39 | return new Response($e->getMessage(), 404); |
||
| 40 | } |
||
| 43 |