Pimcore\Model\Object\ClassDefinition\CustomLayout::save PHP Method

save() public method

public save ( ) : void
return void
    public function save()
    {
        $isUpdate = false;
        if ($this->getId()) {
            $isUpdate = true;
            \Pimcore::getEventManager()->trigger("object.customLayout.preUpdate", $this);
        } else {
            \Pimcore::getEventManager()->trigger("object.customLayout.preAdd", $this);
        }
        $this->setModificationDate(time());
        // create directory if not exists
        if (!is_dir(PIMCORE_CUSTOMLAYOUT_DIRECTORY)) {
            \Pimcore\File::mkdir(PIMCORE_CUSTOMLAYOUT_DIRECTORY);
        }
        $this->getDao()->save();
        // empty custom layout cache
        try {
            Cache::clearTag("customlayout_" . $this->getId());
        } catch (\Exception $e) {
        }
    }

Usage Example

Example #1
0
 /** 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();
     }
 }
All Usage Examples Of Pimcore\Model\Object\ClassDefinition\CustomLayout::save