Skip to content

Instantly share code, notes, and snippets.

@sminnee
Created February 24, 2010 22:49
Show Gist options
  • Select an option

  • Save sminnee/313979 to your computer and use it in GitHub Desktop.

Select an option

Save sminnee/313979 to your computer and use it in GitHub Desktop.
Index: sapphire/core/model/VirtualPage.php
===================================================================
--- sapphire/core/model/VirtualPage.php (revision 99837)
+++ sapphire/core/model/VirtualPage.php (working copy)
@@ -209,13 +209,12 @@
* @return mixed
*/
function __get($field) {
- $return = parent::__get($field);
- if ($return === null) {
- if($this->copyContentFrom()->hasMethod($funcName = "get$field")) {
- $return = $this->copyContentFrom()->$funcName();
- } else if($this->copyContentFrom()->hasField($field)) {
- $return = $this->copyContentFrom()->getField($field);
- }
+ if(parent::hasMethod($funcName = "get$field")) {
+ return $this->$funcName();
+ } else if($this->hasField($field)) {
+ return $this->getField($field);
+ } else {
+ return $this->copyContentFrom()->$field;
}
return $return;
@@ -228,14 +227,10 @@
* @param string $args
*/
function __call($method, $args) {
- try {
+ if(parent::hasMethod($method)) {
return parent::__call($method, $args);
- } catch (Exception $e) {
- // Hack... detect exception type. We really should use exception subclasses.
- // if the exception isn't a 'no method' error, rethrow it
- if ($e->getCode() !== 2175) throw $e;
- $original = $this->copyContentFrom();
- return call_user_func_array(array($original, $method), $args);
+ } else {
+ return call_user_func_array(array($this->copyContentFrom(), $method), $args);
}
}
@@ -246,9 +241,7 @@
* @return bool
*/
function hasMethod($method) {
- $haveIt = parent::hasMethod($method);
- if (!$haveIt) $haveIt = $this->copyContentFrom()->hasMethod($method);
- return $haveIt;
+ return parent::hasMethod($method) || $this->copyContentFrom()->hasMethod($method);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment