gabordemooij/redbean — pull request #137 by mauricoder (2012-03-14 17:00:02+00:00)
Title: Enable FUSE models to overload properties

We are working on a project with rich models, but we couldn't achive to overload properties on models, as the call to \__set is made to OODBBean and dies there. We wanted OODBBean::\__set to do all his work, but then pass the call to our Model::__set

We fixed OODBBean and added OODBBean::setProperties to achive this.

Our base model looks like this now:

class RedBeanModel extends RedBean_SimpleModel implements IModelBase
{

public funcion doSomething() {
}

public function __set( $prop, $value ) {
$value = DoSomethingElseWithValue($value);
// this mess is a workaround to redeban internals
$properties = $this->bean->getProperties();
$properties[$prop] = $value;
$this->bean->setProperties($properties);
$this->bean->$prop = $value;
}
}

Hope it's useful to somebody else