Skip to content

Commit efb07aa

Browse files
authored
Migrating the rest routing (#97)
1 parent dbc636b commit efb07aa

8 files changed

Lines changed: 92 additions & 26 deletions

File tree

.github/workflows/test-application.yaml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,49 +15,36 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
include:
18-
- php-version: '7.2'
18+
- php-version: '8.2'
1919
dependency-versions: 'lowest'
20-
php-extensions: 'mysql, gd'
21-
tools: 'composer:v2'
22-
env:
23-
SYMFONY_DEPRECATIONS_HELPER: disabled
24-
25-
- php-version: '7.4'
26-
dependency-versions: 'highest'
27-
php-extensions: 'mysql, imagick'
28-
tools: 'composer:v2'
29-
env:
30-
SYMFONY_DEPRECATIONS_HELPER: weak
31-
32-
- php-version: '8.0'
33-
dependency-versions: 'highest'
3420
php-extensions: 'mysql, imagick'
3521
tools: 'composer:v2'
3622
env:
3723
SYMFONY_DEPRECATIONS_HELPER: weak
3824

39-
- php-version: '8.1'
25+
- php-version: '8.2'
4026
dependency-versions: 'highest'
4127
php-extensions: 'mysql, imagick'
4228
tools: 'composer:v2'
4329
env:
4430
SYMFONY_DEPRECATIONS_HELPER: weak
4531

46-
- php-version: '8.2'
32+
- php-version: '8.3'
4733
dependency-versions: 'highest'
4834
php-extensions: 'mysql, imagick'
4935
tools: 'composer:v2'
5036
env:
5137
SYMFONY_DEPRECATIONS_HELPER: weak
5238

53-
- php-version: '8.3'
39+
- php-version: '8.4'
5440
dependency-versions: 'highest'
5541
php-extensions: 'mysql, imagick'
5642
tools: 'composer:v2'
43+
composer-options: '--ignore-platform-reqs'
5744
env:
5845
SYMFONY_DEPRECATIONS_HELPER: weak
5946

60-
- php-version: '8.4'
47+
- php-version: '8.5'
6148
dependency-versions: 'highest'
6249
php-extensions: 'mysql, imagick'
6350
tools: 'composer:v2'

Controller/RedirectRouteController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,13 @@ public function getSecurityContext(): string
7676
protected $redirectRouteRepository;
7777

7878
/**
79-
* @var string
79+
* @var class-string
8080
*/
8181
protected $redirectRouteEntityName;
8282

83+
/**
84+
* @param class-string $redirectRouteEntityName
85+
*/
8386
public function __construct(
8487
ViewHandlerInterface $viewHandler,
8588
DoctrineRestHelper $restHelper,

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface
2424
public function getConfigTreeBuilder(): TreeBuilder
2525
{
2626
$treeBuilder = new TreeBuilder('sulu_redirect');
27-
$treeBuilder->getRootNode()
27+
$treeBuilder->getRootNode() // @phpstan-ignore-line
2828
->children()
2929
->arrayNode('gone_on_remove')
3030
->info('When enabled, this feature automatically creates redirects with http status code 410 when a document with route or an route entity is removed.')

Resources/config/routing.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sulu_redirect.import:
2+
path: /import
3+
controller: sulu_redirect.controller.import::postAction
4+
options:
5+
expose: true

Resources/config/routing_api.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
sulu_redirect.get_redirect-routes:
2+
path: '/redirect-routes.{_format}'
3+
options: { expose: true }
4+
methods: GET
5+
controller: 'sulu_redirect.redirect_route_controller::cgetAction'
6+
format: json
7+
requirements: { _format: json|csv }
8+
sulu_redirect.post_redirect-route:
9+
path: '/redirect-routes.{_format}'
10+
options: { expose: true }
11+
methods: POST
12+
controller: 'sulu_redirect.redirect_route_controller::postAction'
13+
format: json
14+
requirements: { _format: json|csv }
15+
sulu_redirect.get_redirect-route:
16+
path: '/redirect-routes/{id}.{_format}'
17+
options: { expose: true }
18+
methods: GET
19+
controller: 'sulu_redirect.redirect_route_controller::getAction'
20+
format: json
21+
requirements: { _format: json|csv }
22+
sulu_redirect.put_redirect-route:
23+
path: '/redirect-routes/{id}.{_format}'
24+
options: { expose: true }
25+
methods: PUT
26+
controller: 'sulu_redirect.redirect_route_controller::putAction'
27+
format: json
28+
requirements: { _format: json|csv }
29+
sulu_redirect.delete_redirect-route:
30+
path: '/redirect-routes/{id}.{_format}'
31+
options: { expose: true }
32+
methods: DELETE
33+
controller: 'sulu_redirect.redirect_route_controller::deleteAction'
34+
format: json
35+
requirements: { _format: json|csv }
36+
sulu_redirect.delete_redirect-routes:
37+
path: '/redirect-routes.{_format}'
38+
options: { expose: true }
39+
methods: DELETE
40+
controller: 'sulu_redirect.redirect_route_controller::cdeleteAction'
41+
format: json
42+
requirements: { _format: json|csv }
43+
sulu_redirect.post_redirect-route_trigger:
44+
path: '/redirect-routes/{id}.{_format}'
45+
methods: POST
46+
controller: 'sulu_redirect.redirect_route_controller::postTriggerAction'
47+
format: json
48+
requirements: { _format: json|csv }

Resources/doc/installation.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ composer require sulu/redirect-bundle
2020

2121
```yml
2222
sulu_redirect_api:
23-
type: rest
24-
resource: "@SuluRedirectBundle/Resources/config/routing_api.yml"
23+
resource: "@SuluRedirectBundle/Resources/config/routing_api.yaml"
2524
prefix: /admin/api
2625

2726
sulu_redirect:
28-
resource: "@SuluRedirectBundle/Resources/config/routing.yml"
27+
resource: "@SuluRedirectBundle/Resources/config/routing.yaml"
2928
prefix: /admin/redirects
3029
```
3130

UPGRADE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# UPGRADE
22

3+
## 2.2.0
4+
5+
## Deprecate usage of fos rest routing
6+
7+
We are no longer considering the [fos rest routing](https://github.com/handcraftedinthealps/RestRoutingBundle) as a best practice.
8+
All bundles should use the Symfony routing system instead.
9+
10+
Inside your `config/routes/sulu_redirect_admin.yaml` you can remove the fos rest routing configuration.
11+
First, remove all instances of `type: rest` and also replace `.yml` with `.yaml`:
12+
13+
```diff
14+
# config/routes/sulu_redirect_admin.yaml`
15+
sulu_redirect_api:
16+
- type: rest
17+
- resource: "@SuluRedirectBundle/Resources/config/routing_api.yml"
18+
+ resource: "@SuluRedirectBundle/Resources/config/routing_api.yaml"
19+
prefix: /admin/api
20+
21+
sulu_redirect:
22+
- resource: "@SuluRedirectBundle/Resources/config/routing.yml"
23+
+ resource: "@SuluRedirectBundle/Resources/config/routing.yaml"
24+
prefix: /admin/redirects
25+
```
26+
327
## 2.0.0
428

529
### Permission changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"phpstan/phpstan-doctrine": "^1.0",
2929
"phpstan/phpstan-phpunit": "^1.0",
3030
"phpstan/phpstan-symfony": "^1.0",
31-
"phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.0",
31+
"phpunit/phpunit": "^10.0",
3232
"php-cs-fixer/shim": "^3.0",
3333
"symfony/browser-kit": "^4.3 || ^5.0 || ^6.0 || ^7.0",
3434
"symfony/dotenv": "^4.3 || ^5.0 || ^6.0 || ^7.0",
@@ -37,7 +37,7 @@
3737
"handcraftedinthealps/zendsearch": "^2.0",
3838
"symfony/framework-bundle": "^4.3 || ^5.0 || ^6.0 || ^7.0",
3939
"phpspec/prophecy": "^1.10",
40-
"phpspec/prophecy-phpunit": "^1.0 || ^2.0"
40+
"phpspec/prophecy-phpunit": "^2.0"
4141
},
4242
"keywords": [
4343
"redirects"

0 commit comments

Comments
 (0)