protected function getResponse(PinholePhoto $photo) { $response = array(); if ($photo->status === PinholePhoto::STATUS_PROCESSING_ERROR) { $response['status'] = 'error'; $response['error_message'] = sprintf(Pinhole::_('Error processing file %s'), $photo->original_filename); } elseif ($photo->isProcessed()) { $response['status'] = 'processed'; $response['auto_publish'] = $photo->auto_publish; $response['image_uri'] = $photo->getUri('thumb'); $response['new_tags'] = $this->getNewTags($photo); $response['tile'] = $this->getTile($photo); } else { $response['status'] = 'unknown'; } return $response; }
/** * Process a photo * * @param mixed $photo The photo id or PinholePhoto dataobject to process * * @return PinholePhoto The processed photo */ public function processPhoto(PinholePhoto $photo) { if ($photo->id !== null && !$photo->isProcessed()) { try { $this->executeProcessing($photo); } catch (SwatException $e) { $e->log(); $photo->status = PinholePhoto::STATUS_PROCESSING_ERROR; } catch (Exception $e) { $e = new SwatException($e); $e->log(); $photo->status = PinholePhoto::STATUS_PROCESSING_ERROR; } $photo->save(); $this->clearCache($photo); $this->addToSearchQueue($photo); } }