Inheritance: extends Pimcore\Model\AbstractModel
示例#1
0
文件: Dao.php 项目: solverat/pimcore
 /**
  * Loads a list of Classificationstore store configs for the specified parameters, returns an array of config elements
  *
  * @return array
  */
 public function load()
 {
     $sql = "SELECT id FROM " . Object\Classificationstore\StoreConfig\Dao::TABLE_NAME_STORES . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit();
     $configsData = $this->db->fetchCol($sql, $this->model->getConditionVariables());
     $configData = [];
     foreach ($configsData as $config) {
         $configData[] = Object\Classificationstore\StoreConfig::getById($config);
     }
     $this->model->setList($configData);
     return $configData;
 }
 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]);
 }