Pimcore\Model\Object\KeyValue\KeyConfig::save PHP Method

save() public method

Saves the key config
public save ( )
    public function save()
    {
        $isUpdate = false;
        if ($this->getId()) {
            unset(self::$cache[$this->getId()]);
            $isUpdate = true;
            \Pimcore::getEventManager()->trigger("object.keyValue.keyConfig.preUpdate", $this);
        } else {
            \Pimcore::getEventManager()->trigger("object.keyValue.keyConfig.preAdd", $this);
        }
        $model = $this->getDao()->save();
        if ($isUpdate) {
            \Pimcore::getEventManager()->trigger("object.keyValue.keyConfig.postUpdate", $this);
        } else {
            \Pimcore::getEventManager()->trigger("object.keyValue.keyConfig.postAdd", $this);
        }
        return $model;
    }

Usage Example

コード例 #1
0
 public function addpropertyAction()
 {
     $name = $this->getParam("name");
     $alreadyExist = false;
     if (!$alreadyExist) {
         $config = new KeyValue\KeyConfig();
         $config->setName($name);
         $config->setType("text");
         $config->save();
     }
     $this->_helper->json(["success" => !$alreadyExist, "id" => $config->getName()]);
 }
All Usage Examples Of Pimcore\Model\Object\KeyValue\KeyConfig::save