function context_reaction::__clone in Context 6
Same name and namespace in other branches
- 6.3 plugins/context_reaction.inc \context_reaction::__clone()
- 7.3 plugins/context_reaction.inc \context_reaction::__clone()
Clone our references when we're being cloned.
PHP 5.3 performs 'shallow' clones when clone()'ing objects, meaning that any objects or arrays referenced by this object will not be copied, the cloned object will just reference our objects/arrays instead. By iterating over our properties and serializing and unserializing them, we force PHP to copy them.
File
- plugins/
context_reaction.inc, line 20
Class
- context_reaction
- Base class for a context reaction.
Code
function __clone() {
foreach ($this as $key => $val) {
if (is_object($val) || is_array($val)) {
$this->{$key} = unserialize(serialize($val));
}
}
}