1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VideoGamesRecords\CoreBundle\Controller; |
4
|
|
|
|
5
|
|
|
use League\Flysystem\FilesystemException; |
6
|
|
|
use League\Flysystem\FilesystemOperator; |
7
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache; |
|
|
|
|
8
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
9
|
|
|
use Symfony\Component\HttpFoundation\StreamedResponse; |
10
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
11
|
|
|
use VideoGamesRecords\CoreBundle\Entity\Serie; |
12
|
|
|
use VideoGamesRecords\CoreBundle\Repository\GameRepository; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class SerieController |
16
|
|
|
* @Route("/serie") |
17
|
|
|
*/ |
18
|
|
|
class SerieController extends AbstractController |
19
|
|
|
{ |
20
|
|
|
private FilesystemOperator $appStorage; |
21
|
|
|
|
22
|
|
|
private string $prefix = 'serie/picture/'; |
23
|
|
|
|
24
|
|
|
public function __construct(FilesystemOperator $appStorage) |
25
|
|
|
{ |
26
|
|
|
$this->appStorage = $appStorage; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @Route(path="/{id}/picture", requirements={"id": "[1-9]\d*"}, name="vgr_core_serie_picture", methods={"GET"}) |
32
|
|
|
* @Cache(expires="+30 days") |
33
|
|
|
* @param Serie $serie |
34
|
|
|
* @return StreamedResponse |
35
|
|
|
* @throws FilesystemException |
36
|
|
|
*/ |
37
|
|
|
public function pictureAction(Serie $serie): StreamedResponse |
38
|
|
|
{ |
39
|
|
|
$path = $this->prefix . $serie->getPicture(); |
40
|
|
|
if (!$this->appStorage->fileExists($path)) { |
41
|
|
|
$path = $this->prefix . 'default.png'; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$stream = $this->appStorage->readStream($path); |
45
|
|
|
return new StreamedResponse(function() use ($stream) { |
46
|
|
|
fpassthru($stream); |
47
|
|
|
}, 200, ['Content-Type' => 'image/png']); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths