public function copyChart($src) { $chart = new Chart(); // new id $chart->setId($this->getUnusedRandomId()); // but the rest remains the same $chart->setUser($src->getUser()); $chart->setTitle($src->getTitle() . ' (' . __('Copy') . ')'); $chart->setMetadata(json_encode($src->getMetadata())); $chart->setTheme($src->getTheme()); $chart->setLocale($src->getLocale()); $chart->setType($src->getType()); $chart->setCreatedAt(time()); $chart->setLastModifiedAt(time()); $chart->setForkedFrom($src->getId()); $chart->setOrganization($src->getOrganization()); $chart->setLastEditStep(3); // we need to copy the data, too $chart->writeData($src->loadData()); $chart->save(); return $chart; }
/** * @param Chart $chart The chart object to add. */ protected function doAddChart($chart) { $this->collCharts[] = $chart; $chart->setOrganization($this); }