@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function generateRemotingApi() { |
49 | 49 | $list = array(); |
50 | - foreach($this->remotingBundles as $bundle) { |
|
50 | + foreach ($this->remotingBundles as $bundle) { |
|
51 | 51 | $controllers = array(); |
52 | 52 | $bundleRef = new \ReflectionClass($bundle); |
53 | 53 | $controllerDir = new Finder(); |
54 | 54 | $controllerDir->files()->in(dirname($bundleRef->getFileName()).'/Controller/')->name('/.*Controller\.php$/'); |
55 | - foreach($controllerDir as $controllerFile) { |
|
56 | - $controller = $bundleRef->getNamespaceName() . "\\Controller\\" . substr($controllerFile->getFilename(), 0, -4); |
|
55 | + foreach ($controllerDir as $controllerFile) { |
|
56 | + $controller = $bundleRef->getNamespaceName()."\\Controller\\".substr($controllerFile->getFilename(), 0, -4); |
|
57 | 57 | $controllerRef = new \ReflectionClass($controller); |
58 | 58 | foreach ($controllerRef->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { |
59 | 59 | /** @var $methodDirectAnnotation Direct */ |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $modelName = str_replace("\\", ".", $classRef->getName()); |
86 | 86 | } |
87 | 87 | if ($classModelAnnotation->generateAsBase === true) { |
88 | - $modelName = substr($modelName, 0, strrpos($modelName, '.')+1) . 'Base' . substr($modelName, strrpos($modelName, '.')+1); |
|
88 | + $modelName = substr($modelName, 0, strrpos($modelName, '.') + 1).'Base'.substr($modelName, strrpos($modelName, '.') + 1); |
|
89 | 89 | } |
90 | 90 | $structure = array( |
91 | 91 | 'name' => $modelName, |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | if (strpos(get_class($annotation), 'Symfony\Component\Validator\Constraints') === 0) { |
155 | 155 | $validators[] = array_merge( |
156 | 156 | array('field'=>$this->convertNaming($property->getName())), |
157 | - $this->getValidator(substr($className, 40),$annotation) |
|
157 | + $this->getValidator(substr($className, 40), $annotation) |
|
158 | 158 | ); |
159 | 159 | } |
160 | - switch(get_class($annotation)) { |
|
160 | + switch (get_class($annotation)) { |
|
161 | 161 | case 'Tpg\ExtjsBundle\Annotation\Model\Field': |
162 | 162 | $field['type'] = $annotation->type; |
163 | 163 | break; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $format = explode(',', |
211 | 211 | substr( |
212 | 212 | $type, |
213 | - stripos($type, '<')+2, |
|
213 | + stripos($type, '<') + 2, |
|
214 | 214 | -2 |
215 | 215 | ) |
216 | 216 | ); |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | $field['type'] = $this->getEntityColumnType($association['entity'], $annotation->referencedColumnName); |
275 | 275 | $field['useNull'] = true; |
276 | 276 | $association['key'] = $this->convertNaming($annotation->name); |
277 | - $field['mapping'] = $property->getName() . '.' . $annotation->referencedColumnName; |
|
277 | + $field['mapping'] = $property->getName().'.'.$annotation->referencedColumnName; |
|
278 | 278 | break; |
279 | 279 | } |
280 | 280 | } |
281 | - if($fieldIsId){ |
|
281 | + if ($fieldIsId) { |
|
282 | 282 | $structure['idProperty'] = $field['name']; |
283 | 283 | } |
284 | 284 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @throws \Exception |
311 | 311 | * @return string |
312 | 312 | */ |
313 | - protected function tryToGetJoinColumnNameOfMappedBy($annotation){ |
|
313 | + protected function tryToGetJoinColumnNameOfMappedBy($annotation) { |
|
314 | 314 | $annotation = $this->tryToGetJoinColumnAnnotationOfMappedBy($annotation); |
315 | 315 | if ($annotation !== null) { |
316 | 316 | if ($annotation instanceof JoinColumn) { |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | * @param OneToMany $annotation |
331 | 331 | * @return null|Annotation |
332 | 332 | */ |
333 | - protected function tryToGetJoinColumnAnnotationOfMappedBy($annotation){ |
|
333 | + protected function tryToGetJoinColumnAnnotationOfMappedBy($annotation) { |
|
334 | 334 | $result = null; |
335 | - if($annotation->targetEntity && $annotation->mappedBy) { |
|
335 | + if ($annotation->targetEntity && $annotation->mappedBy) { |
|
336 | 336 | $result = $this->getAnnotation( |
337 | 337 | $annotation->targetEntity, |
338 | 338 | $annotation->mappedBy, |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | */ |
459 | 459 | protected function getValidator($name, $annotation) { |
460 | 460 | $validate = array(); |
461 | - switch($name) { |
|
461 | + switch ($name) { |
|
462 | 462 | case 'NotBlank': |
463 | 463 | case 'NotNull': |
464 | 464 | $validate['type'] = "presence"; |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | break; |
469 | 469 | case 'Length': |
470 | 470 | $validate['type'] = "length"; |
471 | - $validate['max'] = (int)$annotation->max; |
|
472 | - $validate['min'] = (int)$annotation->min; |
|
471 | + $validate['max'] = (int) $annotation->max; |
|
472 | + $validate['min'] = (int) $annotation->min; |
|
473 | 473 | break; |
474 | 474 | case 'Regex': |
475 | 475 | if ($annotation->match) { |
@@ -482,9 +482,9 @@ discard block |
||
482 | 482 | case 'MinLength': |
483 | 483 | $validate['type'] = "length"; |
484 | 484 | if ($name == "MaxLength") { |
485 | - $validate['max'] = (int)$annotation->limit; |
|
485 | + $validate['max'] = (int) $annotation->limit; |
|
486 | 486 | } else { |
487 | - $validate['min'] = (int)$annotation->limit; |
|
487 | + $validate['min'] = (int) $annotation->limit; |
|
488 | 488 | } |
489 | 489 | break; |
490 | 490 | case 'Choice': |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | } |
529 | 529 | } |
530 | 530 | } |
531 | - foreach(array_reverse($duplicateList) as $index) { |
|
531 | + foreach (array_reverse($duplicateList) as $index) { |
|
532 | 532 | unset($list[$index]); |
533 | 533 | } |
534 | 534 | } |
@@ -2,20 +2,20 @@ |
||
2 | 2 | |
3 | 3 | namespace {{ namespace }}\Controller; |
4 | 4 | |
5 | -{% block use_statements %} |
|
5 | +{%block use_statements%} |
|
6 | 6 | use FOS\RestBundle\Controller\FOSRestController; |
7 | 7 | use FOS\RestBundle\Controller\Annotations\QueryParam; |
8 | -{% endblock use_statements %} |
|
8 | +{%endblock use_statements%} |
|
9 | 9 | |
10 | -{% block class_definition %} |
|
10 | +{%block class_definition%} |
|
11 | 11 | /** |
12 | 12 | * Class {{ controller }}Controller |
13 | 13 | * @package {{ namespace }}\Controller |
14 | 14 | */ |
15 | 15 | class {{ controller }}Controller extends FOSRestController |
16 | -{% endblock class_definition %} |
|
16 | +{%endblock class_definition%} |
|
17 | 17 | { |
18 | -{% block class_body %} |
|
18 | +{%block class_body%} |
|
19 | 19 | use Generated\{{ controller }}Controller; |
20 | -{% endblock class_body %} |
|
20 | +{%endblock class_body%} |
|
21 | 21 | } |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | namespace {{ namespace }}\Controller |
4 | -{%- if trait %} |
|
4 | +{%- if trait%} |
|
5 | 5 | \Generated |
6 | -{%- endif %} |
|
6 | +{%- endif%} |
|
7 | 7 | ; |
8 | 8 | |
9 | -{% block use_statements %} |
|
9 | +{%block use_statements%} |
|
10 | 10 | use Doctrine\ORM\EntityManager; |
11 | 11 | use FOS\RestBundle\Controller\FOSRestController; |
12 | 12 | use FOS\RestBundle\Request\ParamFetcherInterface; |
@@ -16,27 +16,27 @@ discard block |
||
16 | 16 | use \Doctrine\DBAL\DBALException; |
17 | 17 | use \JMS\Serializer\DeserializationContext; |
18 | 18 | use {{ entity_class }}; |
19 | -{% endblock use_statements %} |
|
19 | +{%endblock use_statements%} |
|
20 | 20 | |
21 | -{% block class_definition %} |
|
21 | +{%block class_definition%} |
|
22 | 22 | /** |
23 | 23 | * {%- if trait %} Trait{%- else %} Class{%- endif %} {{ controller }}Controller |
24 | 24 | */ |
25 | 25 | |
26 | -{%- if trait %} |
|
26 | +{%- if trait%} |
|
27 | 27 | |
28 | 28 | trait |
29 | -{%- else %} |
|
29 | +{%- else%} |
|
30 | 30 | |
31 | 31 | class |
32 | -{%- endif %} |
|
32 | +{%- endif%} |
|
33 | 33 | {{ controller }}Controller |
34 | -{%- if not trait %} |
|
34 | +{%- if not trait%} |
|
35 | 35 | extends FOSRestController |
36 | -{%- endif %} |
|
37 | -{% endblock class_definition %} |
|
36 | +{%- endif%} |
|
37 | +{%endblock class_definition%} |
|
38 | 38 | { |
39 | -{% block class_body %} |
|
39 | +{%block class_body%} |
|
40 | 40 | /** |
41 | 41 | * Get detail of a {{ entity_name }} record |
42 | 42 | * @param $id |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function get{{ controller|capitalize }}Action($id) { |
50 | 50 | $manager = $this->get("{{ manager }}"); |
51 | 51 | $entity = $manager->getRepository('{{ entity_bundle }}:{{ entity }}')->find($id); |
52 | - $view = View::create($entity, 200)->setSerializationContext($this->getSerializerContext(array("get")));; |
|
52 | + $view = View::create($entity, 200)->setSerializationContext($this->getSerializerContext(array("get"))); ; |
|
53 | 53 | return $this->handleView($view); |
54 | 54 | } |
55 | 55 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $start = 0; |
83 | 83 | if ($paramFetcher->get("start") === "0") { |
84 | 84 | if ($paramFetcher->get("page") > 1) { |
85 | - $start = ($paramFetcher->get("page")-1) * $paramFetcher->get("limit"); |
|
85 | + $start = ($paramFetcher->get("page") - 1)*$paramFetcher->get("limit"); |
|
86 | 86 | } |
87 | 87 | } else { |
88 | 88 | $start = $paramFetcher->get("start"); |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | $paramFetcher->get("limit"), |
94 | 94 | $start |
95 | 95 | ); |
96 | - {%- if mongo %} |
|
96 | + {%- if mongo%} |
|
97 | 97 | // @todo fix it... |
98 | 98 | // $list = array_values($list->toArray()); |
99 | - {%- endif %} |
|
99 | + {%- endif%} |
|
100 | 100 | |
101 | 101 | $context = $this->getSerializerContext(array('list')); |
102 | 102 | $view = View::create($list, 200)->setSerializationContext($context); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | return $this->handleView(View::create(null, 204)); |
241 | 241 | } |
242 | 242 | |
243 | -{% endblock class_body %} |
|
243 | +{%endblock class_body%} |
|
244 | 244 | |
245 | 245 | protected function getSerializerContext($groups = array(), $version = null) { |
246 | 246 | $serializeContext = SerializationContext::create(); |
@@ -39,19 +39,19 @@ |
||
39 | 39 | exit(1); |
40 | 40 | } |
41 | 41 | } |
42 | - $metadata = $this->getMetadata($input, $output, $outputLocation===false); |
|
43 | - foreach($metadata->getMetadata() as $classMetadata) { |
|
42 | + $metadata = $this->getMetadata($input, $output, $outputLocation === false); |
|
43 | + foreach ($metadata->getMetadata() as $classMetadata) { |
|
44 | 44 | /** @var ClassMetadata $classMetadata */ |
45 | 45 | $classMetadata->reflClass = new \ReflectionClass($classMetadata->name); |
46 | 46 | if ($reader->getClassAnnotation($classMetadata->getReflectionClass(), 'Tpg\ExtjsBundle\Annotation\Model') !== null) { |
47 | 47 | if ($outputLocation) { |
48 | 48 | if (is_dir($outputLocation)) { |
49 | 49 | $baseDir = $outputLocation; |
50 | - foreach(explode("\\", $classMetadata->namespace) as $dir) { |
|
50 | + foreach (explode("\\", $classMetadata->namespace) as $dir) { |
|
51 | 51 | @mkdir($baseDir.DIRECTORY_SEPARATOR.$dir); |
52 | 52 | $baseDir .= DIRECTORY_SEPARATOR.$dir; |
53 | 53 | } |
54 | - $fileName = $baseDir.DIRECTORY_SEPARATOR.substr($classMetadata->name, strlen($classMetadata->namespace)+1).".js"; |
|
54 | + $fileName = $baseDir.DIRECTORY_SEPARATOR.substr($classMetadata->name, strlen($classMetadata->namespace) + 1).".js"; |
|
55 | 55 | if (!$this->canWriteFile($input, $output, $fileName)) { |
56 | 56 | continue; |
57 | 57 | } |
@@ -101,25 +101,25 @@ |
||
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - $dialog->writeSection($output, 'Controller generation: ' . $controller . 'Controller (' . $bundle->getName() . ')'); |
|
104 | + $dialog->writeSection($output, 'Controller generation: '.$controller.'Controller ('.$bundle->getName().')'); |
|
105 | 105 | |
106 | 106 | /** @var RestControllerGenerator $generator */ |
107 | 107 | $generator = $this->getGenerator($bundle); |
108 | 108 | if ($input->getOption('trait')) { |
109 | 109 | $output->writeln("<info>Generating Controller with Traits</info>"); |
110 | 110 | $generator->setUseTrait(true); |
111 | - $generator->generate($bundle,$controller,'',''); |
|
111 | + $generator->generate($bundle, $controller, '', ''); |
|
112 | 112 | $output->writeln("<info>Trait Controller Generated</info>"); |
113 | 113 | $generator->setUseTrait(false); |
114 | 114 | $generator->setTemplateFile('UseTraitController.php'); |
115 | 115 | try { |
116 | - $generator->generate($bundle,$controller,'',''); |
|
116 | + $generator->generate($bundle, $controller, '', ''); |
|
117 | 117 | $output->writeln("<info>Controller Generated</info>"); |
118 | 118 | } catch (\RuntimeException $e) { |
119 | 119 | $output->writeln("<info>Controller Skipped</info>"); |
120 | 120 | } |
121 | 121 | } else { |
122 | - $generator->generate($bundle,$controller,'',''); |
|
122 | + $generator->generate($bundle, $controller, '', ''); |
|
123 | 123 | $output->writeln("<info>Controller Generated</info>"); |
124 | 124 | } |
125 | 125 |
@@ -8,5 +8,5 @@ |
||
8 | 8 | * @Target("PROPERTY") |
9 | 9 | */ |
10 | 10 | class Field implements Annotation { |
11 | - public $type="string"; |
|
11 | + public $type = "string"; |
|
12 | 12 | } |
13 | 13 | \ No newline at end of file |
@@ -18,11 +18,11 @@ |
||
18 | 18 | public function visitProperty(PropertyMetadata $metadata, $data, Context $context) { |
19 | 19 | $name = $this->namingStrategy->translateName($metadata); |
20 | 20 | |
21 | - if (null === $data || ! is_array($data) || ! array_key_exists($name, $data)) { |
|
21 | + if (null === $data || !is_array($data) || !array_key_exists($name, $data)) { |
|
22 | 22 | return; |
23 | 23 | } |
24 | 24 | |
25 | - if ( ! $metadata->type) { |
|
25 | + if (!$metadata->type) { |
|
26 | 26 | throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->class, $metadata->name)); |
27 | 27 | } |
28 | 28 |
@@ -64,11 +64,11 @@ |
||
64 | 64 | 'trait' => $this->trait, |
65 | 65 | 'namespace' => $bundle->getNamespace(), |
66 | 66 | 'bundle' => $bundle->getName(), |
67 | - "manager" => ($this->mongo===true)?"doctrine_mongodb.odm.default_document_manager":"doctrine.orm.default_entity_manager", |
|
68 | - 'serializer' => ($this->mongo===true)?"tpg_extjs.odm_serializer":"tpg_extjs.orm_serializer", |
|
67 | + "manager" => ($this->mongo === true) ? "doctrine_mongodb.odm.default_document_manager" : "doctrine.orm.default_entity_manager", |
|
68 | + 'serializer' => ($this->mongo === true) ? "tpg_extjs.odm_serializer" : "tpg_extjs.orm_serializer", |
|
69 | 69 | 'controller' => $controller, |
70 | 70 | 'entity_class' => $entityClass, |
71 | - 'entity_name' => str_replace(array("/","\\"), "_", $this->entityName), |
|
71 | + 'entity_name' => str_replace(array("/", "\\"), "_", $this->entityName), |
|
72 | 72 | 'entity_bundle' => $this->entityBundle->getName(), |
73 | 73 | 'entity' => array_pop($tmpEntity), |
74 | 74 | 'route_name_prefix' => strtolower(preg_replace('/([A-Z])/', '_\\1', $bundle->getName().'_api_')) |