Skip to content
Snippets Groups Projects
Commit ebd085ec authored by Josh Stevenson-Woods's avatar Josh Stevenson-Woods Committed by Elliot Ward
Browse files

Issue #3088599 by jkswoods, Eli-T: Rename endpoint to entrypoint

parent d81bea9d
Branches
Tags
No related merge requests found
...@@ -11,10 +11,10 @@ jsonapi_reference.settings: ...@@ -11,10 +11,10 @@ jsonapi_reference.settings:
mapping: mapping:
endpoint: endpoint:
type: string type: string
label: 'Endpoint containing JSON:API objects to which we refer' label: 'Entrypoint containing JSON:API objects to which we refer'
username: username:
type: string type: string
label: 'Username for accessing endpoint' label: 'Username for accessing the entrypoint'
password: password:
type: string type: string
label: 'Password for accessing endpoint' label: 'Password for accessing the entrypoint'
access jsonapi autocomplete: access jsonapi autocomplete:
title: 'Access JSON:API autocomplete' title: 'Access JSON:API autocomplete'
description: 'Allow access to the JSON:API autocomplete endpoint. This can expose all data exposed from the external JSON:API endpoint.' description: 'Allow access to the JSON:API autocomplete entrypoint. This can expose all data exposed from the external JSON:API entrypoint.'
configure jsonapi reference: configure jsonapi reference:
title: 'Configure JSON:API reference' title: 'Configure JSON:API reference'
......
...@@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Request; ...@@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Request;
class TypedResourceController extends ControllerBase { class TypedResourceController extends ControllerBase {
/** /**
* Client to talk to our JSON:API endpoint. * Client to talk to our JSON:API entrypoint.
* *
* @var \Drupal\jsonapi_reference\JsonApiClientInterface * @var \Drupal\jsonapi_reference\JsonApiClientInterface
*/ */
...@@ -26,7 +26,7 @@ class TypedResourceController extends ControllerBase { ...@@ -26,7 +26,7 @@ class TypedResourceController extends ControllerBase {
* TypedResourceController constructor. * TypedResourceController constructor.
* *
* @param \Drupal\jsonapi_reference\JsonApiClientInterface $client * @param \Drupal\jsonapi_reference\JsonApiClientInterface $client
* Client to talk to our JSON:API endpoint. * Client to talk to our JSON:API entrypoint.
*/ */
public function __construct(JsonApiClientInterface $client) { public function __construct(JsonApiClientInterface $client) {
$this->client = $client; $this->client = $client;
......
...@@ -31,10 +31,10 @@ class JsonApiReferenceConfigForm extends ConfigFormBase { ...@@ -31,10 +31,10 @@ class JsonApiReferenceConfigForm extends ConfigFormBase {
*/ */
public function buildForm(array $form, FormStateInterface $form_state) { public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('jsonapi_reference.settings'); $config = $this->config('jsonapi_reference.settings');
$form['endpoint'] = [ $form['entrypoint'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => $this->t('Endpoint'), '#title' => $this->t('Entrypoint'),
'#description' => $this->t('The root JSON:API endpoint, for example, https://example.com/jsonapi'), '#description' => $this->t('The root JSON:API entrypoint, for example, https://example.com/jsonapi'),
'#maxlength' => 2048, '#maxlength' => 2048,
'#size' => 64, '#size' => 64,
'#default_value' => $config->get('endpoint'), '#default_value' => $config->get('endpoint'),
...@@ -42,7 +42,7 @@ class JsonApiReferenceConfigForm extends ConfigFormBase { ...@@ -42,7 +42,7 @@ class JsonApiReferenceConfigForm extends ConfigFormBase {
$form['username'] = [ $form['username'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => $this->t('Username'), '#title' => $this->t('Username'),
'#description' => $this->t('Username for authenticating on the JSON:API endpoint'), '#description' => $this->t('Username for authenticating on the JSON:API entrypoint'),
'#maxlength' => 128, '#maxlength' => 128,
'#size' => 64, '#size' => 64,
'#default_value' => $config->get('username'), '#default_value' => $config->get('username'),
...@@ -50,7 +50,7 @@ class JsonApiReferenceConfigForm extends ConfigFormBase { ...@@ -50,7 +50,7 @@ class JsonApiReferenceConfigForm extends ConfigFormBase {
$form['password'] = [ $form['password'] = [
'#type' => 'password', '#type' => 'password',
'#title' => $this->t('Password'), '#title' => $this->t('Password'),
'#description' => $this->t('Password for authenticating on the JSON:API endpoint'), '#description' => $this->t('Password for authenticating on the JSON:API entrypoint'),
'#maxlength' => 128, '#maxlength' => 128,
'#size' => 64, '#size' => 64,
'#default_value' => $config->get('password'), '#default_value' => $config->get('password'),
...@@ -65,7 +65,7 @@ class JsonApiReferenceConfigForm extends ConfigFormBase { ...@@ -65,7 +65,7 @@ class JsonApiReferenceConfigForm extends ConfigFormBase {
parent::submitForm($form, $form_state); parent::submitForm($form, $form_state);
$config = $this->config('jsonapi_reference.settings'); $config = $this->config('jsonapi_reference.settings');
$config->set('endpoint', $form_state->getValue('endpoint')) $config->set('endpoint', $form_state->getValue('entrypoint'))
->set('username', $form_state->getValue('username')); ->set('username', $form_state->getValue('username'));
if ($password = $form_state->getValue('password')) { if ($password = $form_state->getValue('password')) {
$config->set('password', $password); $config->set('password', $password);
......
...@@ -16,28 +16,28 @@ use GuzzleHttp\RequestOptions; ...@@ -16,28 +16,28 @@ use GuzzleHttp\RequestOptions;
class JsonApiClient implements JsonApiClientInterface { class JsonApiClient implements JsonApiClientInterface {
/** /**
* Client for querying JSON:API endpoints. * Client for querying the JSON:API entrypoint.
* *
* @var \GuzzleHttp\ClientInterface * @var \GuzzleHttp\ClientInterface
*/ */
protected $httpClient; protected $httpClient;
/** /**
* Endpoint to call to retrieve JSONAPI objects. * Entrypoint to call to retrieve JSONAPI objects.
* *
* @var string * @var string
*/ */
protected $endpoint; protected $entrypoint;
/** /**
* Username to use when authenticating to endpoint. * Username to use when authenticating to the entrypoint.
* *
* @var string * @var string
*/ */
protected $username; protected $username;
/** /**
* Password to use when authenticating to endpoint. * Password to use when authenticating to the entrypoint.
* *
* @var string * @var string
*/ */
...@@ -54,7 +54,7 @@ class JsonApiClient implements JsonApiClientInterface { ...@@ -54,7 +54,7 @@ class JsonApiClient implements JsonApiClientInterface {
* JsonApiClient constructor. * JsonApiClient constructor.
* *
* @param \GuzzleHttp\ClientInterface $httpClient * @param \GuzzleHttp\ClientInterface $httpClient
* Client for querying JSON:API endpoints. * Client for querying the JSON:API entrypoint.
* @param \Drupal\Core\Logger\LoggerChannelInterface $loggerChannel * @param \Drupal\Core\Logger\LoggerChannelInterface $loggerChannel
* Channel for logging. * Channel for logging.
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
...@@ -62,7 +62,7 @@ class JsonApiClient implements JsonApiClientInterface { ...@@ -62,7 +62,7 @@ class JsonApiClient implements JsonApiClientInterface {
*/ */
public function __construct(ClientInterface $httpClient, LoggerChannelInterface $loggerChannel, ConfigFactoryInterface $configFactory) { public function __construct(ClientInterface $httpClient, LoggerChannelInterface $loggerChannel, ConfigFactoryInterface $configFactory) {
$this->httpClient = $httpClient; $this->httpClient = $httpClient;
$this->endpoint = $configFactory->get('jsonapi_reference.settings')->get('endpoint'); $this->entrypoint = $configFactory->get('jsonapi_reference.settings')->get('endpoint');
$this->username = $configFactory->get('jsonapi_reference.settings')->get('username'); $this->username = $configFactory->get('jsonapi_reference.settings')->get('username');
$this->password = $configFactory->get('jsonapi_reference.settings')->get('password'); $this->password = $configFactory->get('jsonapi_reference.settings')->get('password');
$this->loggerChannel = $loggerChannel; $this->loggerChannel = $loggerChannel;
...@@ -76,16 +76,16 @@ class JsonApiClient implements JsonApiClientInterface { ...@@ -76,16 +76,16 @@ class JsonApiClient implements JsonApiClientInterface {
} }
/** /**
* Gets the resource object type information from the endpoint. * Gets the resource object type information from the entrypoint.
* *
* @return object[] * @return object[]
* Array of objects, keyed by type name (EG node--article). * Array of objects, keyed by type name (EG node--article).
* Each object contains a href element pointing to the JSON:API endpoint * Each object contains a href element pointing to the JSON:API entrypoint
* for that specific type. * for that specific type.
*/ */
protected function getResourceObjectTypes() { protected function getResourceObjectTypes() {
try { try {
$response = $this->httpClient->request('get', $this->endpoint, $this->getRequestOptions()); $response = $this->httpClient->request('get', $this->entrypoint, $this->getRequestOptions());
} }
catch (GuzzleException $e) { catch (GuzzleException $e) {
$this->loggerChannel->error($e->getMessage()); $this->loggerChannel->error($e->getMessage());
...@@ -93,7 +93,7 @@ class JsonApiClient implements JsonApiClientInterface { ...@@ -93,7 +93,7 @@ class JsonApiClient implements JsonApiClientInterface {
} }
$response = json_decode($response->getBody()->getContents()); $response = json_decode($response->getBody()->getContents());
if (!isset($response->links)) { if (!isset($response->links)) {
$this->loggerChannel->error('JSON:API endpoint @endpoint returned no type information.', ['@endpoint' => $this->endpoint]); $this->loggerChannel->error('JSON:API entrypoint @entrypoint returned no type information.', ['@entrypoint' => $this->entrypoint]);
return []; return [];
} }
return (array) $response->links; return (array) $response->links;
...@@ -105,9 +105,9 @@ class JsonApiClient implements JsonApiClientInterface { ...@@ -105,9 +105,9 @@ class JsonApiClient implements JsonApiClientInterface {
public function search($resource_object_type, $search_attribute, $query) { public function search($resource_object_type, $search_attribute, $query) {
$path = $this->getPathForResourceObjectType($resource_object_type); $path = $this->getPathForResourceObjectType($resource_object_type);
if (!$path) { if (!$path) {
$this->loggerChannel->error('No path for resource object type @type found at JSON:API endpoint @endpoint.', [ $this->loggerChannel->error('No path for resource object type @type found at JSON:API entrypoint @entrypoint.', [
'@type' => $resource_object_type, '@type' => $resource_object_type,
'@endpoint' => $this->endpoint, '@entrypoint' => $this->entrypoint,
]); ]);
return []; return [];
} }
...@@ -136,8 +136,8 @@ class JsonApiClient implements JsonApiClientInterface { ...@@ -136,8 +136,8 @@ class JsonApiClient implements JsonApiClientInterface {
foreach ($response->data as $result) { foreach ($response->data as $result) {
$results[$result->attributes->$search_attribute] = $result->id; $results[$result->attributes->$search_attribute] = $result->id;
} }
$this->loggerChannel->error('JSON:API endpoint @endpoint returned no data for path @path when searching for objects where the @search_attribute attribute matched "@query".', [ $this->loggerChannel->error('JSON:API entrypoint @entrypoint returned no data for path @path when searching for objects where the @search_attribute attribute matched "@query".', [
'@endpoint' => $this->endpoint, '@entrypoint' => $this->entrypoint,
'@path' => $path, '@path' => $path,
'@search_attribute' => $search_attribute, '@search_attribute' => $search_attribute,
'@query' => $query, '@query' => $query,
......
...@@ -10,7 +10,7 @@ namespace Drupal\jsonapi_reference; ...@@ -10,7 +10,7 @@ namespace Drupal\jsonapi_reference;
interface JsonApiClientInterface { interface JsonApiClientInterface {
/** /**
* Gets a list of resource object types from the remote endpoint. * Gets a list of resource object types from the remote entrypoint.
* *
* @return string[] * @return string[]
* Array of remote object types.src/JsonApiClient.php * Array of remote object types.src/JsonApiClient.php
...@@ -25,7 +25,7 @@ interface JsonApiClientInterface { ...@@ -25,7 +25,7 @@ interface JsonApiClientInterface {
public function listResourceObjectTypes(); public function listResourceObjectTypes();
/** /**
* Search the endpoint for a resource object of a given type. * Search the entrypoint for a resource object of a given type.
* *
* @param string $resource_object_type * @param string $resource_object_type
* Resource object type. * Resource object type.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment