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

save() public method

Saves the group config
public save ( )
    public function save()
    {
        $isUpdate = false;
        if ($this->getId()) {
            $isUpdate = true;
            \Pimcore::getEventManager()->trigger("object.keyValue.groupConfig.preUpdate", $this);
        } else {
            \Pimcore::getEventManager()->trigger("object.keyValue.groupConfig.preAdd", $this);
        }
        $model = parent::save();
        if ($isUpdate) {
            \Pimcore::getEventManager()->trigger("object.keyValue.groupConfig.postUpdate", $this);
        } else {
            \Pimcore::getEventManager()->trigger("object.keyValue.groupConfig.postAdd", $this);
        }
        return $model;
    }

Usage Example

Example #1
0
 public function addgroupAction()
 {
     $name = $this->getParam("name");
     $alreadyExist = false;
     $config = KeyValue\GroupConfig::getByName($name);
     if (!$config) {
         $config = new KeyValue\GroupConfig();
         $config->setName($name);
         $config->save();
     }
     $this->_helper->json(["success" => !$alreadyExist, "id" => $config->getName()]);
 }
All Usage Examples Of Pimcore\Model\Object\KeyValue\GroupConfig::save