I am building a website with TYPO3 9.5 and the Fluid Powered TYPO3 extensions, and I will need to access GET and POST variables in my fluidpages templates.
I tried to create a custom PageController to do this ; here is the class I added in …myext/Classes/Controller/PageController.php :
<?php
namespace MyVendor\MyExt\Controller;
use FluidTYPO3\Fluidpages\Controller;
class PageController extends Controller\PageController
{
protected function initializeViewVariables() {
parent::initializeViewVariables();
$GETarray = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET();
$this->view->assign('GET', $GETarray);
}
}
Unfortunately, this method never seems to be executed, as if my class weren’t found. When I display GET in the template file with <f:debug>{GET}</f:debug>, the result is always NULL whatever parameters I added in the URL. I tried assigning another, fixed variable with view->assign, and it’s NULL too. The code above does not have syntax errors, I’m using PHPStorm, which finds the parent class and shows that my initializeViewVariables method overrides the one in AbstractFluxController.
What I have tried :
- I followed what the documentation explains here : registered my extension with a key of the form
MyVendorName.Myextensionkey. I created aClassAliasMap.phpfile, even though I don’t think it would be needed for TYPO3 9.5 ? - in the
composer.jsonfile in my extension, I added :
and in the"autoload": { "psr-4": { "MyVendor\\MyExt\\": "Classes" } }composer.jsonfor my entire TYPO3 project, I put :
and I have verified that this path appears in"autoload": { "psr-4": { "MyVendor\\MyExt\\": "public/typo3conf/ext/myext/Classes" } }vendor/composer/autoload_psr4.phpafter I used thecomposer dump-autoloadcommand. I also have the autoload information in theext_emconf.phpfile - cleared all the caches in TYPO3
- I don’t have any error message either in TYPO3 or in the Apache logs when I view the page
And it still doesn’t work. Autoloading works if I call a method of a class in the Typoscript of a page with userFunc, however. Do you see what I am missing?