LennardF1989
Member
Hello everyone,
I have been working on an extension for a client of mine and ran across a slight problem, which I managed to solve, but with a workaround.
Consider the following:
- XenForo_Model has a method called "prepareStateLimitFromConditions" I want to override.
- I have a MyExtension_Model_Post and a MyExtension_Model_Thread class, both registered in my listener to extend the originals. They originally already override a lot of methods, except for "prepareStateLimitFromConditions", which is yet to be implemented at this point.
Since both these class have to use the same "prepareStateLimitFromConditions"-method, I figured I'd just make a MyExtension_Model extending XFCP_MyExtension_Model with said method defined.
Since it's no use trying to add a listener for XenForo_Model, I figured I just add two extends to XenForo_Model_Post and XenForo_Model_Thread. The first one to MyExtension_Model, the second to either MyExtension_Model_Post or MyExtension_Model_Thread respectively.
However, this generates an error where it tells me you can't extend from the same class twice.
Eventually I "solved" it by removing changing MyExtension_Model back to just a class, making the method static, then override method in the two classes twice, just calling the static method.
I was wondering, where did I go wrong, because I don't like my "hack", and it seems my initial way of solving it should have worked.
I have been working on an extension for a client of mine and ran across a slight problem, which I managed to solve, but with a workaround.
Consider the following:
- XenForo_Model has a method called "prepareStateLimitFromConditions" I want to override.
- I have a MyExtension_Model_Post and a MyExtension_Model_Thread class, both registered in my listener to extend the originals. They originally already override a lot of methods, except for "prepareStateLimitFromConditions", which is yet to be implemented at this point.
Since both these class have to use the same "prepareStateLimitFromConditions"-method, I figured I'd just make a MyExtension_Model extending XFCP_MyExtension_Model with said method defined.
Since it's no use trying to add a listener for XenForo_Model, I figured I just add two extends to XenForo_Model_Post and XenForo_Model_Thread. The first one to MyExtension_Model, the second to either MyExtension_Model_Post or MyExtension_Model_Thread respectively.
However, this generates an error where it tells me you can't extend from the same class twice.
Eventually I "solved" it by removing changing MyExtension_Model back to just a class, making the method static, then override method in the two classes twice, just calling the static method.
I was wondering, where did I go wrong, because I don't like my "hack", and it seems my initial way of solving it should have worked.