コード例 #1
0
 /**
  * @param PhotoThumb $thumb
  * @return void
  */
 public function save(PhotoThumb $thumb)
 {
     $sentence = $this->pdo->prepare("INSERT INTO photo_thumb(\"uuid\",\"photo_uuid\",\"httpUrl\",\"height\",\"width\",\"filePath\") " . "VALUES(:uuid, :photo_uuid, :httpUrl, :height, :width, :filePath)");
     $sentence->bindValue(':uuid', $thumb->id(), \PDO::PARAM_STR);
     $sentence->bindValue(':photo_uuid', $thumb->photoId(), \PDO::PARAM_STR);
     $sentence->bindValue(':httpUrl', $thumb->photoThumbHttpUrl(), \PDO::PARAM_STR);
     $sentence->bindValue(':height', $thumb->height(), \PDO::PARAM_INT);
     $sentence->bindValue(':width', $thumb->width(), \PDO::PARAM_INT);
     $filePath = is_null($thumb->photoThumbFile()) ? null : $thumb->photoThumbFile()->filePath();
     $filePathType = is_null($thumb->photoThumbFile()) ? \PDO::PARAM_NULL : \PDO::PARAM_STR;
     $sentence->bindValue(':filePath', $filePath, $filePathType);
     $sentence->execute();
 }
コード例 #2
0
 /**
  * @test
  */
 public function photoThumbWorks()
 {
     $thumbId = new ThumbId();
     $photoId = new PhotoId();
     $photoFile = new PhotoFile(__DIR__ . '/pixel.png');
     $photoThumb = new PhotoThumb($thumbId, $photoId, new HttpUrl('http://works'), new PhotoThumbSize(10, 10), $photoFile);
     $this->assertEquals($thumbId->id(), $photoThumb->id());
     $this->assertEquals($photoId->id(), $photoThumb->photoId());
     $this->assertEquals('http://works', $photoThumb->photoThumbHttpUrl());
     $this->assertEquals(10, $photoThumb->height());
     $this->assertEquals(10, $photoThumb->width());
     $this->assertEquals($photoFile->filePath(), __DIR__ . '/pixel.png');
     $photoThumb->updatePhotoThumbFile(null);
     $this->assertNull($photoThumb->photoThumbFile());
 }
コード例 #3
0
 /**
  * @param PhotoThumb $thumb
  * @return boolean
  */
 public function removeThumb(PhotoThumb $thumb)
 {
     $itemsUri = explode('/', $thumb->photoThumbHttpUrl());
     $response = $this->s3->deleteObject(['Bucket' => $this->config->bucket(), 'Key' => trim(array_pop($itemsUri))]);
     return !is_null($response->get('RequestCharged'));
 }