Commit 30cee97 1 parent 98e891e commit 30cee97 Copy full SHA for 30cee97
File tree 6 files changed +114
-0
lines changed
rules/TYPO3v10/TypoScript
rules-tests/TYPO3v10/TypoScript/RemoveUseCacheHashFromTypolink
6 files changed +114
-0
lines changed Original file line number Diff line number Diff line change 17
17
"a9f/fractor-doc-generator" : " ^0.2" ,
18
18
"a9f/fractor-extension-installer" : " ^0.2" ,
19
19
"a9f/fractor-fluid" : " ^0.2" ,
20
+ "a9f/fractor-typoscript" : " ^0.2" ,
20
21
"a9f/fractor-xml" : " ^0.2" ,
21
22
"a9f/fractor-yaml" : " ^0.2"
22
23
},
Original file line number Diff line number Diff line change 3
3
declare (strict_types=1 );
4
4
5
5
use a9f \Typo3Fractor \TYPO3v10 \Fluid \RemoveNoCacheHashAndUseCacheHashAttributeFractor ;
6
+ use a9f \Typo3Fractor \TYPO3v10 \TypoScript \RemoveUseCacheHashFromTypolink ;
6
7
use a9f \Typo3Fractor \TYPO3v10 \Yaml \EmailFinisherFractor ;
7
8
use a9f \Typo3Fractor \TYPO3v10 \Yaml \TranslationFileFractor ;
8
9
use Symfony \Component \DependencyInjection \Loader \Configurator \ContainerConfigurator ;
16
17
$ services ->set (EmailFinisherFractor::class);
17
18
$ services ->set (TranslationFileFractor::class);
18
19
$ services ->set (RemoveNoCacheHashAndUseCacheHashAttributeFractor::class);
20
+ $ services ->set (RemoveUseCacheHashFromTypolink::class);
19
21
};
Original file line number Diff line number Diff line change
1
+ page = PAGE
2
+ page.10 = TEXT
3
+ page.10.value = Link to page 23
4
+ page.10.typolink {
5
+ parameter = 23
6
+ useCacheHash = 1
7
+ }
8
+
9
+ page.20 = TEXT
10
+ page.20.value = Link to page 42
11
+ page.20.typolink.parameter = 42
12
+ page.20.typolink.useCacheHash = 1
13
+ -----
14
+ page = PAGE
15
+ page.10 = TEXT
16
+ page.10.value = Link to page 23
17
+ page.10.typolink {
18
+ parameter = 23
19
+ }
20
+
21
+ page.20 = TEXT
22
+ page.20.value = Link to page 42
23
+ page.20.typolink.parameter = 42
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace a9f \Typo3Fractor \Tests \TYPO3v10 \Fluid ;
6
+
7
+ use a9f \Fractor \Testing \PHPUnit \AbstractFractorTestCase ;
8
+ use Iterator ;
9
+ use PHPUnit \Framework \Attributes \DataProvider ;
10
+
11
+ final class RemoveUseCacheHashFromTypolinkTest extends AbstractFractorTestCase
12
+ {
13
+ #[DataProvider('provideData ' )]
14
+ public function test (string $ filePath ): void
15
+ {
16
+ $ this ->doTestFile ($ filePath );
17
+ }
18
+
19
+ public static function provideData (): Iterator
20
+ {
21
+ return self ::yieldFilesFromDirectory (__DIR__ . '/Fixtures ' , '*.typoscript ' );
22
+ }
23
+
24
+ public function provideConfigFilePath (): ?string
25
+ {
26
+ return __DIR__ . '/config/fractor.php ' ;
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ use a9f \Fractor \Configuration \FractorConfiguration ;
6
+ use a9f \Typo3Fractor \TYPO3v10 \TypoScript \RemoveUseCacheHashFromTypolink ;
7
+
8
+ return FractorConfiguration::configure ()
9
+ ->withRules ([RemoveUseCacheHashFromTypolink::class]);
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace a9f \Typo3Fractor \TYPO3v10 \TypoScript ;
6
+
7
+ use a9f \FractorTypoScript \AbstractTypoScriptFractor ;
8
+ use a9f \FractorTypoScript \TypoScriptStatementsIterator ;
9
+ use Helmich \TypoScriptParser \Parser \AST \Operator \Assignment ;
10
+ use Helmich \TypoScriptParser \Parser \AST \Statement ;
11
+ use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
12
+ use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
13
+
14
+ /**
15
+ * @changelog https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/10.0/Deprecation-88406-SetCacheHashnoCacheHashOptionsInViewHelpersAndUriBuilder.html
16
+ */
17
+ final class RemoveUseCacheHashFromTypolink extends AbstractTypoScriptFractor
18
+ {
19
+ public function refactor (Statement $ statement ): null |Statement |int
20
+ {
21
+ if (! $ statement instanceof Assignment) {
22
+ return $ statement ;
23
+ }
24
+
25
+ // for some weird reason, "foo.bar.baz = 1" leads to "relativeName" being "foo.bar.baz"
26
+ if (! str_ends_with ($ statement ->object ->absoluteName , '.typolink.useCacheHash ' )) {
27
+ return $ statement ;
28
+ }
29
+
30
+ $ this ->hasChanged = true ;
31
+ return TypoScriptStatementsIterator::REMOVE_NODE ;
32
+ }
33
+
34
+ public function getRuleDefinition (): RuleDefinition
35
+ {
36
+ return new RuleDefinition ('Remove useCacheHash TypoScript setting ' , [new CodeSample (
37
+ <<<'CODE_SAMPLE'
38
+ typolink {
39
+ parameter = 3
40
+ useCacheHash = 1
41
+ }
42
+ CODE_SAMPLE
43
+ ,
44
+ <<<'CODE_SAMPLE'
45
+ typolink {
46
+ parameter = 3
47
+ }
48
+ CODE_SAMPLE
49
+ )]);
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments