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.

Still trying to understand delegation. Why do this not work?

edited April 2007 in Vanilla 1.0 Help
I dont get it. From following other examples, I dont see why this doesnt work!

I have in one extension this control extended class:
class DojoFiles extends Control { function DojoFiles(&$Context) { $this->Name = 'DojoFiles'; $this->Control($Context); $this->CallDelegate('Constructor'); } function Render() { $this->CallDelegate('PreDojoFilesRender'); [..]

and then I have this in another extension:
if ( ('extension.php' == $Context->SelfUrl)) { function writeWikiAdd() { echo "<div style='width:100%;border-top:1px solid #999;border-bottom:1 px solid #999;background:#ddd;color:#999;padding:10px;'>"; echo "Have you checked out the wiki lately?</div>"; } if (isset($Context)) $Context->AddToDelegate('DojoFiles', 'PreDojoFilesRender', 'writeWikiAdd'); }

Comments

  • edited April 2007
    use the adddelegate outside the if statements. Use a debugger to find out if the function is being called or not.
  • nope. no effect :(
  • edited April 2007
    You just have to enable the wiki before u enable DojoFiles When u enable the wiki it adds the function to the Delegate collection, and when dojo runs, it looks up the delegate in the delegate collection, finds it and runs it. Now please use a debugger, If u did u would see that dojo checks to see if the delegates exists and doesn't find it. thats when u'll know to enable the wiki before dojo.
  • Depending of the order the extensions are loaded this might work or not.
    You do NOT need to use delegation with custom classes. This paradigm is made to offer hooks to the core from extensions.
  • ah ok. it was that simple.. we really do need to find a solution for this order of enabling. ah well.
This discussion has been closed.