Пример #1
0
 /**
  * Updates a slider
  * 
  * @param array $input Raw input data
  * @return boolean
  */
 public function update(array $input)
 {
     $data =& $input['data']['image'];
     // Handle image
     if (!empty($input['files'])) {
         $uploader = $this->getUploader($data['category_id']);
         // First of all, we need to remove old one
         if ($uploader->delete($data['id'], $data['image'])) {
             $input = $this->prepareInput($input);
             $file = $input['files']['file'];
             // Now override old image with a new one and start uploading
             $data['image'] = $file[0]->getName();
             $uploader->upload($data['id'], $file);
         } else {
             return false;
         }
     }
     $this->track('Slider "%s" has been updated', $data['name']);
     return $this->imageMapper->update($data);
 }
Пример #2
0
 /**
  * Counts amount of slides in given category
  * 
  * @param string $categoryId
  * @return integer
  */
 public function getSlidesCountByCategoryId($categoryId)
 {
     return $this->imageMapper->countAllByCategoryId($categoryId);
 }