Ejemplo n.º 1
0
 /**
  * @param \Difra\Param\AjaxString $name
  * @param \Difra\Param\AjaxString $text
  * @param \Difra\Param\AjaxInt $id
  * @param \Difra\Param\AjaxString $description
  * @throws Difra\Exception
  */
 public function saveAjaxAction(\Difra\Param\AjaxString $name, \Difra\Param\AjaxString $text, \Difra\Param\AjaxInt $id = null, \Difra\Param\AjaxString $description = null)
 {
     if ($id) {
         if (!($snippet = \Difra\Plugins\CMS\Snippet::getById($id->val()))) {
             throw new \Difra\Exception('Snippet cannot be saved — bad ID');
         }
     } else {
         $snippet = \Difra\Plugins\CMS\Snippet::create();
     }
     $snippet->setName($name);
     $snippet->setDescription($description);
     $snippet->setText($text);
     \Difra\Ajaxer::redirect('/adm/content/snippets');
 }