/** * Magical cloning method. */ public function __clone() { $currentUid = $this->_uid; $this->cloningData = ['pages' => [], 'contents' => []]; if (null !== $this->_contentset && null !== $this->getLayout()) { $this->_contentset = $this->_contentset->createClone($this); } else { $this->_contentset = new ContentSet(); } if ($this->hasMainSection()) { // Main section has to be cloned also $this->setDefaultProperties(null, clone $this->_mainsection, $this->_title, null, $this->_target); } else { // The new page keeps the same section $section = $this->getSection(); $this->setDefaultProperties(null, null, $this->_title, null, $this->_target); if (null !== $section) { $this->setSection($section); } } $this->_revisions = new ArrayCollection(); $this->cloningData['pages'][$currentUid] = $this; }