class Galleries in Flickr API Integration 8
Class Galleries.
@package Drupal\flickr_api\Service
Hierarchy
- class \Drupal\flickr_api\Service\Galleries
Expanded class hierarchy of Galleries
1 string reference to 'Galleries'
1 service uses Galleries
File
- src/
Service/ Galleries.php, line 10
Namespace
Drupal\flickr_api\ServiceView source
class Galleries {
/**
* Client.
*
* @var \Drupal\flickr_api\Service\Client
*/
protected $client;
/**
* Galleries constructor.
*
* @param \Drupal\flickr_api\Service\Client $client
* Client.
*/
public function __construct(Client $client) {
// Flickr API Client.
$this->client = $client;
}
/**
* Returns info about a given gallery.
*
* @param string $id
* NSID of the gallery whose photos you want.
* @param array $otherArgs
* Additional args.
* @param bool $cacheable
* Cacheable.
*
* @return array
* Response from the flickr method flickr.gallery.getInfo.
* (https://www.flickr.com/services/api/flickr.gallery.getInfo.html)
*/
public function galleriesGetInfo($id, array $otherArgs = [], $cacheable = TRUE) {
$args = [
'gallery_id' => $id,
];
$args = array_merge($args, $otherArgs);
$response = $this->client
->request('flickr.galleries.getInfo', $args, $cacheable);
if ($response) {
return $response['gallery'];
}
return FALSE;
}
/**
* Returns a list of photos for a given gallery.
*
* @param string $id
* ID of the gallery.
* @param int $page
* Page.
* @param array $otherArgs
* Other args.
* @param bool $cacheable
* Cacheable.
*
* @return array
* Response from the flickr method flickr.galleries.getPhotos.
* (https://www.flickr.com/services/api/flickr.galleries.getPhotos.html)
*/
public function galleriesGetPhotos($id, $page = 1, array $otherArgs = [], $cacheable = TRUE) {
$args = [
'gallery_id' => $id,
'page' => $page,
];
$args = array_merge($args, $otherArgs);
// Set per_page to flickr_api module default if not specified in $args.
if (!isset($args['per_page'])) {
// TODO Expose pager as a setting.
$args['per_page'] = 6;
}
$response = $this->client
->request('flickr.galleries.getPhotos', $args, $cacheable);
if ($response) {
return $response['photos'];
}
return FALSE;
}
/**
* Returns the galleries curated by the specified user.
*
* @param string $nsid
* NSID of the user whose photoset list you want.
* @param int $page
* Page.
* @param bool $cacheable
* Cacheable.
*
* @return array
* Response from the flickr method flickr.galleries.getList.
* (https://www.flickr.com/services/api/flickr.galleries.getList.html)
*/
public function galleriesGetList($nsid, $page = 1, $cacheable = TRUE) {
$args = [
'user_id' => $nsid,
'page' => $page,
];
$response = $this->client
->request('flickr.galleries.getList', $args, $cacheable);
if ($response) {
return $response['galleries']['gallery'];
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Galleries:: |
protected | property | Client. | |
Galleries:: |
public | function | Returns info about a given gallery. | |
Galleries:: |
public | function | Returns the galleries curated by the specified user. | |
Galleries:: |
public | function | Returns a list of photos for a given gallery. | |
Galleries:: |
public | function | Galleries constructor. |