HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

"_Override" magic method

ddumontddumont ✭✭
When you do this, are you passed the overridden function so that you can call it for some default behavior?

Also, do you know if you can "un-echo" stuff with php or otherwise modify the output buffer?

For example, override a method to change the input it gets called with (by calling it yourself) and then go fix up markup that it printed.

There was an error rendering this rich post.

Tagged:

Best Answer

  • ToddTodd Vanilla Staff
    Answer ✓
    In an override method you are given a reference to the object that you are overriding, so you can call the original method yourself on $Sender.

    PHP has an output buffer and it works like a stack. So if you call ob_start() then echo a bunch of stuff then call ob_get_clean() you will get everything in the output buffer from your call to ob_start(), but you'll leave the rest of the output buffer intact. Really good implementation actually.

Answers

  • ToddTodd Vanilla Staff
    Answer ✓
    In an override method you are given a reference to the object that you are overriding, so you can call the original method yourself on $Sender.

    PHP has an output buffer and it works like a stack. So if you call ob_start() then echo a bunch of stuff then call ob_get_clean() you will get everything in the output buffer from your call to ob_start(), but you'll leave the rest of the output buffer intact. Really good implementation actually.
  • nice, that's some great info... It gives me a route to go down when you're too busy and i'm twiddling my thumbs trying not to push the close button on your placeholder tasks. ;)

    There was an error rendering this rich post.

  • @ddumont & @Todd

    Are we talking about Magic Event or Magic Method?

    Seriously, Magic Method got override capability?

  • Override should be a last resort, monkey patch.

    grep is your friend.

Sign In or Register to comment.