-
-
Notifications
You must be signed in to change notification settings - Fork 213
Frontenduser cannot be correctly extended due to getInstance bug #2969
Comments
Ahhh.... this is not a bug. But it remains true that FrontendUser is Extremely difficult to extend --- Originally created by wal5hy on March 30th, 2011, at 10:33am |
How did you solve it finally? --- Originally created on March 31st, 2011, at 11:41am |
Haven't quite got round to it yet, but here's my thinking
edit: struggling to get the code to format properly sorry If FrontendUser is already initialised (which it is) then I replace it with MyFrontendUser, before doing that I pass the data across from the old class to the new Does this seem like the most logical approach? I really can't think of anything else. Problems with this approach: Possible solutions:
Other thoughts: I also can't help but think that some of the postLogin and postLogout hook should be moved to FrontendUser rather than be in ModuleLogin and ModuleLogout --- Originally created by wal5hy on March 31st, 2011, at 12:35pm |
Another option maybe to make FrontendUser interface and specify in a config file what class implements the interface --- Originally created by wal5hy on April 1st, 2011, at 09:31am |
Or maybe create a static var in FrontendUser called "className" then change this to the name of the class to be instantiated in getInstance. --- Originally created by wal5hy on April 1st, 2011, at 09:37am |
Did you define a --- Originally created on June 15th, 2011, at 01:27pm |
yes, but since this line exists in index.php line: 59 $this->import('FrontendUser', 'User'); the base class ( FrontendUser ) is being called before I can override functionality. maybe a potential fix is this (changing FrontendUser.php )
Then in a config file add This means that any other module which uses $this->import('FrontendUser', 'User') --- Originally created by wal5hy on June 15th, 2011, at 02:58pm |
I need this, too. Was it solved somehow, since you closed it, Leo? Cheers --- Originally created by icarus on September 5th, 2011, at 02:43pm |
Implemented in 2fd7ffa. --- Originally created on September 14th, 2011, at 12:51pm |
--- Originally completed on September 14th, 2011, at 12:51pm |
The Frontenduser class cannot be correctly extended due to a bug in the implementation of getInstance method.
Current method line 173
self::$objInstance = new FrontendUser();
Corrected
self::$objInstance = new self();
This allows the extended class to be instantiated as the singleton, rather than FrontendUser class
when using
->import('Frontenduser', 'User')
or->import('myextendedFrontenduser')
The extended class is not correctly initialised by the framework without this method being changed.
For full conversation about why I think this is an error see the forum post here: [http://www.contao-community.org/viewtopic.php?f=9&t=2899]
--- Originally created by wal5hy on March 30th, 2011, at 01:04am (ID 2969)
The text was updated successfully, but these errors were encountered: