/** * Create a new record for the object in database * * @return boolean */ public function create() { $this->db->insert("custom_layouts", array("name" => $this->model->getName(), "classId" => $this->model->getClassId())); $this->model->setId($this->db->lastInsertId()); $this->model->setCreationDate(time()); $this->model->setModificationDate(time()); $this->save(); }
/** Synchronizes a custom layout with its master layout * @param ClassDefinition\CustomLayout $customLayout */ public static function synchronizeCustomLayout(ClassDefinition\CustomLayout $customLayout) { $classId = $customLayout->getClassId(); $class = ClassDefinition::getById($classId); if ($class && $class->getModificationDate() > $customLayout->getModificationDate()) { $masterDefinition = $class->getFieldDefinitions(); $customLayoutDefinition = $customLayout->getLayoutDefinitions(); $targetList = self::extractLocalizedFieldDefinitions($class->getLayoutDefinitions(), array(), false); $masterDefinition = array_merge($masterDefinition, $targetList); self::synchronizeCustomLayoutFieldWithMaster($masterDefinition, $customLayoutDefinition); $customLayout->save(); } }