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( |
||
73 | |||
74 | /** |
||
75 | * This action applies a given filter to a given image, saves the image and redirects the browser to the stored |
||
76 | * image. |
||
77 | * |
||
78 | * The resulting image is cached so subsequent requests will redirect to the cached image instead applying the |
||
79 | * filter and storing the image again. |
||
80 | * |
||
81 | * @param Request $request |
||
82 | * @param string $path |
||
83 | * @param string $filter |
||
84 | * |
||
85 | * @throws RuntimeException |
||
86 | * @throws NotFoundHttpException |
||
87 | * |
||
88 | * @return RedirectResponse |
||
89 | */ |
||
90 | public function filterAction(Request $request, $path, $filter) |
||
104 | |||
105 | /** |
||
106 | * This action applies a given filter -merged with additional runtime filters- to a given image, saves the image and |
||
107 | * redirects the browser to the stored image. |
||
108 | * |
||
109 | * The resulting image is cached so subsequent requests will redirect to the cached image instead applying the |
||
110 | * filter and storing the image again. |
||
111 | * |
||
112 | * @param Request $request |
||
113 | * @param string $hash |
||
114 | * @param string $path |
||
115 | * @param string $filter |
||
116 | * |
||
117 | * @throws RuntimeException |
||
118 | * @throws BadRequestHttpException |
||
119 | * @throws NotFoundHttpException |
||
120 | * |
||
121 | * @return RedirectResponse |
||
122 | */ |
||
123 | public function filterRuntimeAction(Request $request, $hash, $path, $filter) |
||
152 | |||
153 | /** |
||
154 | * @param \Closure $url |
||
155 | * @param string $path |
||
156 | * @param string $filter |
||
157 | * @param string|null $hash |
||
158 | * |
||
159 | * @return RedirectResponse |
||
160 | */ |
||
161 | private function createRedirectResponse(\Closure $url, string $path, string $filter, ?string $hash = null): RedirectResponse |
||
181 | |||
182 | /** |
||
183 | * @param Request $request |
||
184 | * |
||
185 | * @return bool |
||
186 | */ |
||
187 | private function isSupportWebp(Request $request): bool |
||
191 | } |
||
192 |
If you suppress an error, we recommend checking for the error condition explicitly: