Пример #1
0
 protected function modify(Category $category)
 {
     $requete = $this->dao->prepare('UPDATE category SET  name = :name, parentId = :parentId WHERE id = :id');
     $requete->bindValue(':name', $category->name(), \PDO::PARAM_STR);
     $requete->bindValue(':parentId', $category->parentId(), \PDO::PARAM_INT);
     $requete->bindValue(':id', $category->id(), \PDO::PARAM_INT);
     $requete->execute();
 }
Пример #2
0
 public function executeInsert(HTTPRequest $request)
 {
     if ($request->method() == 'POST') {
         $categoriesManager = $this->getManagerOf($this->module(), 'Categories');
         $category = new Category();
         $category->setName($request->postData('name'));
         $category->setParentId($request->postData('parentId'));
         $categoriesManager->save($category);
         $this->app->httpResponse()->previous();
     }
 }
Пример #3
0
 /**
  * Méthode permettant d'enregistrer une category.
  * @param $category Category la category à enregistrer
  * @see self::add()
  * @see self::modify()
  * @return void
  */
 public function save(Category $category)
 {
     if ($category->isValid()) {
         if ($category->isNew()) {
             return $this->add($category);
         }
         $this->modify($category);
     } else {
         throw new \RuntimeException('La category doit être validée pour être enregistrée');
     }
 }