From ebd085ecd45bd19c510911324659d95bb7c415bb Mon Sep 17 00:00:00 2001
From: jkswoods <jkswoods@2767839.no-reply.drupal.org>
Date: Mon, 18 Nov 2019 14:51:35 +0000
Subject: [PATCH] Issue #3088599 by jkswoods, Eli-T: Rename endpoint to
 entrypoint

---
 config/schema/jsonapi_reference.schema.yml |  6 ++---
 jsonapi_reference.permissions.yml          |  2 +-
 src/Controller/TypedResourceController.php |  4 +--
 src/Form/JsonApiReferenceConfigForm.php    | 12 ++++-----
 src/JsonApiClient.php                      | 30 +++++++++++-----------
 src/JsonApiClientInterface.php             |  4 +--
 6 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/config/schema/jsonapi_reference.schema.yml b/config/schema/jsonapi_reference.schema.yml
index 87611c3..98a8eca 100644
--- a/config/schema/jsonapi_reference.schema.yml
+++ b/config/schema/jsonapi_reference.schema.yml
@@ -11,10 +11,10 @@ jsonapi_reference.settings:
   mapping:
     endpoint:
       type: string
-      label: 'Endpoint containing JSON:API objects to which we refer'
+      label: 'Entrypoint containing JSON:API objects to which we refer'
     username:
       type: string
-      label: 'Username for accessing endpoint'
+      label: 'Username for accessing the entrypoint'
     password:
       type: string
-      label: 'Password for accessing endpoint'
+      label: 'Password for accessing the entrypoint'
diff --git a/jsonapi_reference.permissions.yml b/jsonapi_reference.permissions.yml
index c37b836..530a585 100644
--- a/jsonapi_reference.permissions.yml
+++ b/jsonapi_reference.permissions.yml
@@ -1,6 +1,6 @@
 access jsonapi 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:
   title: 'Configure JSON:API reference'
diff --git a/src/Controller/TypedResourceController.php b/src/Controller/TypedResourceController.php
index 1b34ab0..3f764dd 100644
--- a/src/Controller/TypedResourceController.php
+++ b/src/Controller/TypedResourceController.php
@@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Request;
 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
    */
@@ -26,7 +26,7 @@ class TypedResourceController extends ControllerBase {
    * TypedResourceController constructor.
    *
    * @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) {
     $this->client = $client;
diff --git a/src/Form/JsonApiReferenceConfigForm.php b/src/Form/JsonApiReferenceConfigForm.php
index 2df6f57..ae0f3b6 100644
--- a/src/Form/JsonApiReferenceConfigForm.php
+++ b/src/Form/JsonApiReferenceConfigForm.php
@@ -31,10 +31,10 @@ class JsonApiReferenceConfigForm extends ConfigFormBase {
    */
   public function buildForm(array $form, FormStateInterface $form_state) {
     $config = $this->config('jsonapi_reference.settings');
-    $form['endpoint'] = [
+    $form['entrypoint'] = [
       '#type' => 'textfield',
-      '#title' => $this->t('Endpoint'),
-      '#description' => $this->t('The root JSON:API endpoint, for example, https://example.com/jsonapi'),
+      '#title' => $this->t('Entrypoint'),
+      '#description' => $this->t('The root JSON:API entrypoint, for example, https://example.com/jsonapi'),
       '#maxlength' => 2048,
       '#size' => 64,
       '#default_value' => $config->get('endpoint'),
@@ -42,7 +42,7 @@ class JsonApiReferenceConfigForm extends ConfigFormBase {
     $form['username'] = [
       '#type' => 'textfield',
       '#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,
       '#size' => 64,
       '#default_value' => $config->get('username'),
@@ -50,7 +50,7 @@ class JsonApiReferenceConfigForm extends ConfigFormBase {
     $form['password'] = [
       '#type' => '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,
       '#size' => 64,
       '#default_value' => $config->get('password'),
@@ -65,7 +65,7 @@ class JsonApiReferenceConfigForm extends ConfigFormBase {
     parent::submitForm($form, $form_state);
 
     $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'));
     if ($password = $form_state->getValue('password')) {
       $config->set('password', $password);
diff --git a/src/JsonApiClient.php b/src/JsonApiClient.php
index 884a9b7..7b8d6df 100644
--- a/src/JsonApiClient.php
+++ b/src/JsonApiClient.php
@@ -16,28 +16,28 @@ use GuzzleHttp\RequestOptions;
 class JsonApiClient implements JsonApiClientInterface {
 
   /**
-   * Client for querying JSON:API endpoints.
+   * Client for querying the JSON:API entrypoint.
    *
    * @var \GuzzleHttp\ClientInterface
    */
   protected $httpClient;
 
   /**
-   * Endpoint to call to retrieve JSONAPI objects.
+   * Entrypoint to call to retrieve JSONAPI objects.
    *
    * @var string
    */
-  protected $endpoint;
+  protected $entrypoint;
 
   /**
-   * Username to use when authenticating to endpoint.
+   * Username to use when authenticating to the entrypoint.
    *
    * @var string
    */
   protected $username;
 
   /**
-   * Password to use when authenticating to endpoint.
+   * Password to use when authenticating to the entrypoint.
    *
    * @var string
    */
@@ -54,7 +54,7 @@ class JsonApiClient implements JsonApiClientInterface {
    * JsonApiClient constructor.
    *
    * @param \GuzzleHttp\ClientInterface $httpClient
-   *   Client for querying JSON:API endpoints.
+   *   Client for querying the JSON:API entrypoint.
    * @param \Drupal\Core\Logger\LoggerChannelInterface $loggerChannel
    *   Channel for logging.
    * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
@@ -62,7 +62,7 @@ class JsonApiClient implements JsonApiClientInterface {
    */
   public function __construct(ClientInterface $httpClient, LoggerChannelInterface $loggerChannel, ConfigFactoryInterface $configFactory) {
     $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->password = $configFactory->get('jsonapi_reference.settings')->get('password');
     $this->loggerChannel = $loggerChannel;
@@ -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[]
    *   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.
    */
   protected function getResourceObjectTypes() {
     try {
-      $response = $this->httpClient->request('get', $this->endpoint, $this->getRequestOptions());
+      $response = $this->httpClient->request('get', $this->entrypoint, $this->getRequestOptions());
     }
     catch (GuzzleException $e) {
       $this->loggerChannel->error($e->getMessage());
@@ -93,7 +93,7 @@ class JsonApiClient implements JsonApiClientInterface {
     }
     $response = json_decode($response->getBody()->getContents());
     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 (array) $response->links;
@@ -105,9 +105,9 @@ class JsonApiClient implements JsonApiClientInterface {
   public function search($resource_object_type, $search_attribute, $query) {
     $path = $this->getPathForResourceObjectType($resource_object_type);
     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,
-        '@endpoint' => $this->endpoint,
+        '@entrypoint' => $this->entrypoint,
       ]);
       return [];
     }
@@ -136,8 +136,8 @@ class JsonApiClient implements JsonApiClientInterface {
     foreach ($response->data as $result) {
       $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".', [
-      '@endpoint' => $this->endpoint,
+    $this->loggerChannel->error('JSON:API entrypoint @entrypoint returned no data for path @path when searching for objects where the @search_attribute attribute matched "@query".', [
+      '@entrypoint' => $this->entrypoint,
       '@path' => $path,
       '@search_attribute' => $search_attribute,
       '@query' => $query,
diff --git a/src/JsonApiClientInterface.php b/src/JsonApiClientInterface.php
index dc39243..fb97fcd 100644
--- a/src/JsonApiClientInterface.php
+++ b/src/JsonApiClientInterface.php
@@ -10,7 +10,7 @@ namespace Drupal\jsonapi_reference;
 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[]
    *   Array of remote object types.src/JsonApiClient.php
@@ -25,7 +25,7 @@ interface JsonApiClientInterface {
   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
    *   Resource object type.
-- 
GitLab