Pimcore\Model\Object\Classificationstore\StoreConfig::save PHP Метод

save() публичный Метод

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

Usage Example

 public function createStoreAction()
 {
     $name = $this->getParam("name");
     $config = Classificationstore\StoreConfig::getByName($name);
     if (!$config) {
         $config = new Classificationstore\StoreConfig();
         $config->setName($name);
         $config->save();
     } else {
         throw new \Exception("Store with the given name exists");
     }
     $this->_helper->json(["success" => true, "storeId" => $config->getId()]);
 }