filburt1
25 Jan 2006, 23:49
I finally found a way to emulate an event firing model from Java: callbacks. http://www.php.net/callback and http://www.php.net/create_function . Nowhere near as clean as Java with implementing interfaces and providing listeners, but it works:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Now $installer->upgrade() will fire the callback function as it executes, providing status updates. Calling the callback is as simple as:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Of course, in Java, it would be more like:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
...but that would require PHP 5 at least because of the abstractifiedness needed.
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Now $installer->upgrade() will fire the callback function as it executes, providing status updates. Calling the callback is as simple as:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Of course, in Java, it would be more like:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
...but that would require PHP 5 at least because of the abstractifiedness needed.