You are here

protected function EntityShareCronService::getPage in Entity Share Cron 3.0.x

Same name and namespace in other branches
  1. 8.2 src/EntityShareCronService.php \Drupal\entity_share_cron\EntityShareCronService::getPage()
  2. 8 src/EntityShareCronService.php \Drupal\entity_share_cron\EntityShareCronService::getPage()

Returns the page data to import entities.

Parameters

string $url: The URL of the page.

Return value

array An associative array with the following keys:

  • data => parsed JSON of entities to import.
  • next => URL of the next page.
1 call to EntityShareCronService::getPage()
EntityShareCronService::sync in src/EntityShareCronService.php
Synchronizes entities starting from provided channel.

File

src/EntityShareCronService.php, line 141

Class

EntityShareCronService
Entity Share Cron service.

Namespace

Drupal\entity_share_cron

Code

protected function getPage($url) {
  $data = [
    'data' => [],
    'next' => FALSE,
  ];
  $response = $this->importService
    ->jsonApiRequest('GET', $url);
  $json = Json::decode((string) $response
    ->getBody());

  // Parses the JSON of entities to import.
  $data['data'] = EntityShareUtility::prepareData($json['data']);

  // Gets the URL of the next page.
  $data['next'] = !empty($json['links']['next']['href']) ? $json['links']['next']['href'] : FALSE;
  return $data;
}