Skip to content

Commit c2b0d7a

Browse files
committed
refactorings
1 parent 3b9de72 commit c2b0d7a

File tree

9 files changed

+34
-92
lines changed

9 files changed

+34
-92
lines changed

app/AppKernel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function registerBundles()
2323
new JMS\SerializerBundle\JMSSerializerBundle(),
2424
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
2525
new Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle(),
26-
new Csa\Bundle\GuzzleBundle\CsaGuzzleBundle(),
2726

2827
new AppBundle\AppBundle(),
2928
];
@@ -33,6 +32,8 @@ public function registerBundles()
3332
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
3433
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
3534
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
35+
36+
$bundles[] = new Csa\Bundle\GuzzleBundle\CsaGuzzleBundle();
3637
}
3738

3839
return $bundles;

app/config/config.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,24 @@ nelmio_api_doc:
106106
# FOS REST Bundle
107107
fos_rest:
108108
body_listener: true
109-
format_listener: true
110109
param_fetcher_listener: force
111110
view:
112111
view_response_listener: 'force'
113112
formats:
114-
jsonp: true
115113
json: true
116114
xml: false
117115
rss: false
118116
mime_types:
119117
json: ['application/json', 'application/x-json']
120118
jpg: ['image/jpeg']
121119
png: ['image/png']
122-
jsonp_handler: ~
123120
routing_loader:
124121
default_format: json
125122
include_format: false
126123
format_listener:
124+
enabled: true
127125
rules:
128-
- { path: ^/, priorities: [ json, jsonp ], fallback_format: ~, prefer_extension: true }
126+
- { path: ^/, priorities: [ json ], fallback_format: json, prefer_extension: true }
129127
exception:
130128
enabled: true
131129
# versioning:

behat.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ default:
99
doctrine: "@doctrine"
1010
- AppBundle\Features\Context\RestApiContext:
1111
client: "@csa_guzzle.client.local_test_api"
12-
- AppBundle\Features\Context\MysqlDatabaseContext:
13-
em: "@doctrine.orm.entity_manager"
1412
- AppBundle\Features\Context\UserSetupContext:
1513
userManager: "@fos_user.user_manager"
1614
em: "@doctrine.orm.entity_manager"

features/bootstrap/FeatureContext.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<?php
22

33
use Behat\Behat\Context\Context;
4-
use Behat\Behat\Context\SnippetAcceptingContext;
5-
use Behat\Gherkin\Node\PyStringNode;
6-
use Behat\Gherkin\Node\TableNode;
74

85
/**
96
* Defines application features from the specific context.
107
*/
11-
class FeatureContext implements Context, SnippetAcceptingContext
8+
class FeatureContext implements Context
129
{
1310
private $doctrine;
1411
private $manager;
1512
private $schemaTool;
1613
private $classes;
14+
1715
/**
1816
* Initializes context.
1917
*
@@ -28,6 +26,7 @@ public function __construct(\Doctrine\Common\Persistence\ManagerRegistry $doctri
2826
$this->schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->manager);
2927
$this->classes = $this->manager->getMetadataFactory()->getAllMetadata();
3028
}
29+
3130
/**
3231
* @BeforeScenario
3332
*/

src/AppBundle/Controller/RestRegistrationController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,16 @@ public function registerAction(Request $request)
6464

6565
$userManager->updateUser($user);
6666

67+
$jwtManager = $this->get('lexik_jwt_authentication.jwt_manager');
68+
69+
$jwt = $jwtManager->create($user);
70+
6771
if (null === $response = $event->getResponse()) {
6872
return new JsonResponse(
69-
$this->get('translator')->trans('registration.flash.user_created', [], 'FOSUserBundle'),
73+
[
74+
'msg' => $this->get('translator')->trans('registration.flash.user_created', [], 'FOSUserBundle'),
75+
'token' => $jwt,
76+
],
7077
Response::HTTP_CREATED
7178
);
7279
}

src/AppBundle/Event/Listener/JWTCreatedListener.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public function __construct( TokenStorageInterface $tokenStorage)
2929
*/
3030
public function onJWTCreated(JWTCreatedEvent $event)
3131
{
32-
$payload = $event->getData();
33-
34-
// add new data
35-
$payload['userId'] = $this->tokenStorage->getToken()->getUser()->getId();
36-
37-
$event->setData($payload);
32+
// $payload = $event->getData();
33+
//
34+
// // add new data
35+
// $payload['userId'] = $this->tokenStorage->getToken()->getUser()->getId();
36+
//
37+
// $event->setData($payload);
3838
}
3939
}

src/AppBundle/Features/Context/MysqlDatabaseContext.php

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/AppBundle/Features/Context/UserSetupContext.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Behat\Gherkin\Node\TableNode;
88
use Doctrine\ORM\EntityManagerInterface;
99
use FOS\UserBundle\Model\UserManagerInterface;
10-
use PhpSpec\Exception\Example\PendingException;
1110

1211
class UserSetupContext implements Context, SnippetAcceptingContext
1312
{
@@ -20,6 +19,12 @@ class UserSetupContext implements Context, SnippetAcceptingContext
2019
*/
2120
private $em;
2221

22+
/**
23+
* UserSetupContext constructor.
24+
*
25+
* @param UserManagerInterface $userManager
26+
* @param EntityManagerInterface $em
27+
*/
2328
public function __construct(UserManagerInterface $userManager, EntityManagerInterface $em)
2429
{
2530
$this->userManager = $userManager;

web/app_acceptance.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
//umask(0000);
88
// This check prevents access to debug front controllers that are deployed by accident to production servers.
99
// Feel free to remove this, extend it, or make something more sophisticated.
10-
//if (isset($_SERVER['HTTP_CLIENT_IP'])
11-
// || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
12-
// || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
13-
//) {
14-
// header('HTTP/1.0 403 Forbidden');
15-
// exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
16-
//}
10+
if (isset($_SERVER['HTTP_CLIENT_IP'])
11+
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
12+
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
13+
) {
14+
header('HTTP/1.0 403 Forbidden');
15+
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
16+
}
1717
/**
1818
* @var Composer\Autoload\ClassLoader $loader
1919
*/

0 commit comments

Comments
 (0)