예제 #1
0
 public function addAction()
 {
     $success = false;
     $letter = Newsletter\Config::getByName($this->getParam("name"));
     if (!$letter) {
         $letter = new Newsletter\Config();
         $letter->setName($this->getParam("name"));
         $letter->save();
         $success = true;
     }
     $this->_helper->json(array("success" => $success, "id" => $letter->getName()));
 }
 public function addAction()
 {
     try {
         Newsletter\Config::getByName($this->getParam("name"));
         $alreadyExist = true;
     } catch (\Exception $e) {
         $alreadyExist = false;
     }
     if (!$alreadyExist) {
         $letter = new Newsletter\Config();
         $letter->setName($this->getParam("name"));
         $letter->save();
     }
     $this->_helper->json(array("success" => !$alreadyExist, "id" => $letter->getName()));
 }