@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function process(string $controller, string $action, array $parameters, CoreInterface $core) |
| 40 | 40 | { |
| 41 | - foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) { |
|
| 42 | - if (isset($parameters[$parameter])) { |
|
| 41 | + foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){ |
|
| 42 | + if (isset($parameters[$parameter])){ |
|
| 43 | 43 | continue; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** @var FilterInterface $filter */ |
| 47 | 47 | $filter = $this->container->get($filterClass); |
| 48 | 48 | |
| 49 | - if (!$filter->isValid()) { |
|
| 49 | + if (!$filter->isValid()){ |
|
| 50 | 50 | // add more options in future |
| 51 | 51 | return [ |
| 52 | 52 | 'status' => 400, |
@@ -68,23 +68,23 @@ discard block |
||
| 68 | 68 | private function getDeclaredFilters(string $controller, string $action): array |
| 69 | 69 | { |
| 70 | 70 | $key = sprintf("%s:%s", $controller, $action); |
| 71 | - if (array_key_exists($key, $this->filterCache)) { |
|
| 71 | + if (array_key_exists($key, $this->filterCache)){ |
|
| 72 | 72 | return $this->filterCache[$key]; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $this->filterCache[$key] = []; |
| 76 | - try { |
|
| 76 | + try{ |
|
| 77 | 77 | $method = new \ReflectionMethod($controller, $action); |
| 78 | - } catch (\ReflectionException $e) { |
|
| 78 | + }catch (\ReflectionException $e){ |
|
| 79 | 79 | return []; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - foreach ($method->getParameters() as $parameter) { |
|
| 83 | - if ($parameter->getClass() === null) { |
|
| 82 | + foreach ($method->getParameters() as $parameter){ |
|
| 83 | + if ($parameter->getClass() === null){ |
|
| 84 | 84 | continue; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if ($parameter->getClass()->implementsInterface(FilterInterface::class)) { |
|
| 87 | + if ($parameter->getClass()->implementsInterface(FilterInterface::class)){ |
|
| 88 | 88 | $this->filterCache[$key][$parameter->getName()] = $parameter->getClass()->getName(); |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | public function process(string $controller, string $action, array $parameters, CoreInterface $core) |
| 40 | 40 | { |
| 41 | 41 | // todo: support singular ID |
| 42 | - foreach ($this->getDeclaredEntities($controller, $action) as $parameter => $role) { |
|
| 43 | - if (!isset($parameters[$parameter])) { |
|
| 42 | + foreach ($this->getDeclaredEntities($controller, $action) as $parameter => $role){ |
|
| 43 | + if (!isset($parameters[$parameter])){ |
|
| 44 | 44 | throw new ControllerException( |
| 45 | 45 | "Entity `{$role}` can not be found", |
| 46 | 46 | ControllerException::NOT_FOUND |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $entity = $this->orm->getRepository($role)->findByPK($parameters[$parameter]); |
| 51 | - if ($entity === null) { |
|
| 51 | + if ($entity === null){ |
|
| 52 | 52 | throw new ControllerException( |
| 53 | 53 | "Entity `{$role}` can not be found", |
| 54 | 54 | ControllerException::NOT_FOUND |
@@ -69,23 +69,23 @@ discard block |
||
| 69 | 69 | private function getDeclaredEntities(string $controller, string $action): array |
| 70 | 70 | { |
| 71 | 71 | $key = sprintf("%s:%s", $controller, $action); |
| 72 | - if (array_key_exists($key, $this->entityCache)) { |
|
| 72 | + if (array_key_exists($key, $this->entityCache)){ |
|
| 73 | 73 | return $this->entityCache[$key]; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $this->entityCache[$key] = []; |
| 77 | - try { |
|
| 77 | + try{ |
|
| 78 | 78 | $method = new \ReflectionMethod($controller, $action); |
| 79 | - } catch (\ReflectionException $e) { |
|
| 79 | + }catch (\ReflectionException $e){ |
|
| 80 | 80 | return []; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - foreach ($method->getParameters() as $parameter) { |
|
| 84 | - if ($parameter->getClass() === null) { |
|
| 83 | + foreach ($method->getParameters() as $parameter){ |
|
| 84 | + if ($parameter->getClass() === null){ |
|
| 85 | 85 | continue; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ($this->orm->getSchema()->defines($parameter->getClass()->getName())) { |
|
| 88 | + if ($this->orm->getSchema()->defines($parameter->getClass()->getName())){ |
|
| 89 | 89 | $this->entityCache[$key][$parameter->getName()] = $parameter->getClass()->getName(); |
| 90 | 90 | } |
| 91 | 91 | } |