@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | $entities = $this->getDeclaredEntities($controller, $action); |
47 | 47 | |
48 | 48 | $contextCandidates = []; |
49 | - foreach ($entities as $parameter => $role) { |
|
49 | + foreach ($entities as $parameter => $role){ |
|
50 | 50 | $value = $this->getParameter($parameter, $parameters, count($entities) === 1); |
51 | - if ($value === null) { |
|
51 | + if ($value === null){ |
|
52 | 52 | throw new ControllerException( |
53 | 53 | "Entity `{$parameter}` can not be found", |
54 | 54 | ControllerException::NOT_FOUND |
55 | 55 | ); |
56 | 56 | } |
57 | 57 | |
58 | - if (is_object($value)) { |
|
59 | - if ($this->orm->getHeap()->has($value)) { |
|
58 | + if (is_object($value)){ |
|
59 | + if ($this->orm->getHeap()->has($value)){ |
|
60 | 60 | $contextCandidates[] = $value; |
61 | 61 | } |
62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | $entity = $this->resolveEntity($role, $value); |
68 | - if ($entity === null) { |
|
68 | + if ($entity === null){ |
|
69 | 69 | throw new ControllerException( |
70 | 70 | "Entity `{$parameter}` can not be found", |
71 | 71 | ControllerException::NOT_FOUND |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $contextCandidates[] = $entity; |
77 | 77 | } |
78 | 78 | |
79 | - if (!isset($parameters['@context']) && count($contextCandidates) === 1) { |
|
79 | + if (!isset($parameters['@context']) && count($contextCandidates) === 1){ |
|
80 | 80 | $parameters['@context'] = current($contextCandidates); |
81 | 81 | } |
82 | 82 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | protected function getParameter(string $role, array $parameters, bool $useDefault = false) |
93 | 93 | { |
94 | - if (!$useDefault) { |
|
94 | + if (!$useDefault){ |
|
95 | 95 | return $parameters[$role] ?? null; |
96 | 96 | } |
97 | 97 | |
@@ -116,23 +116,23 @@ discard block |
||
116 | 116 | private function getDeclaredEntities(string $controller, string $action): array |
117 | 117 | { |
118 | 118 | $key = sprintf('%s:%s', $controller, $action); |
119 | - if (array_key_exists($key, $this->cache)) { |
|
119 | + if (array_key_exists($key, $this->cache)){ |
|
120 | 120 | return $this->cache[$key]; |
121 | 121 | } |
122 | 122 | |
123 | 123 | $this->cache[$key] = []; |
124 | - try { |
|
124 | + try{ |
|
125 | 125 | $method = new \ReflectionMethod($controller, $action); |
126 | - } catch (\ReflectionException $e) { |
|
126 | + }catch (\ReflectionException $e){ |
|
127 | 127 | return []; |
128 | 128 | } |
129 | 129 | |
130 | - foreach ($method->getParameters() as $parameter) { |
|
131 | - if ($parameter->getClass() === null) { |
|
130 | + foreach ($method->getParameters() as $parameter){ |
|
131 | + if ($parameter->getClass() === null){ |
|
132 | 132 | continue; |
133 | 133 | } |
134 | 134 | |
135 | - if ($this->orm->getSchema()->defines($parameter->getClass()->getName())) { |
|
135 | + if ($this->orm->getSchema()->defines($parameter->getClass()->getName())){ |
|
136 | 136 | $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($parameter->getClass()->getName()); |
137 | 137 | } |
138 | 138 | } |