@@ -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\ORM; |
| 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 | class GeneratedRestControllerReferenceAssociationTest extends BaseTestGeneratedRestController { |
| 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\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); |
@@ -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); |
@@ -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 | } |
@@ -30,12 +30,12 @@ |
||
| 30 | 30 | |
| 31 | 31 | class |
| 32 | 32 | {%- endif %} |
| 33 | - {{ controller }}Controller |
|
| 33 | + {{ controller }}Controller |
|
| 34 | 34 | {%- if not trait %} |
| 35 | - extends FOSRestController |
|
| 35 | + extends FOSRestController |
|
| 36 | 36 | {%- endif %} |
| 37 | 37 | {% endblock class_definition %} |
| 38 | - { |
|
| 38 | + { |
|
| 39 | 39 | {% block class_body %} |
| 40 | 40 | /** |
| 41 | 41 | * Get detail of a {{ entity_name }} record |
@@ -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(); |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | {%- if trait %} |
| 27 | 27 | |
| 28 | 28 | trait |
| 29 | -{%- else %} |
|
| 29 | +{%- else { |
|
| 30 | + %} |
|
| 30 | 31 | |
| 31 | 32 | class |
| 32 | 33 | {%- endif %} |
@@ -48,6 +49,7 @@ discard block |
||
| 48 | 49 | */ |
| 49 | 50 | public function get{{ controller|capitalize }}Action($id) { |
| 50 | 51 | $manager = $this->get("{{ manager }}"); |
| 52 | +} |
|
| 51 | 53 | $entity = $manager->getRepository('{{ entity_bundle }}:{{ entity }}')->find($id); |
| 52 | 54 | $view = View::create($entity, 200)->setSerializationContext($this->getSerializerContext(array("get")));; |
| 53 | 55 | return $this->handleView($view); |
@@ -249,7 +251,9 @@ discard block |
||
| 249 | 251 | array(\JMS\Serializer\Exclusion\GroupsExclusionStrategy::DEFAULT_GROUP), |
| 250 | 252 | $groups |
| 251 | 253 | )); |
| 252 | - if ($version !== null) $serializeContext->setVersion($version); |
|
| 254 | + if ($version !== null) { |
|
| 255 | + $serializeContext->setVersion($version); |
|
| 256 | + } |
|
| 253 | 257 | return $serializeContext; |
| 254 | 258 | } |
| 255 | 259 | } |
@@ -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 | |