@@ -20,7 +20,7 @@ |
||
20 | 20 | * FormProcessor constructor. |
21 | 21 | * |
22 | 22 | * @param FormFactoryInterface $factory |
23 | - * @param string|FormTypeInterface $form |
|
23 | + * @param \Symfony\Component\Form\FormInterface $form |
|
24 | 24 | * @param array $options |
25 | 25 | */ |
26 | 26 | public function __construct(FormFactoryInterface $factory, $form, array $options = []) |
@@ -24,6 +24,9 @@ |
||
24 | 24 | $this->mapper = $mapper; |
25 | 25 | } |
26 | 26 | |
27 | + /** |
|
28 | + * @param string $className |
|
29 | + */ |
|
27 | 30 | public function createFormForClass($className) |
28 | 31 | { |
29 | 32 | $form = $this->factory->create(); |
@@ -191,6 +191,9 @@ |
||
191 | 191 | return $this->container->getDefinition('cruds.api.router_loader'); |
192 | 192 | } |
193 | 193 | |
194 | + /** |
|
195 | + * @param string $name |
|
196 | + */ |
|
194 | 197 | private function normalize($name) |
195 | 198 | { |
196 | 199 | return str_replace('-', '_', $name); |
@@ -9,7 +9,6 @@ |
||
9 | 9 | use ScayTrase\Api\Cruds\Controller\ReadController; |
10 | 10 | use ScayTrase\Api\Cruds\Controller\SearchController; |
11 | 11 | use ScayTrase\Api\Cruds\Controller\UpdateController; |
12 | -use ScayTrase\Api\Cruds\PropertyAccessProcessor; |
|
13 | 12 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
14 | 13 | use Symfony\Component\DependencyInjection\Definition; |
15 | 14 | use Symfony\Component\DependencyInjection\DefinitionDecorator; |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | $actionConfig['name'] = $name; |
55 | 55 | $actionConfig['class'] = $class; |
56 | 56 | $actionConfig['repository'] = $repositoryDefinition; |
57 | - $actionConfig['path'] = $prefix . $actionConfig['path']; |
|
57 | + $actionConfig['path'] = $prefix.$actionConfig['path']; |
|
58 | 58 | $actionConfig['manager'] = $manager; |
59 | - $function = new \ReflectionMethod($this, 'register' . ucfirst($action) . 'Action'); |
|
59 | + $function = new \ReflectionMethod($this, 'register'.ucfirst($action).'Action'); |
|
60 | 60 | $args = []; |
61 | 61 | |
62 | 62 | foreach ($function->getParameters() as $parameter) { |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | ); |
97 | 97 | $definition->setPublic(true); |
98 | 98 | |
99 | - $controllerId = $this->normalize('cruds.api.generated.' . $name . '.create_controller'); |
|
99 | + $controllerId = $this->normalize('cruds.api.generated.'.$name.'.create_controller'); |
|
100 | 100 | $this->container->setDefinition($controllerId, $definition); |
101 | 101 | |
102 | 102 | $this->getLoaderDefinition()->addMethodCall( |
103 | 103 | 'addRoute', |
104 | 104 | [ |
105 | - $this->normalize('cruds_api_' . $name . '_create'), |
|
105 | + $this->normalize('cruds_api_'.$name.'_create'), |
|
106 | 106 | $path, |
107 | - $controllerId . ':' . CreateController::ACTION, |
|
107 | + $controllerId.':'.CreateController::ACTION, |
|
108 | 108 | ['POST'], |
109 | 109 | ] |
110 | 110 | ); |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | ] |
121 | 121 | ); |
122 | 122 | |
123 | - $controllerId = $this->normalize('cruds_api_' . $name . '_read_controller'); |
|
123 | + $controllerId = $this->normalize('cruds_api_'.$name.'_read_controller'); |
|
124 | 124 | $this->container->setDefinition($controllerId, $definition); |
125 | 125 | |
126 | 126 | $this->getLoaderDefinition()->addMethodCall( |
127 | 127 | 'addRoute', |
128 | 128 | [ |
129 | - $this->normalize('cruds_api_' . $name . '_read'), |
|
129 | + $this->normalize('cruds_api_'.$name.'_read'), |
|
130 | 130 | $path, |
131 | - $controllerId . ':' . ReadController::ACTION, |
|
131 | + $controllerId.':'.ReadController::ACTION, |
|
132 | 132 | ['GET'], |
133 | 133 | ] |
134 | 134 | ); |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | ] |
153 | 153 | ); |
154 | 154 | |
155 | - $controllerId = $this->normalize('cruds_api_' . $name . '_update_controller'); |
|
155 | + $controllerId = $this->normalize('cruds_api_'.$name.'_update_controller'); |
|
156 | 156 | $this->container->setDefinition($controllerId, $definition); |
157 | 157 | |
158 | 158 | $this->getLoaderDefinition()->addMethodCall( |
159 | 159 | 'addRoute', |
160 | 160 | [ |
161 | - $this->normalize('cruds_api_' . $name . '_update'), |
|
161 | + $this->normalize('cruds_api_'.$name.'_update'), |
|
162 | 162 | $path, |
163 | - $controllerId . ':' . UpdateController::ACTION, |
|
163 | + $controllerId.':'.UpdateController::ACTION, |
|
164 | 164 | ['POST'], |
165 | 165 | ] |
166 | 166 | ); |
@@ -177,15 +177,15 @@ discard block |
||
177 | 177 | ] |
178 | 178 | ); |
179 | 179 | |
180 | - $controllerId = $this->normalize('cruds_api_' . $name . '_delete_controller'); |
|
180 | + $controllerId = $this->normalize('cruds_api_'.$name.'_delete_controller'); |
|
181 | 181 | $this->container->setDefinition($controllerId, $definition); |
182 | 182 | |
183 | 183 | $this->getLoaderDefinition()->addMethodCall( |
184 | 184 | 'addRoute', |
185 | 185 | [ |
186 | - $this->normalize('cruds_api_' . $name . '_delete'), |
|
186 | + $this->normalize('cruds_api_'.$name.'_delete'), |
|
187 | 187 | $path, |
188 | - $controllerId . ':' . DeleteController::ACTION, |
|
188 | + $controllerId.':'.DeleteController::ACTION, |
|
189 | 189 | ['POST'], |
190 | 190 | ] |
191 | 191 | ); |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | ] |
209 | 209 | ); |
210 | 210 | |
211 | - $controllerId = $this->normalize('cruds_api_' . $name . '_search_controller'); |
|
211 | + $controllerId = $this->normalize('cruds_api_'.$name.'_search_controller'); |
|
212 | 212 | $this->container->setDefinition($controllerId, $definition); |
213 | 213 | |
214 | 214 | $this->getLoaderDefinition()->addMethodCall( |
215 | 215 | 'addRoute', |
216 | 216 | [ |
217 | - $this->normalize('cruds_api_' . $name . '_search'), |
|
217 | + $this->normalize('cruds_api_'.$name.'_search'), |
|
218 | 218 | $path, |
219 | - $controllerId . ':' . SearchController::ACTION, |
|
219 | + $controllerId.':'.SearchController::ACTION, |
|
220 | 220 | ['GET', 'POST'], |
221 | 221 | ] |
222 | 222 | ); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | ->beforeNormalization() |
65 | 65 | ->ifArray() |
66 | 66 | ->then( |
67 | - function (array $v) { |
|
67 | + function(array $v) { |
|
68 | 68 | if (array_keys($v) !== range(0, count($v) - 1)) { |
69 | 69 | return $v; |
70 | 70 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | ->beforeNormalization() |
118 | 118 | ->ifString() |
119 | 119 | ->then( |
120 | - function ($v) { |
|
120 | + function($v) { |
|
121 | 121 | return [$v]; |
122 | 122 | } |
123 | 123 | ) |
@@ -11,13 +11,13 @@ |
||
11 | 11 | /** {@inheritdoc} */ |
12 | 12 | public function registerContainerConfiguration(LoaderInterface $loader) |
13 | 13 | { |
14 | - return $loader->load(__DIR__ . '/config.yml'); |
|
14 | + return $loader->load(__DIR__.'/config.yml'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | protected function buildContainer() |
18 | 18 | { |
19 | 19 | $container = parent::buildContainer(); |
20 | - $container->addResource(new FileResource(__DIR__ . '/config.yml')); |
|
20 | + $container->addResource(new FileResource(__DIR__.'/config.yml')); |
|
21 | 21 | |
22 | 22 | return $container; |
23 | 23 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | implode( |
37 | 37 | "\n\n", |
38 | 38 | array_map( |
39 | - function ($l) { |
|
39 | + function($l) { |
|
40 | 40 | return implode("\n\n", $l); |
41 | 41 | }, |
42 | 42 | $errors |
@@ -11,13 +11,13 @@ |
||
11 | 11 | /** {@inheritdoc} */ |
12 | 12 | public function registerContainerConfiguration(LoaderInterface $loader) |
13 | 13 | { |
14 | - return $loader->load(__DIR__ . '/config.yml'); |
|
14 | + return $loader->load(__DIR__.'/config.yml'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | protected function buildContainer() |
18 | 18 | { |
19 | 19 | $container = parent::buildContainer(); |
20 | - $container->addResource(new FileResource(__DIR__ . '/config.yml')); |
|
20 | + $container->addResource(new FileResource(__DIR__.'/config.yml')); |
|
21 | 21 | |
22 | 22 | return $container; |
23 | 23 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | * @param int $limit |
41 | 41 | * @param int $offset |
42 | 42 | * |
43 | - * @return object[] |
|
43 | + * @return \Doctrine\Common\Collections\Collection |
|
44 | 44 | * @throws CriteriaConfigurationException |
45 | 45 | */ |
46 | 46 | public function findAction(array $criteria, array $order = [], $limit = 10, $offset = 0) |
@@ -115,6 +115,9 @@ discard block |
||
115 | 115 | return array_shift($identifier); |
116 | 116 | } |
117 | 117 | |
118 | + /** |
|
119 | + * @param string $attribute |
|
120 | + */ |
|
118 | 121 | private function getObjectMetadata($object, $attribute) |
119 | 122 | { |
120 | 123 | $class = get_class($object); |
@@ -132,6 +135,9 @@ discard block |
||
132 | 135 | return $metadata; |
133 | 136 | } |
134 | 137 | |
138 | + /** |
|
139 | + * @param string $attribute |
|
140 | + */ |
|
135 | 141 | private function getAssocMetadata(ClassMetadataInterface $metadata, $attribute) |
136 | 142 | { |
137 | 143 | $assoc = $metadata->getAssociationTargetClass($attribute); |
@@ -139,9 +139,9 @@ |
||
139 | 139 | |
140 | 140 | if (null === $assocManager) { |
141 | 141 | throw new \LogicException($metadata->getName() . |
142 | - '::$' . |
|
143 | - $attribute . |
|
144 | - ' references non-existent managed entity'); |
|
142 | + '::$' . |
|
143 | + $attribute . |
|
144 | + ' references non-existent managed entity'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | return $assocManager->getClassMetadata($assoc); |
@@ -138,9 +138,9 @@ |
||
138 | 138 | $assocManager = $this->registry->getManagerForClass($assoc); |
139 | 139 | |
140 | 140 | if (null === $assocManager) { |
141 | - throw new \LogicException($metadata->getName() . |
|
142 | - '::$' . |
|
143 | - $attribute . |
|
141 | + throw new \LogicException($metadata->getName(). |
|
142 | + '::$'. |
|
143 | + $attribute. |
|
144 | 144 | ' references non-existent managed entity'); |
145 | 145 | } |
146 | 146 |