Admin_ClassificationstoreController::editStoreAction PHP Метод

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

public editStoreAction ( )
    public function editStoreAction()
    {
        $id = $this->getParam("id");
        $data = json_decode($this->getParam("data"), true);
        $name = $data["name"];
        if (!$name) {
            throw new \Exception("Name must not be empty");
        }
        $description = $data["description"];
        $config = Classificationstore\StoreConfig::getByName($name);
        if ($config && $config->getId() != $id) {
            throw new \Exception("There is already a config with the same name");
        }
        $config = Classificationstore\StoreConfig::getById($id);
        if (!$config) {
            throw new \Exception("Configuration does not exist");
        }
        $config->setName($name);
        $config->setDescription($description);
        $config->save();
        $this->_helper->json(["success" => true]);
    }