@@ -20,26 +20,26 @@ discard block |
||
| 20 | 20 | $kernel = $this->get('kernel'); |
| 21 | 21 | if ($models === null) { |
| 22 | 22 | $list = $this->container->getParameter("tpg_extjs.entities"); |
| 23 | - return new StreamedResponse(function () use($list, $generator, $kernel) { |
|
| 23 | + return new StreamedResponse(function() use($list, $generator, $kernel) { |
|
| 24 | 24 | foreach ($list as $configEntityLine) { |
| 25 | 25 | list($bundleName, $path) = explode("/", substr($configEntityLine, 1), 2); |
| 26 | 26 | /** @var Bundle $bundle */ |
| 27 | 27 | $bundle = $kernel->getBundle($bundleName, true); |
| 28 | 28 | |
| 29 | 29 | /** Entity end with backslash, it is a directory */ |
| 30 | - $loadAllEntitiesFromDir = ($configEntityLine[strlen($configEntityLine)-1] == "/"); |
|
| 30 | + $loadAllEntitiesFromDir = ($configEntityLine[strlen($configEntityLine) - 1] == "/"); |
|
| 31 | 31 | |
| 32 | - if ( $loadAllEntitiesFromDir ) { |
|
| 32 | + if ($loadAllEntitiesFromDir) { |
|
| 33 | 33 | $bundleRef = new \ReflectionClass($bundle); |
| 34 | 34 | $dir = new Finder(); |
| 35 | 35 | $dir->files()->depth('== 0')->in(dirname($bundleRef->getFileName()).'/'.$path)->name('/.*\.php$/'); |
| 36 | - foreach($dir as $file) { |
|
| 36 | + foreach ($dir as $file) { |
|
| 37 | 37 | /** @var SplFileInfo $file*/ |
| 38 | - $entityClassname = $bundleRef->getNamespaceName() . "\\" . str_replace("/", "\\", $path) . substr($file->getFilename(), 0, -4); |
|
| 38 | + $entityClassname = $bundleRef->getNamespaceName()."\\".str_replace("/", "\\", $path).substr($file->getFilename(), 0, -4); |
|
| 39 | 39 | echo $generator->generateMarkupForEntity($entityClassname); |
| 40 | 40 | } |
| 41 | - } else { |
|
| 42 | - $entityClassname = $bundle->getNamespace() . "\\" . str_replace("/", "\\", $path); |
|
| 41 | + } else { |
|
| 42 | + $entityClassname = $bundle->getNamespace()."\\".str_replace("/", "\\", $path); |
|
| 43 | 43 | echo $generator->generateMarkupForEntity($entityClassname); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | if (!is_array($models)) { |
| 52 | 52 | $models = array($models); |
| 53 | 53 | } |
| 54 | - return new StreamedResponse(function () use($models, $generator) { |
|
| 54 | + return new StreamedResponse(function() use($models, $generator) { |
|
| 55 | 55 | foreach ($models as $model) { |
| 56 | 56 | $model = str_replace(".", "\\", $model); |
| 57 | 57 | echo $generator->generateMarkupForEntity($model); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | } else { |
| 103 | 103 | $requestData = array(); |
| 104 | 104 | $i = 0; |
| 105 | - foreach($actionparams as $parameter) { |
|
| 105 | + foreach ($actionparams as $parameter) { |
|
| 106 | 106 | $requestData[$parameter->getName()] = $data[$i++]; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -21,19 +21,19 @@ |
||
| 21 | 21 | $this->twigEngine = new TwigEngineMokcup(); |
| 22 | 22 | $this->service->setTwigEngine($this->twigEngine); |
| 23 | 23 | $this->service->setModelFieldsParameters(array( |
| 24 | - "date" => array( "format" => "d-m-y") |
|
| 24 | + "date" => array( "format" => "d-m-y") |
|
| 25 | 25 | )); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function testCustomFieldParameters() { |
| 29 | - $this->service->generateMarkupForEntity('Test\TestBundle\Model\Person'); |
|
| 30 | - $fieldsType = array(); |
|
| 31 | - foreach ($this->twigEngine->renderParameters['fields'] as $field) { |
|
| 29 | + $this->service->generateMarkupForEntity('Test\TestBundle\Model\Person'); |
|
| 30 | + $fieldsType = array(); |
|
| 31 | + foreach ($this->twigEngine->renderParameters['fields'] as $field) { |
|
| 32 | 32 | if (isset($field['format'])) { |
| 33 | - $fieldsType[$field['name']] = $field['format']; |
|
| 33 | + $fieldsType[$field['name']] = $field['format']; |
|
| 34 | + } |
|
| 34 | 35 | } |
| 35 | - } |
|
| 36 | - $this->assertEquals("d-m-y", $fieldsType['createdAt']); |
|
| 36 | + $this->assertEquals("d-m-y", $fieldsType['createdAt']); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function testEntityProperty() { |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | $this->twigEngine = new TwigEngineMokcup(); |
| 22 | 22 | $this->service->setTwigEngine($this->twigEngine); |
| 23 | 23 | $this->service->setModelFieldsParameters(array( |
| 24 | - "date" => array( "format" => "d-m-y") |
|
| 24 | + "date" => array("format" => "d-m-y") |
|
| 25 | 25 | )); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | public function testGetsActionWithFilterOnName() { |
| 18 | 18 | $filter = json_encode(array( |
| 19 | - array('property'=>'name','value'=>'Ford') |
|
| 19 | + array('property'=>'name', 'value'=>'Ford') |
|
| 20 | 20 | )); |
| 21 | 21 | $this->client->request('GET', '/cars.json?filter='.$filter); |
| 22 | 22 | $content = json_decode($this->client->getResponse()->getContent(), true); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | public function testGetsActionWithFilterOnPlateNumner() { |
| 28 | 28 | $filter = json_encode(array( |
| 29 | - array('property'=>'plateNumber','value'=>'BB243') |
|
| 29 | + array('property'=>'plateNumber', 'value'=>'BB243') |
|
| 30 | 30 | )); |
| 31 | 31 | $this->client->request('GET', '/cars.json?filter='.$filter); |
| 32 | 32 | $content = json_decode($this->client->getResponse()->getContent(), true); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $manager = $this->client->getContainer()->get("doctrine.orm.default_entity_manager"); |
| 24 | 24 | $owner = new CarOwner(); |
| 25 | 25 | $owner->setName("james"); |
| 26 | - foreach($this->records as $record) { |
|
| 26 | + foreach ($this->records as $record) { |
|
| 27 | 27 | $owner->addCar($record); |
| 28 | 28 | } |
| 29 | 29 | $manager->persist($owner); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | public function testGetWithAssociation() { |
| 46 | 46 | $filter = json_encode(array( |
| 47 | - array('property'=>'name','value'=>'Ford') |
|
| 47 | + array('property'=>'name', 'value'=>'Ford') |
|
| 48 | 48 | )); |
| 49 | 49 | $this->client->request('GET', '/cars.json?filter='.$filter); |
| 50 | 50 | $content = json_decode($this->client->getResponse()->getContent(), true); |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Tpg\ExtjsBundle\Tests\Command\ODM; |
| 3 | 3 | |
| 4 | -include_once(__DIR__ . '/../../app/AppKernel.php'); |
|
| 4 | +include_once(__DIR__.'/../../app/AppKernel.php'); |
|
| 5 | 5 | |
| 6 | 6 | use Symfony\Bundle\FrameworkBundle\Console\Application; |
| 7 | 7 | use Symfony\Component\Console\Tester\CommandTester; |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | |
| 8 | 8 | public function testGetWithAssociation() { |
| 9 | 9 | $filter = json_encode(array( |
| 10 | - array('property'=>'name','value'=>'Invoice 1') |
|
| 10 | + array('property'=>'name', 'value'=>'Invoice 1') |
|
| 11 | 11 | )); |
| 12 | 12 | $this->client->request('GET', '/orders.json?filter='.$filter); |
| 13 | 13 | $content = json_decode($this->client->getResponse()->getContent(), true); |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Tpg\ExtjsBundle\Tests\Command; |
| 3 | 3 | |
| 4 | -include_once(__DIR__ . '/../app/AppKernel.php'); |
|
| 4 | +include_once(__DIR__.'/../app/AppKernel.php'); |
|
| 5 | 5 | |
| 6 | 6 | use Doctrine\Bundle\MongoDBBundle\Command\CreateSchemaDoctrineODMCommand; |
| 7 | 7 | use Doctrine\Bundle\MongoDBBundle\Command\DropSchemaDoctrineODMCommand; |
@@ -5,8 +5,8 @@ |
||
| 5 | 5 | exit(0); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | -$loader = require_once __DIR__ . '/bootstrap.php'; |
|
| 9 | -require_once __DIR__ . '/app/AppKernel.php'; |
|
| 8 | +$loader = require_once __DIR__.'/bootstrap.php'; |
|
| 9 | +require_once __DIR__.'/app/AppKernel.php'; |
|
| 10 | 10 | use Symfony\Component\HttpFoundation\Request; |
| 11 | 11 | |
| 12 | 12 | $kernel = new AppKernel('test', true); |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | break; |
| 261 | 261 | case 'Doctrine\ORM\Mapping\JoinColumns': |
| 262 | 262 | if (count($annotation->value) > 1) { |
| 263 | - throw new \Exception('Multiple foreign key is not supported'); |
|
| 263 | + throw new \Exception('Multiple foreign key is not supported'); |
|
| 264 | 264 | } |
| 265 | 265 | $saveField = true; |
| 266 | 266 | $field['name'] = $this->convertNaming($annotation->value[0]->name); |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | /** Add the ability to override field parameter */ |
| 286 | 286 | if (isset($this->fieldsParams[$field['type']])) { |
| 287 | - $field = array_merge($field, $this->fieldsParams[$field['type']]); |
|
| 287 | + $field = array_merge($field, $this->fieldsParams[$field['type']]); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | if (!empty($association)) { |
@@ -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 | } |