You are here

function context_condition::__clone in Context 6

Same name and namespace in other branches
  1. 6.3 plugins/context_condition.inc \context_condition::__clone()
  2. 7.3 plugins/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

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));
    }
  }
}