| @@ 65-84 (lines=20) @@ | ||
| 62 | * |
|
| 63 | * @return Mediafile |
|
| 64 | */ |
|
| 65 | protected function findMediafileModel(int $id): Mediafile |
|
| 66 | { |
|
| 67 | $modelObject = new Mediafile(); |
|
| 68 | ||
| 69 | if (!method_exists($modelObject, 'findOne')) { |
|
| 70 | $class = (new\ReflectionClass($modelObject)); |
|
| 71 | throw new UnknownMethodException('Method findOne does not exists in ' . $class->getNamespaceName() . '\\' . |
|
| 72 | $class->getShortName().' class.'); |
|
| 73 | } |
|
| 74 | ||
| 75 | $result = call_user_func([ |
|
| 76 | $modelObject, |
|
| 77 | 'findOne', |
|
| 78 | ], $id); |
|
| 79 | ||
| 80 | if ($result !== null) { |
|
| 81 | return $result; |
|
| 82 | } |
|
| 83 | ||
| 84 | throw new NotFoundHttpException('The requested page does not exist.'); |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| @@ 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 | /** |
|