示例#1
0
 public function __invoke(Id $id)
 {
     $query = new Query(['_id' => $id->value()]);
     $cursor = $this->mongo->executeQuery('booothy.photo', $query)->toArray();
     if (empty($cursor)) {
         throw new NonExistingResource();
     }
     return $this->hydrator->__invoke($cursor[0]);
 }
示例#2
0
文件: Photo.php 项目: aeony/booothy
 public static function generateNew($a_quote, $an_upload_mime_type, Email $an_email)
 {
     $id = Id::next();
     $quote = new Quote($a_quote);
     $creation_date = new DateTimeImmutable();
     $image_details = ImageDetails::fake();
     $upload = self::generateUpload($a_quote, $creation_date, $an_upload_mime_type);
     return new self($id, $quote, $upload, $image_details, $creation_date, $an_email);
 }
示例#3
0
 public function __invoke(Id $id)
 {
     return $this->database_handler->getResource('photo', $id->value(), function () {
         throw new NonExistingResource();
     });
 }