You are here

public function RemoteManager::getChannelsInfos in Entity Share 8.3

Same name and namespace in other branches
  1. 8 modules/entity_share_client/src/Service/RemoteManager.php \Drupal\entity_share_client\Service\RemoteManager::getChannelsInfos()
  2. 8.2 modules/entity_share_client/src/Service/RemoteManager.php \Drupal\entity_share_client\Service\RemoteManager::getChannelsInfos()

Get the channels infos of a remote website.

Parameters

\Drupal\entity_share_client\Entity\RemoteInterface $remote: The remote website on which to get the channels infos.

Return value

array Channel infos as returned by entity_share_server entry point.

Overrides RemoteManagerInterface::getChannelsInfos

File

modules/entity_share_client/src/Service/RemoteManager.php, line 95

Class

RemoteManager
Service to wrap requests logic.

Namespace

Drupal\entity_share_client\Service

Code

public function getChannelsInfos(RemoteInterface $remote) {
  $remote_id = $remote
    ->id();
  if (!isset($this->remoteInfos[$remote_id])) {
    $response = $this
      ->jsonApiRequest($remote, 'GET', 'entity_share');
    $json = [
      'data' => [
        'channels' => [],
        'field_mappings' => [],
      ],
    ];
    if (!is_null($response)) {
      $json = Json::decode((string) $response
        ->getBody());
    }
    $this->remoteInfos[$remote_id] = $json['data'];
  }
  return $this->remoteInfos[$remote_id]['channels'];
}