Skip to content

Commit 9ae5e51

Browse files
committed
Add initial state of extension
This was copied and modified for publishing from one of our customer projects.
1 parent a96ce5d commit 9ae5e51

52 files changed

Lines changed: 2029 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Tests export-ignore
2+
.github export-ignore
3+
4+
.gitattributes export-ignore
5+
.gitignore export-ignore
6+
7+
.php-cs-fixer.dist.php export-ignore
8+
phpstan.neon export-ignore
9+
phpstan-baseline.neon export-ignore
10+
phpunit.xml.dist export-ignore
11+
12+
shell.nix export-ignore

.github/workflows/ci.yaml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: 'CI'
2+
3+
'on':
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
9+
jobs:
10+
check-composer:
11+
runs-on: 'ubuntu-latest'
12+
steps:
13+
- uses: 'actions/checkout@v3'
14+
15+
- name: 'Install PHP'
16+
uses: 'shivammathur/setup-php@v2'
17+
with:
18+
php-version: '8.4'
19+
coverage: 'none'
20+
tools: 'composer:v2'
21+
env:
22+
COMPOSER_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
23+
24+
- name: 'Validate composer.json'
25+
run: 'composer validate'
26+
27+
php-linting:
28+
runs-on: 'ubuntu-latest'
29+
strategy:
30+
matrix:
31+
php-version:
32+
- 8.1
33+
- 8.2
34+
- 8.3
35+
- 8.4
36+
steps:
37+
- name: 'Checkout'
38+
uses: 'actions/checkout@v3'
39+
40+
- name: 'Install PHP'
41+
uses: 'shivammathur/setup-php@v2'
42+
with:
43+
php-version: '${{ matrix.php-version }}'
44+
coverage: 'none'
45+
46+
- name: 'PHP lint'
47+
run: "find *.php Classes Configuration Tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l"
48+
49+
xml-linting:
50+
runs-on: 'ubuntu-latest'
51+
needs:
52+
- check-composer
53+
steps:
54+
- uses: 'actions/checkout@v3'
55+
56+
- name: 'Install PHP'
57+
uses: 'shivammathur/setup-php@v2'
58+
with:
59+
php-version: '8.4'
60+
coverage: 'none'
61+
tools: 'composer:v2'
62+
env:
63+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: 'Install xmllint'
66+
run: 'sudo apt update && sudo apt install libxml2-utils'
67+
68+
- name: 'Install dependencies'
69+
run: 'composer update --prefer-dist --no-progress'
70+
71+
- name: 'PHPUnit configuration file'
72+
run: 'xmllint --schema vendor/phpunit/phpunit/phpunit.xsd --noout phpunit.xml.dist'
73+
74+
coding-guideline:
75+
runs-on: 'ubuntu-latest'
76+
steps:
77+
- uses: 'actions/checkout@v3'
78+
79+
- name: 'Install PHP'
80+
uses: 'shivammathur/setup-php@v2'
81+
with:
82+
php-version: '8.3'
83+
coverage: 'none'
84+
tools: 'composer:v2'
85+
env:
86+
COMPOSER_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
87+
88+
- name: 'Install dependencies'
89+
run: 'composer update --prefer-dist --no-progress'
90+
91+
- name: 'Coding Guideline'
92+
run: './vendor/bin/php-cs-fixer fix --dry-run --diff'
93+
94+
tests-mysql:
95+
runs-on: 'ubuntu-latest'
96+
needs:
97+
- xml-linting
98+
strategy:
99+
matrix:
100+
include:
101+
- php-version: '8.1'
102+
typo3-version: '^12.4'
103+
- php-version: '8.2'
104+
typo3-version: '^12.4'
105+
- php-version: '8.3'
106+
typo3-version: '^12.4'
107+
- php-version: '8.4'
108+
typo3-version: '^12.4'
109+
- php-version: '8.2'
110+
typo3-version: '^13.4'
111+
- php-version: '8.3'
112+
typo3-version: '^13.4'
113+
- php-version: '8.4'
114+
typo3-version: '^13.4'
115+
steps:
116+
- uses: 'actions/checkout@v3'
117+
118+
- name: 'Install PHP'
119+
uses: 'shivammathur/setup-php@v2'
120+
with:
121+
php-version: '${{ matrix.php-version }}'
122+
coverage: 'none'
123+
tools: 'composer:v2'
124+
env:
125+
COMPOSER_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
126+
127+
- name: 'Install dependencies with expected TYPO3 version'
128+
run: 'composer require --prefer-dist --no-progress "typo3/cms-core:${{ matrix.typo3-version }}"'
129+
130+
- name: 'PHPUnit Tests'
131+
run: './vendor/bin/phpunit --testdox'
132+
133+
code-quality:
134+
runs-on: 'ubuntu-latest'
135+
strategy:
136+
matrix:
137+
include:
138+
- php-version: '8.1'
139+
typo3-version: '^12.4'
140+
- php-version: '8.2'
141+
typo3-version: '^12.4'
142+
- php-version: '8.3'
143+
typo3-version: '^12.4'
144+
- php-version: '8.4'
145+
typo3-version: '^12.4'
146+
- php-version: '8.2'
147+
typo3-version: '^13.4'
148+
- php-version: '8.3'
149+
typo3-version: '^13.4'
150+
- php-version: '8.4'
151+
typo3-version: '^13.4'
152+
steps:
153+
- uses: 'actions/checkout@v3'
154+
155+
- name: 'Install PHP'
156+
uses: 'shivammathur/setup-php@v2'
157+
with:
158+
php-version: '${{ matrix.php-version }}'
159+
coverage: 'none'
160+
tools: 'composer:v2'
161+
env:
162+
COMPOSER_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
163+
164+
- name: 'Install dependencies with expected TYPO3 version'
165+
run: 'composer require --prefer-dist --no-progress "typo3/cms-backend:${{ matrix.typo3-version }}" "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-dashboard:${{ matrix.typo3-version }}"'
166+
167+
- name: 'Code Quality (by PHPStan)'
168+
run: './vendor/bin/phpstan analyse'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
/.Build/

.php-cs-fixer.dist.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* Copyright (C) 2025 Daniel Siepmann <daniel.siepmann@codappix.com>
7+
*
8+
* This program is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU General Public License
10+
* as published by the Free Software Foundation; either version 2
11+
* of the License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21+
* 02110-1301, USA.
22+
*/
23+
24+
$finder = (new PhpCsFixer\Finder())
25+
->ignoreVCSIgnored(true)
26+
->in(realpath(__DIR__) ?: throw new \Exception('Could not resolve current dir.', 1750834500))
27+
;
28+
29+
return (new \PhpCsFixer\Config())
30+
->setRiskyAllowed(true)
31+
->setRules([
32+
'@DoctrineAnnotation' => true,
33+
'@PSR2' => true,
34+
'array_syntax' => ['syntax' => 'short'],
35+
'blank_line_after_opening_tag' => true,
36+
'braces' => ['allow_single_line_closure' => true],
37+
'cast_spaces' => ['space' => 'none'],
38+
'compact_nullable_typehint' => true,
39+
'concat_space' => ['spacing' => 'one'],
40+
'declare_equal_normalize' => ['space' => 'none'],
41+
'dir_constant' => true,
42+
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
43+
'function_typehint_space' => true,
44+
'lowercase_cast' => true,
45+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
46+
'modernize_strpos' => true,
47+
'modernize_types_casting' => true,
48+
'native_function_casing' => true,
49+
'new_with_braces' => true,
50+
'no_alias_functions' => true,
51+
'no_blank_lines_after_phpdoc' => true,
52+
'no_empty_phpdoc' => true,
53+
'no_empty_statement' => true,
54+
'no_extra_blank_lines' => true,
55+
'no_leading_import_slash' => true,
56+
'no_leading_namespace_whitespace' => true,
57+
'no_null_property_initialization' => true,
58+
'no_short_bool_cast' => true,
59+
'no_singleline_whitespace_before_semicolons' => true,
60+
'no_superfluous_elseif' => true,
61+
'no_trailing_comma_in_singleline_array' => true,
62+
'no_unneeded_control_parentheses' => true,
63+
'no_unused_imports' => true,
64+
'no_useless_else' => true,
65+
'no_whitespace_in_blank_line' => true,
66+
'ordered_imports' => true,
67+
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
68+
'php_unit_mock_short_will_return' => true,
69+
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
70+
'phpdoc_no_access' => true,
71+
'phpdoc_no_empty_return' => true,
72+
'phpdoc_no_package' => true,
73+
'phpdoc_scalar' => true,
74+
'phpdoc_trim' => true,
75+
'phpdoc_types' => true,
76+
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
77+
'return_type_declaration' => ['space_before' => 'none'],
78+
'single_quote' => true,
79+
'single_line_comment_style' => ['comment_types' => ['hash']],
80+
'single_trait_insert_per_statement' => true,
81+
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
82+
'whitespace_after_comma_in_array' => true,
83+
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
84+
])
85+
->setFinder($finder);

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## v1.0.0 - 2025-06-25
4+
5+
Initial release.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* Copyright (C) 2025 Daniel Siepmann <daniel.siepmann@codappix.com>
7+
*
8+
* This program is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU General Public License
10+
* as published by the Free Software Foundation; either version 2
11+
* of the License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21+
* 02110-1301, USA.
22+
*/
23+
24+
namespace Codappix\PageSpecificTypoScript\EventListener;
25+
26+
use Codappix\PageSpecificTypoScript\Service\TypoScriptServiceInterface;
27+
use TYPO3\CMS\Core\TypoScript\IncludeTree\Event\ModifyLoadedPageTsConfigEvent;
28+
29+
final class PagesTsConfigIncludeEventListener
30+
{
31+
public function __construct(
32+
private readonly TypoScriptServiceInterface $typoScriptService
33+
) {
34+
}
35+
36+
public function __invoke(ModifyLoadedPageTsConfigEvent $event): void
37+
{
38+
foreach (array_reverse($event->getRootLine()) as $page) {
39+
if (
40+
is_array($page) === false
41+
|| is_numeric($page['uid'] ?? null) === false
42+
) {
43+
throw new \RuntimeException('Given UID of rootline page is not numeric.', 1750834911);
44+
}
45+
46+
$files = $this->typoScriptService->getFilesForPage((int)$page['uid'], 'PageTSconfig');
47+
48+
foreach ($files as $file) {
49+
$event->addTsConfig($this->typoScriptService->getIncludeForFile($file));
50+
}
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)