Skip to content

Commit d25009b

Browse files
Add sulu 3.0 support (#96)
* add sulu 3.0 support * Replace TaggedServiceCollectorCompilerPass with tagged iterator * Push dependencies # Conflicts: # composer.json * Update github worfklows * Fix subscriber * Fix multiple issues * Add review suggestions * Fix localized redirects * Fix linting * Refactor to RedirectRouteCollectionLoader * Add upgrade adjustments --------- Co-authored-by: Prokyonn <daniel@sulu.io>
1 parent efb07aa commit d25009b

35 files changed

+1047
-842
lines changed

.github/workflows/crowdin-upload.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
name: Crowdin Upload
2+
23
on:
34
push:
45
tags:
56
- '*'
7+
workflow_dispatch:
68

79
jobs:
810
upload_sources:
911
name: Upload Sources
10-
runs-on: ubuntu-18.04
12+
runs-on: ubuntu-22.04
13+
timeout-minutes: 30
14+
1115
steps:
12-
- uses: actions/checkout@v1
16+
- uses: actions/checkout@v4
17+
1318
- name: Copy translation file
1419
run: cp Resources/translations/admin.en.json admin.en.json
20+
1521
- name: Download Crowdin CLI
1622
run: curl "https://downloads.crowdin.com/cli/v3/crowdin-cli.zip" --output crowdin-cli.zip && unzip crowdin-cli.zip
23+
1724
- name: Upload translations to crowdin
1825
env:
1926
CROWDIN_TOKEN: ${{ secrets.CrowdinToken }}
Lines changed: 70 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,71 @@
11
name: Test application
2+
23
on:
3-
pull_request: null
4+
pull_request:
45
push:
56
branches:
67
- '[0-9]+.x'
78
- '[0-9]+.[0-9]+'
9+
workflow_dispatch:
10+
11+
# automatically cancel previously started workflows when pushing a new commit to a branch
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
816
jobs:
917
php:
1018
name: 'PHP ${{ matrix.php-version }} (${{ matrix.dependency-versions }})'
11-
runs-on: ubuntu-latest
19+
runs-on: ubuntu-22.04
20+
timeout-minutes: 30
21+
1222
env:
13-
DATABASE_URL: 'mysql://root:root@127.0.0.1/sulu_redirect_test?serverVersion=5.7'
23+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
1425
strategy:
1526
fail-fast: false
1627
matrix:
1728
include:
1829
- php-version: '8.2'
1930
dependency-versions: 'lowest'
20-
php-extensions: 'mysql, imagick'
31+
php-extensions: 'ctype, iconv, mysql, gd'
2132
tools: 'composer:v2'
2233
env:
23-
SYMFONY_DEPRECATIONS_HELPER: weak
34+
SYMFONY_DEPRECATIONS_HELPER: disabled
35+
DATABASE_URL: 'mysql://root:root@127.0.0.1:3306/sulu_redirect_test?serverVersion=5.7&charset=utf8mb4'
2436

2537
- php-version: '8.2'
2638
dependency-versions: 'highest'
27-
php-extensions: 'mysql, imagick'
39+
php-extensions: 'ctype, iconv, mysql, imagick'
2840
tools: 'composer:v2'
2941
env:
3042
SYMFONY_DEPRECATIONS_HELPER: weak
43+
DATABASE_URL: 'mysql://root:root@127.0.0.1:3306/sulu_redirect_test?serverVersion=5.7&charset=utf8mb4'
3144

3245
- php-version: '8.3'
3346
dependency-versions: 'highest'
34-
php-extensions: 'mysql, imagick'
47+
php-extensions: 'ctype, iconv, mysql, imagick'
3548
tools: 'composer:v2'
3649
env:
3750
SYMFONY_DEPRECATIONS_HELPER: weak
51+
DATABASE_URL: 'mysql://root:root@127.0.0.1:3306/sulu_redirect_test?serverVersion=5.7&charset=utf8mb4'
3852

3953
- php-version: '8.4'
4054
dependency-versions: 'highest'
41-
php-extensions: 'mysql, imagick'
42-
tools: 'composer:v2'
43-
composer-options: '--ignore-platform-reqs'
55+
php-extensions: 'ctype, iconv, mysql, imagick'
56+
tools: 'composer'
4457
env:
4558
SYMFONY_DEPRECATIONS_HELPER: weak
59+
DATABASE_URL: 'mysql://root:root@127.0.0.1:3306/sulu_redirect_test?serverVersion=5.7&charset=utf8mb4'
4660

4761
- php-version: '8.5'
4862
dependency-versions: 'highest'
49-
php-extensions: 'mysql, imagick'
50-
tools: 'composer:v2'
51-
composer-options: '--ignore-platform-reqs'
63+
php-extensions: 'ctype, iconv, mysql, imagick'
64+
tools: 'composer:snapshot'
65+
composer-stability: 'dev'
5266
env:
5367
SYMFONY_DEPRECATIONS_HELPER: weak
68+
DATABASE_URL: 'mysql://root:root@127.0.0.1:3306/sulu_redirect_test?serverVersion=5.7&charset=utf8mb4'
5469

5570
services:
5671
mysql:
@@ -69,35 +84,53 @@ jobs:
6984
- name: Install and configure PHP
7085
uses: shivammathur/setup-php@v2
7186
with:
72-
php-version: '${{ matrix.php-version }}'
73-
extensions: '${{ matrix.php-extensions }}'
74-
tools: '${{ matrix.tools }}'
87+
php-version: ${{ matrix.php-version }}
88+
extensions: ${{ matrix.php-extensions }}
89+
tools: ${{ matrix.tools }}
90+
ini-values: memory_limit=-1
7591
coverage: none
7692

7793
- name: Remove Lint Tools
7894
# These tools are not required to run tests, so we are removing them to improve dependency resolving and
7995
# testing lowest versions.
8096
run: composer remove "*php-cs-fixer*" "*phpstan*" "*rector*" --dev --no-update
8197

98+
- name: Set composer stability
99+
if: ${{ matrix.composer-stability }}
100+
run: composer config minimum-stability ${{ matrix.composer-stability }}
101+
82102
- name: Install composer dependencies
83-
uses: ramsey/composer-install@v2
103+
uses: ramsey/composer-install@v3
84104
with:
85-
dependency-versions: ${{matrix.dependency-versions}}
86-
composer-options: ${{matrix.composer-options}}
105+
dependency-versions: ${{ matrix.dependency-versions }}
106+
composer-options: ${{ matrix.composer-options }}
107+
108+
- name: Output versions and installed dependencies
109+
run: |
110+
echo 'PHP Version:'
111+
php --version
112+
echo ''
113+
echo 'PHP Modules:'
114+
php -m
115+
echo ''
116+
echo 'Composer Info:'
117+
composer info
87118
88119
- name: Bootstrap test environment
89120
run: composer bootstrap-test-environment
90-
env: '${{ matrix.env }}'
121+
env: ${{ matrix.env }}
91122

92123
- name: Execute test cases
93124
run: time composer test
94-
env: '${{ matrix.env }}'
125+
env: ${{ matrix.env }}
95126

96127
php-lint:
97128
name: 'PHP Lint'
98-
runs-on: ubuntu-latest
129+
runs-on: ubuntu-22.04
130+
timeout-minutes: 30
131+
99132
env:
100-
DATABASE_URL: 'mysql://root:root@127.0.0.1/sulu_redirect_test?serverVersion=5.7'
133+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101134

102135
steps:
103136
- name: Checkout project
@@ -107,14 +140,26 @@ jobs:
107140
uses: shivammathur/setup-php@v2
108141
with:
109142
php-version: '8.3'
110-
extensions: 'mysql, imagick'
143+
extensions: 'ctype, iconv, mysql, imagick'
111144
tools: 'composer:v2'
145+
ini-values: memory_limit=-1
112146
coverage: none
113147

114148
- name: Install composer dependencies
115-
uses: ramsey/composer-install@v2
149+
uses: ramsey/composer-install@v3
116150
with:
117151
dependency-versions: highest
118152

153+
- name: Output versions and installed dependencies
154+
run: |
155+
echo 'PHP Version:'
156+
php --version
157+
echo ''
158+
echo 'PHP Modules:'
159+
php -m
160+
echo ''
161+
echo 'Composer Info:'
162+
composer info
163+
119164
- name: Lint code
120165
run: composer lint

Controller/RedirectRouteController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
use Sulu\Component\Rest\Exception\RestException;
2626
use Sulu\Component\Rest\ListBuilder\Doctrine\DoctrineListBuilderFactoryInterface;
2727
use Sulu\Component\Rest\ListBuilder\FieldDescriptorInterface;
28-
use Sulu\Component\Rest\ListBuilder\ListRepresentation;
2928
use Sulu\Component\Rest\ListBuilder\Metadata\FieldDescriptorFactoryInterface;
29+
use Sulu\Component\Rest\ListBuilder\PaginatedRepresentation;
3030
use Sulu\Component\Security\SecuredControllerInterface;
3131
use Symfony\Component\HttpFoundation\Request;
3232
use Symfony\Component\HttpFoundation\Response;
@@ -117,14 +117,12 @@ public function cgetAction(Request $request)
117117
$this->restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);
118118
$results = $listBuilder->execute();
119119

120-
$list = new ListRepresentation(
120+
$list = new PaginatedRepresentation(
121121
$results,
122122
self::RESULT_KEY,
123-
$request->attributes->get('_route'),
124-
$request->query->all(),
125123
$listBuilder->getCurrentPage(),
126124
$listBuilder->getLimit(),
127-
$listBuilder->count()
125+
$listBuilder->count(),
128126
);
129127

130128
return $this->handleView($this->view($list));

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() // @phpstan-ignore-line
27+
$treeBuilder->getRootNode()
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.')

Entity/RedirectRouteRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public function findBySource($source, $sourceHost = null)
4646

4747
public function persist(RedirectRouteInterface $entity): void
4848
{
49-
$this->_em->persist($entity);
49+
$this->getEntityManager()->persist($entity);
5050
}
5151

5252
public function remove(RedirectRouteInterface $entity): void
5353
{
54-
$this->_em->remove($entity);
54+
$this->getEntityManager()->remove($entity);
5555
}
5656

5757
/**

Exception/RedirectRouteNotUniqueException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function __construct($source, $sourceHost = null)
3737
parent::__construct(\sprintf('The source "%s" with sourceHost "%s" is already in use.', $source, $sourceHost));
3838

3939
$this->source = $source;
40+
$this->sourceHost = $sourceHost;
4041
}
4142

4243
/**

0 commit comments

Comments
 (0)