You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Xyster does allow for setValue() setter methods in entities through __set(), but it does not allow for setValue() through __get(). It would be nice to have both in there. Currently, we have subclassed the Xyster_Orm_Entity and added the following method:
/**
* Override __get() to call getName() if available.
* The implementation of Xyster_Orm_Entity does allow for
* implementing a setter method in the entity, but it doesn't allow
* for a getter.
*
* @param string $name
* @return mixed The value of the field
* @throws Xyster_Orm_Entity_Exception if the field is invalid
*/
public function __get($name)
{
// Check if a getter is implemented. If yes, then call it.
if (array_key_exists($name, $this->_values)) {
$method = 'get'.ucfirst($name);
if (method_exists($this, $method)) {
return $this->$method();
}
}
// Otherwise, hand over control to the parent getter.
return parent::__get($name);
}
It would be nice if such feature would be incorporated in Xyster. We only have allowed setter methods for the values that are inside the entity, because we didn't yet see the implications of allowing a getter for any property and because we only needed support for the direct data values. Maybe it would have been okay to allow any kind of getter by doing it somewhat like this:
public function __get($name)
{
// Check if a getter is implemented. If yes, then call it.
$method = 'get'.ucfirst($name);
if (method_exists($this, $method)) {
return $this->$method();
}
// Otherwise, hand over control to the parent getter.
return parent::__get($name);
}
One possible conflict that I see: there is a method named getErrors() in the Entity class, so a getter for an "errors" field could yield unexpected results. Reporter: Maurice Makaay Begin: 2009-08-24 Completed: 0
The text was updated successfully, but these errors were encountered:
Xyster does allow for setValue() setter methods in entities through __set(), but it does not allow for setValue() through __get(). It would be nice to have both in there. Currently, we have subclassed the Xyster_Orm_Entity and added the following method:
It would be nice if such feature would be incorporated in Xyster. We only have allowed setter methods for the values that are inside the entity, because we didn't yet see the implications of allowing a getter for any property and because we only needed support for the direct data values. Maybe it would have been okay to allow any kind of getter by doing it somewhat like this:
One possible conflict that I see: there is a method named getErrors() in the Entity class, so a getter for an "errors" field could yield unexpected results.
Reporter: Maurice Makaay
Begin: 2009-08-24
Completed: 0
The text was updated successfully, but these errors were encountered: