Beispiel #1
0
 /**
  * Updates a photo
  * 
  * @param array $input Raw input data
  * @return boolean
  */
 public function update(array $input)
 {
     $data =& $input['data']['photo'];
     // Upload a photo if present and override it
     if (!empty($input['files'])) {
         $input = $this->prepareInput($input);
         $file =& $input['files']['file'];
         // First of all, we need to remove old photo on the file-system
         if ($this->imageManager->delete($data['id'], $data['photo'])) {
             // And now upload a new one
             $data['photo'] = $file[0]->getName();
             $this->imageManager->upload($data['id'], $file);
         } else {
             return false;
         }
     }
     $this->track('The photo "%s" has been updated', $data['name']);
     return $this->photoMapper->update($data);
 }