You are here

public function FacebookAlbumController::getAlbumNext in Facebook Album 8

Fetch the next or previous set of photos from the specified album

Parameters

\Drupal\block\BlockInterface $block:

$album_id: The album id to fetch photos from

null $after: The id for fetching the next or previous set of photos

Return value

\Zend\Diactoros\Response\JsonResponse

1 call to FacebookAlbumController::getAlbumNext()
FacebookAlbumController::getAlbum in src/Controller/FacebookAlbumController.php
Fetch the first set of photos from the specified album
1 string reference to 'FacebookAlbumController::getAlbumNext'
facebook_album.routing.yml in ./facebook_album.routing.yml
facebook_album.routing.yml

File

src/Controller/FacebookAlbumController.php, line 129
Contains \Drupal\facebook_album\Controller\FacebookAlbumController.

Class

FacebookAlbumController
Controller for Facebook Album.

Namespace

Drupal\facebook_album\Controller

Code

public function getAlbumNext(BlockInterface $block, $album_id, $after = NULL) {
  $settings = $block
    ->get('settings');
  $parameters = [
    'after' => $after,
    'fields' => 'url',
  ];
  $response = $this
    ->makeRequest($album_id . '/photos', $parameters);

  // Build json response
  $json_response = [];
  $render = [
    '#theme' => 'facebook_album_photos',
    '#settings' => $settings,
    '#photos' => $response['data'],
  ];
  $json_response['data']['content'] = \Drupal::service('renderer')
    ->render($render);
  $json_response['data']['photo_ids'] = $response['data'];
  if (isset($response['paging']) && isset($response['paging']['next'])) {
    $json_response['data']['after'] = $response['paging']['cursors']['after'];
  }
  return new JsonResponse($json_response);
}