function context_condition::__clone

cis7 context_condition.inc context_condition::__clone()
cle7 context_condition.inc context_condition::__clone()
elmsmedia7 context_condition.inc context_condition::__clone()
icor7 context_condition.inc context_condition::__clone()
meedjum_blog7 context_condition.inc context_condition::__clone()
mooc7 context_condition.inc context_condition::__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

sites/all/modules/ulmus/context/plugins/context_condition.inc, line 21

Class

context_condition
Base class for a context condition.

Code

function __clone() {
  foreach ($this as $key => $val) {
    if (is_object($val) || (is_array($val))) {
      $this->{$key} = unserialize(serialize($val));
    }
  }
}