/** * Object cloning. */ public function __clone() { if ($this->components) { $oldMyself = reset($this->components)->getParent(); $oldMyself->cloning = $this; foreach ($this->components as $name => $component) { $this->components[$name] = clone $component; } $oldMyself->cloning = NULL; } parent::__clone(); }