Bug #70008
closedextbase use of class variables don't work
0%
Description
I try to build a BE extension with only one view but different action controllers.
To access the view from any any action controller I use:
$this->view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:hgaxlfedit/Resources/Private/Templates/Edit/init.html'));
This works, but the current action controller ist only responcible for a part of the view. If the view will be rendered, only the values from the current controller are updated, the other values are gone.
Therefore I change my concept and defined class variables for the action controller ( e.g. $Temp). The specific action controller should only modifing the class variables and on the end redirect to the central view, which has the only task to assign all varibles to the view.
But this is not working!
If I define $Temp
/** * Temp String * * @var String */ private $Temp ='Init';
in the class, I can read the value from every action controller, but if I do
$this->Temp = "Test Var";
and I read $this->Temp in the same controller I get the modified value 'Test Var'.
But if I try do read $this->Temp in another action controller, e. g. from my main view, I get the value 'init' again.
It seem to me, that the action controller only writes the data to a copy of the class variable $Temp, but not to the class variable itself.
This looks for me as a bug!
Files
Updated by Wouter Wolters about 9 years ago
- Status changed from New to Needs Feedback
Can you create a test extension that shows your problem?
Without this I don't think we can be of any help here.
Furthermore I suggest to name all your templates Uppercase.
Not init.html but Init.html
Updated by Hans-Georg Althoff about 9 years ago
You can find the current state of the extension in the attached file.
There are also error_logs implemented, which shows the problem.
Updated by Wouter Wolters about 9 years ago
- Status changed from Needs Feedback to Rejected
Hi Hans,
I had a look at your code and what you want to achieve isn't possible with your code structure.
If you set $Temp in initAction to "Test Var" this won't be available in xlfFilesAction and defaultAction.
This is just how PHP works. No magic at all. Thus if you want to have this variable available in all actions you need to pass it with every action link you create.
I'll reject this issue because this is not a bug at all! I suggest you to read this book: http://www.extbase-book.org/