@@ 305-328 (lines=24) @@ | ||
302 | * |
|
303 | * @return Album |
|
304 | */ |
|
305 | protected function findModel($key): Album |
|
306 | { |
|
307 | if (null === $key) { |
|
308 | throw new BadRequestHttpException('Key parameter is not defined in findModel method.'); |
|
309 | } |
|
310 | ||
311 | $modelObject = $this->getNewModel(); |
|
312 | ||
313 | if (!method_exists($modelObject, 'findOne')) { |
|
314 | $class = (new\ReflectionClass($modelObject)); |
|
315 | throw new UnknownMethodException('Method findOne does not exists in ' . $class->getNamespaceName() . '\\' . |
|
316 | $class->getShortName().' class.'); |
|
317 | } |
|
318 | ||
319 | $result = call_user_func([ |
|
320 | $modelObject, |
|
321 | 'findOne', |
|
322 | ], $key); |
|
323 | ||
324 | if ($result !== null) { |
|
325 | return $result; |
|
326 | } |
|
327 | ||
328 | throw new NotFoundHttpException('The requested page does not exist.'); |
|
329 | } |
|
330 | ||
331 | /** |
@@ 85-104 (lines=20) @@ | ||
82 | * |
|
83 | * @return Mediafile |
|
84 | */ |
|
85 | protected function findMediafileModel(int $id): Mediafile |
|
86 | { |
|
87 | $modelObject = new Mediafile(); |
|
88 | ||
89 | if (!method_exists($modelObject, 'findOne')) { |
|
90 | $class = (new\ReflectionClass($modelObject)); |
|
91 | throw new UnknownMethodException('Method findOne does not exists in ' . $class->getNamespaceName() . '\\' . |
|
92 | $class->getShortName().' class.'); |
|
93 | } |
|
94 | ||
95 | $result = call_user_func([ |
|
96 | $modelObject, |
|
97 | 'findOne', |
|
98 | ], $id); |
|
99 | ||
100 | if ($result !== null) { |
|
101 | return $result; |
|
102 | } |
|
103 | ||
104 | throw new NotFoundHttpException('The requested page does not exist.'); |
|
105 | } |
|
106 | ||
107 | /** |