Esempio n. 1
0
 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->setLastEditStep(3);
     // we need to copy the data, too
     $chart->writeData($src->loadData());
     $chart->save();
     return $chart;
 }