Skip to content

Commit 611a8bc

Browse files
committed
Rename AjaxActionViewHelper to ActionViewHelper
To be consistent with the link view helper and also to clarify, that the URI generated might be used for different purposes than just Ajax, like download links for example, we rename the view helper but keep the old one to provide backwards compatibility. Usage of the old one is deprecated though.
1 parent a823cd4 commit 611a8bc

9 files changed

Lines changed: 63 additions & 5 deletions

File tree

Classes/ViewHelpers/Uri/AjaxActionViewHelper.php renamed to Classes/ViewHelpers/Uri/ActionViewHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
* = Examples =
2626
*
2727
* <code title="URI to the show-action of the current controller">
28-
* <t:uri.ajaxAction action="show" />
28+
* <t:uri.action action="show" />
2929
* </code>
3030
* <output>
3131
* index.php?id=123&tx_typoscriptrendering[context]={"record":"tt_content_123","path":"tt_content.list.20.myextension_plugin"}&tx_myextension_plugin[action]=show&tx_myextension_plugin[controller]=Standard&cHash=xyz
3232
* (depending on the current page and your TS configuration)
3333
* </output>
3434
*/
35-
class AjaxActionViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
35+
class ActionViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
3636
{
3737
use CompileWithRenderStatic;
3838

Migrations/Code/ClassAliasMap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
return [
3+
'Helhum\\TyposcriptRendering\\ViewHelpers\\Uri\\AjaxActionViewHelper' => \Helhum\TyposcriptRendering\ViewHelpers\Uri\ActionViewHelper::class,
4+
];
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
namespace {
3+
die('Access denied');
4+
}
5+
namespace Helhum\TyposcriptRendering\ViewHelpers\Uri {
6+
/** @deprecated */
7+
class AjaxActionViewHelper extends \Helhum\TyposcriptRendering\ViewHelpers\Uri\ActionViewHelper
8+
{
9+
}
10+
}

Tests/Functional/Fixtures/Frontend/Basic.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ lib.fluid.file = EXT:typoscript_rendering/Tests/Functional/Fixtures/Frontend/Tem
3232

3333
lib.viewHelper = FLUIDTEMPLATE
3434
lib.viewHelper.file = EXT:typoscript_rendering/Tests/Functional/Fixtures/Frontend/ViewHelperTemplate.html
35+
lib.linkViewHelper = FLUIDTEMPLATE
36+
lib.linkViewHelper.file = EXT:typoscript_rendering/Tests/Functional/Fixtures/Frontend/LinkViewHelperTemplate.html
37+
lib.oldViewHelper = FLUIDTEMPLATE
38+
lib.oldViewHelper.file = EXT:typoscript_rendering/Tests/Functional/Fixtures/Frontend/OldViewHelperTemplate.html
3539
tt_content.typoscriptrendering_plugintest.20 = TEXT
3640

3741
page = PAGE
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml"
2+
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
3+
xmlns:t="http://typo3.org/ns/Helhum/TyposcriptRendering/ViewHelpers"
4+
data-namespace-typo3-fluid="true">
5+
<t:link.action controller="Foo" pluginName="pluginTest" extensionName="TyposcriptRendering" contextRecord="currentPage">Link</t:link.action>
6+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml"
2+
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
3+
xmlns:t="http://typo3.org/ns/Helhum/TyposcriptRendering/ViewHelpers"
4+
data-namespace-typo3-fluid="true">
5+
<t:uri.ajaxAction controller="Foo" pluginName="pluginTest" extensionName="TyposcriptRendering" contextRecord="currentPage"/>
6+
</html>

Tests/Functional/Fixtures/Frontend/ViewHelperTemplate.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
33
xmlns:t="http://typo3.org/ns/Helhum/TyposcriptRendering/ViewHelpers"
44
data-namespace-typo3-fluid="true">
5-
<t:uri.ajaxAction controller="Foo" pluginName="pluginTest" extensionName="TyposcriptRendering" contextRecord="currentPage"/>
5+
<t:uri.action controller="Foo" pluginName="pluginTest" extensionName="TyposcriptRendering" contextRecord="currentPage"/>
66
</html>

Tests/Functional/RenderingTest.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,30 @@ public function emailViewHelperWorksAlsoWithSpamProtection()
4242
public function viewHelperOutputsUri()
4343
{
4444
$requestArguments = ['url' => $this->getRenderUrl(1, 1, 'lib.viewHelper')];
45-
$expectedContent = '/index.php?id=1&amp;L=1&amp;tx_typoscriptrendering%5Bcontext%5D=%7B%22record%22%3A%22pages_1%22%2C%22path%22%3A%22tt_content.typoscriptrendering_plugintest.20%22%7D&amp;tx_typoscriptrendering_plugintest%5Bcontroller%5D=Foo&amp;cHash=';
46-
$this->assertSame(0, strpos(trim($this->fetchFrontendResponse($requestArguments)->getContent()), $expectedContent));
45+
$actualContentWithoutCHash = preg_replace('/&amp;cHash=[a-z0-9]*/', '', trim($this->fetchFrontendResponse($requestArguments)->getContent()));
46+
$expectedContent = '/index.php?id=1&amp;L=1&amp;tx_typoscriptrendering%5Bcontext%5D=%7B%22record%22%3A%22pages_1%22%2C%22path%22%3A%22tt_content.typoscriptrendering_plugintest.20%22%7D&amp;tx_typoscriptrendering_plugintest%5Bcontroller%5D=Foo';
47+
$this->assertSame($expectedContent, $actualContentWithoutCHash);
48+
}
49+
50+
/**
51+
* @test
52+
*/
53+
public function oldViewHelperOutputsUri()
54+
{
55+
$requestArguments = ['url' => $this->getRenderUrl(1, 1, 'lib.oldViewHelper')];
56+
$actualContentWithoutCHash = preg_replace('/&amp;cHash=[a-z0-9]*/', '', trim($this->fetchFrontendResponse($requestArguments)->getContent()));
57+
$expectedContent = '/index.php?id=1&amp;L=1&amp;tx_typoscriptrendering%5Bcontext%5D=%7B%22record%22%3A%22pages_1%22%2C%22path%22%3A%22tt_content.typoscriptrendering_plugintest.20%22%7D&amp;tx_typoscriptrendering_plugintest%5Bcontroller%5D=Foo';
58+
$this->assertSame($expectedContent, $actualContentWithoutCHash);
59+
}
60+
61+
/**
62+
* @test
63+
*/
64+
public function linkViewHelperOutputsUri()
65+
{
66+
$requestArguments = ['url' => $this->getRenderUrl(1, 1, 'lib.linkViewHelper')];
67+
$actualContentWithoutCHash = preg_replace('/&amp;cHash=[a-z0-9]*/', '', trim($this->fetchFrontendResponse($requestArguments)->getContent()));
68+
$expectedContent = '<a href="/index.php?id=1&amp;L=1&amp;tx_typoscriptrendering%5Bcontext%5D=%7B%22record%22%3A%22pages_1%22%2C%22path%22%3A%22tt_content.typoscriptrendering_plugintest.20%22%7D&amp;tx_typoscriptrendering_plugintest%5Bcontroller%5D=Foo">Link</a>';
69+
$this->assertSame($expectedContent, $actualContentWithoutCHash);
4770
}
4871
}

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
"extension-key": "typoscript_rendering",
6161
"app-dir": ".Build",
6262
"web-dir": ".Build/public"
63+
},
64+
"typo3/class-alias-loader": {
65+
"class-alias-maps": [
66+
"Migrations/Code/ClassAliasMap.php"
67+
]
6368
}
6469
}
6570
}

0 commit comments

Comments
 (0)