note 54125 deleted from language.oop5.autoload by nlopess

From: Date: Fri, 24 Jun 2005 12:13:18 +0000
Subject: note 54125 deleted from language.oop5.autoload by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-90891@lists.php.net to get a copy of this message
Note Submitter: christopher dot klein at ecw dot de ---- I'am currently developing an application with Propel. I still don't designed all objects with their specific properties. But I have already a rudementary framework, which makes use of the Propel-Methods (getter and setter). Imagine, you have a class Example_ManagementFileObject. The class handles operations in conjunction with a FileObject. The FileObject ist still not designed - because of different reasons. This Example_ManagementFileObject looks like this: class Example_ManagementFileObject { public static $objFile; public static function writeDataToFile($nameOfFile, $stringToWrite) { self::$objFile = new FileObject() self::$objFile->setNameOfFile($nameOfFile); self::$objFile->setString($stringToWrite); self::$objFile->setSave(1); } pulbic static function getSavedString() { if (is_object(self::$objFile)) { return self::$objFile->getString(); } return false; } } ---- Now we use a method, which I want to call "Extreme Prototyping". We test our Example_ManagementFileObject::writeDataToFile()-Method: ---- /** * __autoload($className) * Searches all defined search-pathes. * if the new object does not exists, it will be created */ function __autoload($className) { $arrPath = array('../classes/''); for ($i = 0, $m = sizeof($arrSearchPath); $i < $m; $i++) { if (file_exists($arrPath[$i].$className.".php5")) { include_once($arrPath[$i].$className.".php5"); return true; } } $str = 'class '.$className.' { private static $objInstances = array(); public function __construct() { self::$objInstances[] = $this; } private $objVals = array(); public static $test = "TEST"; public function __call($m, $a) { if (preg_match("/^(set|get)(.*)/",$m,$arrRet)) { if ($arrRet[1] == "get") { if ($this->objVals[$arrRet[2]]) { return $this->objVals[$arrRet[2]]; } } else { $this->objVals[$arrRet[2]] = $a[0]; return true; } } } public function dumpVar() { var_dump($this); } public static function dumpObjects() { var_dump(self::$objInstances); print "</pre>"; } }'; eval($str); } $myString = "Extreme Prototyping"; Example_ManagementFileObject::writeDataToFile($testFile, $myString); if (Example_ManagementFileObject::getSavedString() == $myString) { print "Extreme Prototyping was successful."; } ---- I Hope, you could use it =;) Best regards, Christopher Klein

« previous php.notes (#90891) next »