protected function EntityShareCronService::getPage in Entity Share Cron 8.2
Same name and namespace in other branches
- 8 src/EntityShareCronService.php \Drupal\entity_share_cron\EntityShareCronService::getPage()
- 3.0.x src/EntityShareCronService.php \Drupal\entity_share_cron\EntityShareCronService::getPage()
Returns the page data to import entities.
Parameters
string $remote_id: The ID of the remote the channel belongs to.
string $channel_id: The ID of the channel to be synchronized.
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 URL.
File
- src/
EntityShareCronService.php, line 152
Class
- EntityShareCronService
- Entity Share Cron service.
Namespace
Drupal\entity_share_cronCode
protected function getPage($remote_id, $channel_id, $url) {
$data = [
'data' => [],
'next' => FALSE,
];
$remote = Remote::load($remote_id);
if ($remote) {
// Makes request to get profiles.
$this->jsonapiHelper
->setRemote($remote);
$http_client = $this->remoteManager
->prepareJsonApiClient($remote);
$json_response = $http_client
->get($url)
->getBody()
->getContents();
// Parses the JSON of entities to import.
$json = Json::decode($json_response);
$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;
}