You are here

public function PHPExcel_Worksheet::__clone in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet.php \PHPExcel_Worksheet::__clone()

Implement PHP __clone to create a deep clone, not just a shallow copy.

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet.php, line 2856

Class

PHPExcel_Worksheet
PHPExcel_Worksheet

Code

public function __clone() {
  foreach ($this as $key => $val) {
    if ($key == '_parent') {
      continue;
    }
    if (is_object($val) || is_array($val)) {
      if ($key == '_cellCollection') {
        $newCollection = clone $this->_cellCollection;
        $newCollection
          ->copyCellCollection($this);
        $this->_cellCollection = $newCollection;
      }
      elseif ($key == '_drawingCollection') {
        $newCollection = clone $this->_drawingCollection;
        $this->_drawingCollection = $newCollection;
      }
      elseif ($key == '_autoFilter' && $this->_autoFilter instanceof PHPExcel_Worksheet_AutoFilter) {
        $newAutoFilter = clone $this->_autoFilter;
        $this->_autoFilter = $newAutoFilter;
        $this->_autoFilter
          ->setParent($this);
      }
      else {
        $this->{$key} = unserialize(serialize($val));
      }
    }
  }
}