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:
PHP Code:
// go-go anonymous functions
$callback = create_function(
"\$step, \$stepcount, \$status, \$result = false",
"if (\$step >= 0)
{
vbms_installer_update_progress(\$step, \$stepcount, \$status);
}
else
{
vbms_installer_die(\$status, \$result);
}");
$installer->upgrade($callback);
Now $installer->upgrade() will fire the callback function as it executes, providing status updates. Calling the callback is as simple as:
PHP Code:
$callback($step, $stepcount, $status);
Of course, in Java, it would be more like:
Code:
installer.addUpdateListener(new InstallerUpdateListener()
{
public void statusChanged(int step, int stepCount, String status, Object result)
{
...
}
});
installer.upgrade();
...but that would require PHP 5 at least because of the abstractifiedness needed.