. */ require_once 'phing/Task.php'; /** * Use introspection to "adapt" an arbitrary ( not extending Task, but with * similar patterns). * * @author Andreas Aderhold * @copyright © 2001,2002 THYRELL. All rights reserved * @version $Revision: 1.7 $ * @package phing */ class TaskAdapter extends Task { /** target object */ private $proxy; /** * Main entry point. * @return void */ function main() { if (method_exists($this->proxy, "setProject")) { try { // try to set project $this->proxy->setProject($this->project); } catch (Exception $ex) { $this->log("Error setting project in " . get_class($this->proxy) . PROJECT_MSG_ERR); throw new BuildException($ex); } } else { throw new Exception("Error setting project in class " . get_class($this->proxy)); } if (method_exists($this->proxy, "main")) { try { //try to call main $this->proxy->main($this->project); } catch (Exception $ex) { $this->log("Error in " . get_class($this->proxy), PROJECT_MSG_ERR); throw new BuildException($ex->getMessage()); } } else { throw new BuildException("Your task-like class '" . get_class($this->proxy) ."' does not have a main() method"); } } /** * Set the target object. * @param object $o * @return void */ function setProxy($o) { $this->proxy = $o; } /** * Gets the target object. * @return object */ function getProxy() { return $this->proxy; } }