You are here

public function EntityShareClientCliService::pull in Entity Share 8.2

Pull content.

Parameters

\Drupal\entity_share_client\Entity\RemoteInterface $remote: The remote website entity to import from.

string $channel_url: The remote channel URL to import.

1 call to EntityShareClientCliService::pull()
EntityShareClientCliService::ioPull in modules/entity_share_client/src/Service/EntityShareClientCliService.php
Handle the pull interaction.

File

modules/entity_share_client/src/Service/EntityShareClientCliService.php, line 141

Class

EntityShareClientCliService
Class EntityShareClientCliService.

Namespace

Drupal\entity_share_client\Service

Code

public function pull(RemoteInterface $remote, $channel_url) {

  // Import channel content and loop on pagination.
  $this->jsonapiHelper
    ->setRemote($remote);
  $http_client = $this->remoteManager
    ->prepareJsonApiClient($remote);
  while ($channel_url) {
    $response = $this->requestService
      ->request($http_client, 'GET', $channel_url);
    $json = Json::decode((string) $response
      ->getBody());
    $this->jsonapiHelper
      ->importEntityListData(EntityShareUtility::prepareData($json['data']));
    if (isset($json['links']['next']['href'])) {
      $channel_url = $json['links']['next']['href'];
    }
    else {
      $channel_url = FALSE;
    }
  }
}