Exemplo n.º 1
0
 public function createPhoto($album)
 {
     $client = $this->photos;
     $fd = $client->newMediaFileSource('Zend/GData/_files/testImage.jpg');
     $fd->setContentType('image/jpeg');
     $photo = new Photos\PhotoEntry();
     $photo->setMediaSource($fd);
     $photo->setTitle($client->newTitle("test photo"));
     $photo->setCategory(array($client->newCategory('http://schemas.google.com/photos/2007#photo', 'http://schemas.google.com/g/2005#kind')));
     $newPhoto = $client->insertPhotoEntry($photo, $album);
     $this->assertEquals($photo->getTitle(), $newPhoto->getTitle());
     $this->assertEquals($newPhoto->getTitle(), $client->getPhotoEntry($newPhoto->getLink('self')->href)->getTitle());
     $photoFeedUri = $newPhoto->getLink('http://schemas.google.com/g/2005#feed')->href;
     $photoFeed = $client->getPhotoFeed($photoFeedUri);
     $this->verifyProperty($photoFeed, "title", "text", "test photo");
     return $newPhoto;
 }
Exemplo n.º 2
0
 /**
  * Delete a PhotoEntry.
  *
  * @param \Zend\GData\Photos\PhotoEntry $photo The photo entry to
  *          delete.
  * @param boolean $catch Whether to catch an exception when
  *            modified and re-delete or throw
  * @return void.
  * @throws \Zend\GData\App\Exception
  * @throws \Zend\GData\App\HttpException
  */
 public function deletePhotoEntry($photo, $catch)
 {
     if ($catch) {
         try {
             $this->delete($photo);
         } catch (App\HttpException $e) {
             if ($e->getResponse()->getStatus() === 409) {
                 $entry = new PhotoEntry($e->getResponse()->getBody());
                 $this->delete($entry->getLink('edit')->href);
             } else {
                 throw $e;
             }
         }
     } else {
         $this->delete($photo);
     }
 }