Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix h:uri.action viewhelper - $uriBuilder->setRequest($request) #94

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

TrueType
Copy link

@TrueType TrueType commented Oct 9, 2024

Hi Helmut,
please merge this little change. I still use the viewhelper for AJAX uri generation in some projects. It is simple and straightforward. The missing request object with the uribuilder prevents it from working with TYPO3v12. Thx.
Henri Nathanson

@helhum helhum merged commit 12acf2e into helhum:v12 Oct 10, 2024
1 of 12 checks passed
@wazum
Copy link

wazum commented Oct 11, 2024

This change results in an exception now:

TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::setRequest(): Argument #1 ($request) must be of type TYPO3\CMS\Extbase\Mvc\RequestInterface, TYPO3\CMS\Core\Http\ServerRequest given, called in /var/www/html/vendor/helhum/typoscript-rendering/Classes/Uri/TyposcriptRenderingUri.php on line 85

@TrueType
Copy link
Author

@wazum
Copy link

wazum commented Oct 11, 2024

We had this patch in place with the previous commit … all half-baked solutions.

diff --git a/Classes/Uri/TyposcriptRenderingUri.php b/Classes/Uri/TyposcriptRenderingUri.php
index 6f8b34d0..a75a7299 100644
--- a/Classes/Uri/TyposcriptRenderingUri.php
+++ b/Classes/Uri/TyposcriptRenderingUri.php
@@ -65,9 +65,9 @@ class TyposcriptRenderingUri extends Uri
             $extensionName = $request->getControllerExtensionName();
         }
         if ($contextRecord === 'current') {
-            if (
-                $pluginName !== $request->getPluginName()
-                || $extensionName !== $request->getControllerExtensionName()
+            if ($request instanceof \TYPO3\CMS\Extbase\Mvc\Request &&
+               ($pluginName !== $request->getPluginName() ||
+               $extensionName !== $request->getControllerExtensionName())
             ) {
                 $contextRecord = 'currentPage';
             } else {
@@ -132,9 +132,9 @@ class TyposcriptRenderingUri extends Uri
             $extensionName = $request->getWidgetContext()->getParentExtensionName();
         }
         if ($contextRecord === 'current') {
-            if (
-                $pluginName !== $request->getWidgetContext()->getParentPluginName()
-                || $extensionName !== $request->getWidgetContext()->getParentExtensionName()
+            if ($request instanceof \TYPO3\CMS\Extbase\Mvc\Request &&
+                ($pluginName !== $request->getPluginName() ||
+                $extensionName !== $request->getControllerExtensionName())
             ) {
                 $contextRecord = 'currentPage';
             } else {

@TrueType
Copy link
Author

I have seen these fixes. I decided to not go that way, because it seemed not clean enough I created plugins and rendered them with <f:cObject typoscriptObjectPath="lib.xy">. I have depencies here between an EXT:sitepackage and EXT:my_extbase_business ...

@TrueType
Copy link
Author

TrueType commented Dec 2, 2024

Sry, if I messed things up here. I used the extension to create AJAX uris. That may have never been the intended use of this extension. I switched to typeNum uris instead.
{f:uri.action('pageType:'<your_typenum>',controller:'xy',action:'xy')}
The typoscript definition can use a USER_INT. So in case you have only non-cached AJAX calls, one can omit the double declaration within ext_localconf.php -> configurePlugin().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants