1 | <?php |
||
26 | class ImagineController |
||
27 | { |
||
28 | /** |
||
29 | * @var FilterService |
||
30 | */ |
||
31 | private $filterService; |
||
32 | |||
33 | /** |
||
34 | * @var DataManager |
||
35 | */ |
||
36 | private $dataManager; |
||
37 | |||
38 | /** |
||
39 | * @var SignerInterface |
||
40 | */ |
||
41 | private $signer; |
||
42 | |||
43 | /** |
||
44 | * @var ControllerConfig |
||
45 | */ |
||
46 | private $controllerConfig; |
||
47 | |||
48 | /** |
||
49 | * @param FilterService $filterService |
||
50 | * @param DataManager $dataManager |
||
51 | * @param SignerInterface $signer |
||
52 | * @param ControllerConfig|null $controllerConfig |
||
53 | */ |
||
54 | public function __construct(FilterService $filterService, DataManager $dataManager, SignerInterface $signer, ?ControllerConfig $controllerConfig = null) |
||
68 | |||
69 | /** |
||
70 | * This action applies a given filter to a given image, saves the image and redirects the browser to the stored |
||
71 | * image. |
||
72 | * |
||
73 | * The resulting image is cached so subsequent requests will redirect to the cached image instead applying the |
||
74 | * filter and storing the image again. |
||
75 | * |
||
76 | * @param Request $request |
||
77 | * @param string $path |
||
78 | * @param string $filter |
||
79 | * |
||
80 | * @throws RuntimeException |
||
81 | * @throws NotFoundHttpException |
||
82 | * |
||
83 | * @return RedirectResponse |
||
84 | */ |
||
85 | public function filterAction(Request $request, $path, $filter) |
||
94 | |||
95 | /** |
||
96 | * This action applies a given filter -merged with additional runtime filters- to a given image, saves the image and |
||
97 | * redirects the browser to the stored image. |
||
98 | * |
||
99 | * The resulting image is cached so subsequent requests will redirect to the cached image instead applying the |
||
100 | * filter and storing the image again. |
||
101 | * |
||
102 | * @param Request $request |
||
103 | * @param string $hash |
||
104 | * @param string $path |
||
105 | * @param string $filter |
||
106 | * |
||
107 | * @throws RuntimeException |
||
108 | * @throws BadRequestHttpException |
||
109 | * @throws NotFoundHttpException |
||
110 | * |
||
111 | * @return RedirectResponse |
||
112 | */ |
||
113 | public function filterRuntimeAction(Request $request, $hash, $path, $filter) |
||
136 | |||
137 | /** |
||
138 | * @param \Closure $url |
||
139 | * @param string $path |
||
140 | * @param string $filter |
||
141 | * @param null|string $hash |
||
142 | * |
||
143 | * @return RedirectResponse |
||
144 | */ |
||
145 | private function createRedirectResponse(\Closure $url, string $path, string $filter, ?string $hash = null): RedirectResponse |
||
165 | } |
||
166 |
If you suppress an error, we recommend checking for the error condition explicitly: