Skip to content

Commit a03b9d4

Browse files
authored
Merge pull request #10 from hetg/feature/add-fixtures
Feature/add fixtures
2 parents 44c44ca + 43ce62a commit a03b9d4

29 files changed

+461
-184
lines changed

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JWT + FOS User + FOS REST template
22

3-
**Instalation**
3+
**Installation**
44

55
1. Generate the SSH keys:
66
```
@@ -22,9 +22,5 @@
2222
```
2323
5. Create admin user
2424
```
25-
bin/console fos:user:create
26-
```
27-
6. Promote admin user to admin role (ROLE_SUPER_ADMIN)
28-
```
29-
bin/console fos:user:promote
30-
```
25+
bin/console doctrine:fixtures:load
26+
```

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "project",
55
"license": "proprietary",
66
"require": {
7-
"php": "^7.1.3",
7+
"php": "^7.4",
88
"ext-ctype": "*",
99
"ext-iconv": "*",
1010
"ext-openssl": "*",
@@ -78,5 +78,8 @@
7878
"allow-contrib": false,
7979
"require": "4.4.*"
8080
}
81+
},
82+
"require-dev": {
83+
"doctrine/doctrine-fixtures-bundle": "^3.4"
8184
}
8285
}

composer.lock

Lines changed: 169 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/bundles.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
Gesdinet\JWTRefreshTokenBundle\GesdinetJWTRefreshTokenBundle::class => ['all' => true],
1515
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
1616
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true],
17+
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
1718
];
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
nelmio_api_doc:
22
documentation:
33
info:
4-
title: App
5-
#description: This is an awesome app!
6-
version: 1.0.0
4+
title: Symfony JWT App
5+
version: 0.0.1
6+
securityDefinitions:
7+
Bearer:
8+
type: apiKey
9+
description: 'Authorization: Bearer {jwt}'
10+
name: Authorization
11+
in: header
12+
scheme: Bearer
13+
security:
14+
- Bearer: []
715
areas:
816
path_patterns:
9-
- ^/api(?!/doc$)
17+
- ^/api(?!/doc$)

config/services.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,15 @@ services:
2525

2626
# add more service definitions when explicit configuration is needed
2727
# please note that last definitions always *replace* previous ones
28+
29+
api_exceptions_subscriber:
30+
class: App\EventListener\ApiExceptionsSubscriber
31+
arguments: []
32+
tags:
33+
- { name: kernel.event_subscriber }
34+
35+
attach_user_id_on_success_listener:
36+
class: App\EventListener\AttachUserIdOnSuccessListener
37+
arguments: []
38+
tags:
39+
- { name: kernel.event_listener, event: lexik_jwt_authentication.on_authentication_success, method: attachUserId }

src/ArgumentResolver/PaginateConditionsResolver.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
namespace App\ArgumentResolver;
44

55
use App\DTO\PaginateConditions;
6-
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
6+
use Generator;
77
use Symfony\Component\HttpFoundation\Request;
8+
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
89
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
910

1011
/**
@@ -13,12 +14,12 @@
1314
class PaginateConditionsResolver implements ArgumentValueResolverInterface
1415
{
1516
/**
16-
* @param Request $request
17+
* @param Request $request
1718
* @param ArgumentMetadata $argument
1819
*
1920
* @return bool
2021
*/
21-
public function supports(Request $request, ArgumentMetadata $argument)
22+
public function supports(Request $request, ArgumentMetadata $argument): bool
2223
{
2324
if (null === $argument->getType()) {
2425
return false;
@@ -32,12 +33,12 @@ public function supports(Request $request, ArgumentMetadata $argument)
3233
}
3334

3435
/**
35-
* @param Request $request
36+
* @param Request $request
3637
* @param ArgumentMetadata $argument
3738
*
38-
* @return \Generator
39+
* @return Generator
3940
*/
40-
public function resolve(Request $request, ArgumentMetadata $argument)
41+
public function resolve(Request $request, ArgumentMetadata $argument): Generator
4142
{
4243
$order = $request->get('order');
4344
$start = $request->get('start');
@@ -60,8 +61,6 @@ public function resolve(Request $request, ArgumentMetadata $argument)
6061
$start = is_numeric($start) ? intval($start) : 0;
6162
$limit = is_numeric($limit) ? intval($limit) : 100;
6263

63-
$dto = new PaginateConditions($order, $start, $limit);
64-
65-
yield $dto;
64+
yield new PaginateConditions($start, $limit, $order);
6665
}
6766
}

0 commit comments

Comments
 (0)