Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Hijacking Vanilla classes via the ObjectFactory...
saladyears
New
So, I'm trying to decorate the Panel class to add some extra special functionality to it. Based on my close reading of the ObjectFactory documentation, it seems like the way to go is to extend Panel with my own class and then use the SetReference method to make my class the instantiated Panel class. Here's my test code in my extension's default.php file:
This, unfortunately, does nothing. I don't see Blargh output anywhere. I know that this file is being parsed because if I put random crap in it, I get PHP errors. I am a C++ ninja, not a PHP guru, so I don't know if the problem is my PHP or that this just isn't possible, though it seemed like this was exactly the kind of thing the ObjectFactory is for. Anyone got any ideas?
class CONPanel extends Panel
{
function CONPanel(&$Context)
{
// Silly PHP doesn't chain base class constructors.
Panel::Panel($Context);
echo '<h1 class="StartNew">Blargh!!</h1>';
}
}
// Replace the Panel class in the object factory with our own.
$Context->ObjectFactory->SetReference("Panel", "CONPanel");
This, unfortunately, does nothing. I don't see Blargh output anywhere. I know that this file is being parsed because if I put random crap in it, I get PHP errors. I am a C++ ninja, not a PHP guru, so I don't know if the problem is my PHP or that this just isn't possible, though it seemed like this was exactly the kind of thing the ObjectFactory is for. Anyone got any ideas?
0
This discussion has been closed.
Comments
$this->Panel($Context);
But you're also right: extensions are loaded after the core controls, so you are only able to override the other, non-core controls.You're on the right track though!