Philipp Rotmann, Linksystem Muenchen wrote:
>On 08.08.02 (04:14), Pascal Van Hecke wrote:
>
>
>>Apart from Torben Nehmer at
>>http://www.nathan-syntronics.de/midgard/oop/extending.html
>>, has anybody done some work here already and is
>>willing to share?
>>
>>
>
>Well, not everything at the above-mentioned URL is up-to-date
>with regard to the classes we wrapped for production use, but we
>still don't have more than CPerson, CUser, CArticle, CTopic,
>CEvent and CGroup.
>
> phr
>
>
just a few suggestions for those classes.
you have massive var copying
$this->abstract = $object->abstract;
$this->abstract = $object->abstract;
.....
you could use..
foreach (get_object_vars($object) as $k=>$v) {
$this->$k = $v;
}
I would also suggest creating a base class Midgard_Utils
so that the article create would look something like this..
class Midgard_Article extends MidgardArticle {
function create() {
return Midgard_Utils::create('article');
}
And all the generic stuff can go in Midgard_Utils.
class Midgard_Utils {
function create($name) {
$args = func_get_args();
array_shift($args);
$newid =
call_user_func_array(array("Midgard{$name}",'create'),$args);
if (!$newid) {
return false;
}
$newobject =
call_user_func_array("mgd_get_{$name}",array($newid));
Midgard_Utils::_copyMgdData($newobject);
return $newid;
}
function _copyMgdData(&$object) {
foreach (get_object_vars($object) as $k=>$v) {
$this->$k = $v;
}
}
---
due to php's wierd and wonderfull static object call stuff. $this in a
static method call is actually the $this of the calling class instance -
using static method calls in effect gives you quasi multiple inheritance...
regards
alan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]