setData() public method

public setData ( mixed $data ) : void
$data mixed
return void
Example #1
0
 /**
  * @param bool $setModificationDate
  * @param bool $callPluginHook
  * @return null|Version
  * @throws \Exception
  */
 public function saveVersion($setModificationDate = true, $callPluginHook = true)
 {
     // hook should be also called if "save only new version" is selected
     if ($callPluginHook) {
         \Pimcore::getEventManager()->trigger("asset.preUpdate", $this, ["saveVersionOnly" => true]);
     }
     // set date
     if ($setModificationDate) {
         $this->setModificationDate(time());
     }
     // scheduled tasks are saved always, they are not versioned!
     $this->saveScheduledTasks();
     // create version
     $version = null;
     // only create a new version if there is at least 1 allowed
     if (Config::getSystemConfig()->assets->versions->steps || Config::getSystemConfig()->assets->versions->days) {
         $version = new Version();
         $version->setCid($this->getId());
         $version->setCtype("asset");
         $version->setDate($this->getModificationDate());
         $version->setUserId($this->getUserModification());
         $version->setData($this);
         $version->save();
     }
     // hook should be also called if "save only new version" is selected
     if ($callPluginHook) {
         \Pimcore::getEventManager()->trigger("asset.postUpdate", $this, ["saveVersionOnly" => true]);
     }
     return $version;
 }