Jack Bates wrote:
this does beg the question why don't you know the classname at runtime..
seems to be a slight design flaw and may make sense for you to post the
full problem (you must have chosen to implement this for a reason..)
The full problem is: I started off with a "DeployTask" for deploying a
new instance of my web project to DreamHost:
http://cgi.sfu.ca/~jdbates/tmp/php/200812170/DeployTask.class.phps
(It is a "task" in the symfony framework, but basically the
DeployTask::execute() method gets called)
The task takes about thirty minutes to run, so I broke it up into steps.
After each step, it updates a database row so that a user who started
the task through a web interface can monitor its progress.
Great so far. Now I decided to create an "UpdateTask" for updating
deployed instances to the latest version of my code:
http://cgi.sfu.ca/~jdbates/tmp/php/200812170/UpdateTask.class.phps
Of course it also takes a long time to run, so my first iteration just
extends the DeployTask and defines different steps. UpdateTask inherits
DeployTask::execute(), which drives the steps and updates the database.
Unfortunately, in the inherited DeployTask::execute(), "self::$STEPS"
does not refer to UpdateTask::$STEPS, it refers to DeployTask::$STEPS
: (
Yup I follow, been here myself too; infact doing very similar at the mo
making an event handler / listener for the hell of it!
anyhow.. stick this in you're DeployTask and run it :p
protected function execute($arguments = array(), $options = array()) {
// you're existing code here up to..
$job->pid = getmypid();
$thisClass = new ReflectionClass( get_class($this) );
$steps = $thisClass->getStaticPropertyValue('STEPS');
while ($job->step < count($steps))
{
$job->save();
call_user_func(array($this, $steps[$job->step]), $arguments, $options);
$job->step++;
}
$job->delete();
}
untested but should work :)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php