My background is in Propel, so I was hoping it would be a simple thing to override a magical getter in a Doctrine_Record (sfDoctrineRecord), but I\'m getting either a Segfault o
Configure Doctrine:
$manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
then:
public function getAnything()
{
return $this->_get('anything');
}
public function setAnything()
{
return $this->_set('anything', $value);
}
Try _get and _set methods.
Not sure about what do you wanted to do exactly, but here are some hints:
Doctrine (with ATTR_AUTO_ACCESSOR_OVERRIDE
attribute enabled, which is enabled by symfony) allows you to override certain component columns' getters just by defining getColumnName
methods in model class. That's why your getDisplayName
method can fall infinite loop which usually causes segfault.
To access/modify column value directly (bypassing custom (get|set)ters) you have to use _get('column_name')
and _set('column_name')
methods defined by Doctrine_Record
class.
All the $obj->getSomething()
, $obj->something
and $obj['something']
calls are actually magical. They are "redirected" to $obj->get('something')
which is only real way to access model data.
This works:
class FaqCategory extends BaseFaqCategory
{
public function __toString()
{
return $this->getCategory();
}
public function getDisplayName() {
if($this->_get("display_name") != "") {
$display_name = $this->_get("display_name");
} else {
$display_name = $this->getCategory();
}
return $display_name;
}
}