Pimcore\Model\Object\Classificationstore\CollectionConfig::save PHP Method

save() public method

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

Usage Example

 public function createCollectionAction()
 {
     $name = $this->getParam("name");
     $alreadyExist = false;
     $config = Classificationstore\CollectionConfig::getByName($name);
     if (!$config) {
         $config = new Classificationstore\CollectionConfig();
         $config->setName($name);
         $config->save();
     }
     $this->_helper->json(array("success" => !$alreadyExist, "id" => $config->getName()));
 }