Commit 1d1f0556 authored by chtito's avatar chtito

allowing customisation of the invokers prefixes

parent ac34e4bf
......@@ -121,6 +121,14 @@ final class Doctrine {
* accessor invoking attribute
*/
const ATTR_ACCESSORS = 18;
/**
* accessor invoking prefix get
*/
const ATTR_ACCESSOR_PREFIX_GET = 22;
/**
* accessor invoking prefix set
*/
const ATTR_ACCESSOR_PREFIX_SET = 23;
......
......@@ -119,6 +119,8 @@ abstract class Doctrine_Configurable {
case Doctrine::ATTR_QUOTE_IDENTIFIER:
case Doctrine::ATTR_PORTABILITY:
case Doctrine::ATTR_DEFAULT_TABLE_TYPE:
case Doctrine::ATTR_ACCESSOR_PREFIX_GET:
case Doctrine::ATTR_ACCESSOR_PREFIX_SET:
break;
case Doctrine::ATTR_SEQCOL_NAME:
......@@ -203,7 +205,7 @@ abstract class Doctrine_Configurable {
public function getAttribute($attribute) {
$attribute = (int) $attribute;
if($attribute < 1 || $attribute > 21)
if($attribute < 1 || $attribute > 23)
throw new Doctrine_Exception('Unknown attribute.');
if( ! isset($this->attributes[$attribute])) {
......
......@@ -1009,9 +1009,13 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*/
public function invokeSet(Doctrine_Record $record, $name, $value) {
if( ! ($this->getAttribute(Doctrine::ATTR_ACCESSORS) & Doctrine::ACCESSOR_SET))
return $value;
return $value;
$prefix = $this->getAttribute(Doctrine::ATTR_ACCESSOR_PREFIX_SET);
if (!$prefix)
$prefix = 'set';
$method = 'set' . $name;
$method = $prefix . $name;
if(method_exists($record, $method)) {
return $record->$method($value);
......@@ -1028,7 +1032,11 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
if( ! ($this->getAttribute(Doctrine::ATTR_ACCESSORS) & Doctrine::ACCESSOR_GET))
return $value;
$method = 'get' . $name;
$prefix = $this->getAttribute(Doctrine::ATTR_ACCESSOR_PREFIX_GET);
if (!$prefix)
$prefix = 'get';
$method = $prefix . $name;
if(method_exists($record, $method)) {
return $record->$method($value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment