allowing customisation of the invokers prefixes
This commit is contained in:
parent
ac34e4bfc0
commit
1d1f0556b2
3 changed files with 22 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue