mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
FIX: Add __isset to VirtualPage for PHP7 support.
Also rely on parent::hasField and parent::hasMethod
This commit is contained in:
parent
7ac2be0802
commit
ec15c71342
@ -420,6 +420,24 @@ class VirtualPage extends Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow attributes on the master page to pass
|
||||||
|
* through to the virtual page
|
||||||
|
*
|
||||||
|
* @param string $field
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function __isset($field) {
|
||||||
|
if(parent::hasMethod($funcName = "get$field")) {
|
||||||
|
return true;
|
||||||
|
} else if(parent::hasField($field) || ($field === 'ID' && !$this->exists())) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return $this->CopyContentFrom()->__isset($field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass unrecognized method calls on to the original data object
|
* Pass unrecognized method calls on to the original data object
|
||||||
*
|
*
|
||||||
@ -441,13 +459,11 @@ class VirtualPage extends Page {
|
|||||||
*/
|
*/
|
||||||
public function hasField($field) {
|
public function hasField($field) {
|
||||||
return (
|
return (
|
||||||
array_key_exists($field, $this->record)
|
parent::hasField($field)
|
||||||
|| $this->hasDatabaseField($field)
|
|
||||||
|| array_key_exists($field, $this->db()) // Needed for composite fields
|
|
||||||
|| parent::hasMethod("get{$field}")
|
|
||||||
|| $this->CopyContentFrom()->hasField($field)
|
|| $this->CopyContentFrom()->hasField($field)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwrite to also check for method on the original data object
|
* Overwrite to also check for method on the original data object
|
||||||
*
|
*
|
||||||
@ -455,8 +471,10 @@ class VirtualPage extends Page {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasMethod($method) {
|
public function hasMethod($method) {
|
||||||
if(parent::hasMethod($method)) return true;
|
return (
|
||||||
return $this->copyContentFrom()->hasMethod($method);
|
parent::hasMethod($method)
|
||||||
|
|| $this->CopyContentFrom()->hasMethod($method)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user