Permalink
Browse files

Added support for foreign keys in ArrayAccess methods

  • Loading branch information...
1 parent 068d32a commit 360dc9c53b5a02010477371a0e1ad36e352a18aa Niklas Närhinen committed Oct 8, 2010
Showing with 16 additions and 4 deletions.
  1. +16 −4 ArrayAccessBehavior.php
View
@@ -36,7 +36,13 @@ protected function addArrayAccessIssetChecker()
return "
public function offsetExists(\$offset)
{
- return \$this->getByName(\$offset) !== null;
+ try {
+ \$getter = 'get' . \$offset;
+ return \$this->\$getter() !== null;
+ }
+ catch (PropelException \$ex) {
+ return false;
+ }
}
";
}
@@ -46,7 +52,8 @@ protected function addArrayAccessGetter()
return "
public function offsetGet(\$offset)
{
- return \$this->getByName(\$offset);
+ \$getter = 'get' . \$offset;
+ return \$this->\$getter();
}
";
}
@@ -56,7 +63,11 @@ protected function addArrayAccessUnsetter()
return "
public function offsetUnset(\$offset)
{
- \$this->setByName(\$offset, null);
+ try {
+ \$setter = 'set' . \$offset;
+ \$this->\$setter(null);
+ }
+ catch (PropelException \$ex) { }
}
";
}
@@ -66,7 +77,8 @@ protected function addArrayAccessSetter()
return "
public function offsetSet(\$offset, \$value)
{
- \$this->setByName(\$offset, \$value);
+ \$setter = 'set' . \$offset;
+ \$this->\$setter(\$value);
}
";
}

0 comments on commit 360dc9c

Please sign in to comment.