1 | <?php |
||
27 | class ImagineController |
||
28 | { |
||
29 | /** |
||
30 | * @var FilterService |
||
31 | */ |
||
32 | private $filterService; |
||
33 | |||
34 | /** |
||
35 | * @var DataManager |
||
36 | */ |
||
37 | private $dataManager; |
||
38 | |||
39 | /** |
||
40 | * @var SignerInterface |
||
41 | */ |
||
42 | private $signer; |
||
43 | |||
44 | /** |
||
45 | * @var ControllerConfig |
||
46 | */ |
||
47 | private $controllerConfig; |
||
48 | |||
49 | /** |
||
50 | * @param FilterService $filterService |
||
51 | * @param DataManager $dataManager |
||
52 | * @param SignerInterface $signer |
||
53 | * @param ControllerConfig|null $controllerConfig |
||
54 | */ |
||
55 | public function __construct(FilterService $filterService, DataManager $dataManager, SignerInterface $signer, ?ControllerConfig $controllerConfig = null) |
||
69 | |||
70 | /** |
||
71 | * This action applies a given filter to a given image, saves the image and redirects the browser to the stored |
||
72 | * image. |
||
73 | * |
||
74 | * The resulting image is cached so subsequent requests will redirect to the cached image instead applying the |
||
75 | * filter and storing the image again. |
||
76 | * |
||
77 | * @param Request $request |
||
78 | * @param string $path |
||
79 | * @param string $filter |
||
80 | * |
||
81 | * @throws RuntimeException |
||
82 | * @throws NotFoundHttpException |
||
83 | * |
||
84 | * @return RedirectResponse |
||
85 | */ |
||
86 | public function filterAction(Request $request, $path, $filter) |
||
100 | |||
101 | /** |
||
102 | * This action applies a given filter -merged with additional runtime filters- to a given image, saves the image and |
||
103 | * redirects the browser to the stored image. |
||
104 | * |
||
105 | * The resulting image is cached so subsequent requests will redirect to the cached image instead applying the |
||
106 | * filter and storing the image again. |
||
107 | * |
||
108 | * @param Request $request |
||
109 | * @param string $hash |
||
110 | * @param string $path |
||
111 | * @param string $filter |
||
112 | * |
||
113 | * @throws RuntimeException |
||
114 | * @throws BadRequestHttpException |
||
115 | * @throws NotFoundHttpException |
||
116 | * |
||
117 | * @return RedirectResponse |
||
118 | */ |
||
119 | public function filterRuntimeAction(Request $request, $hash, $path, $filter) |
||
148 | |||
149 | /** |
||
150 | * @param \Closure $url |
||
151 | * @param string $path |
||
152 | * @param string $filter |
||
153 | * @param string|null $hash |
||
154 | * |
||
155 | * @return RedirectResponse |
||
156 | */ |
||
157 | private function createRedirectResponse(\Closure $url, string $path, string $filter, ?string $hash = null): RedirectResponse |
||
177 | |||
178 | /** |
||
179 | * @param Request $request |
||
180 | * |
||
181 | * @return bool |
||
182 | */ |
||
183 | private function isSupportWebp(Request $request) |
||
187 | } |
||
188 |
If you suppress an error, we recommend checking for the error condition explicitly: