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

Issue #3092666 by jkswoods, Eli-T: Apply fixes for highlighted PHPCS issues

parent 3022c425
Branches
Tags
No related merge requests found
JSON:API reference provides a field type Typed Resource Object, that is similar to an entity reference field. However, rather than refer to an entity on the same Drupal installation, this refers to a resource object exposed via JSON:API.
JSON:API reference provides a field type Typed Resource Object, that is similar
to an entity reference field. However, rather than refer to an entity on the
same Drupal installation, this refers to a resource object exposed via
JSON:API.
For example - if you are syndicating content from one system to another, you may want to create a typed resource object field on the user entity type on the source system, which refers to the corresponding user on the destination system.
For example - if you are syndicating content from one system to another, you
may want to create a typed resource object field on the user entity type on
the source system, which refers to the corresponding user on the destination
system.
You then may want to add a typed resource object field to the content types from which you are syndicating on the source system so that you can record the relationship to the newly created content in the future.
You then may want to add a typed resource object field to the content types
from which you are syndicating on the source system so that you can record the
relationship to the newly created content in the future.
The module provides an autocomplete widget that looks up resources in the remote system as you type and suggests . Because different types of resource object will autocomplete by comparing the user input against a different attribute, the attribute against which autocompletion takes place is configured in the widget.
The module provides an autocomplete widget that looks up resources in the
remote system as you type and suggests . Because different types of resource
object will autocomplete by comparing the user input against a different
attribute, the attribute against which autocompletion takes place is configured
in the widget.
Caveats & Assumptions
* The module assumes that all fields come from the same remote system
* The module assumes that authentication is done by basic authentication on the remote system
* The module has not been tested against non-Drupal remote systems, but this may work
* The module does not provide and Field Formatters so currently displays the GUID of the resource object as text
* The module assumes that authentication is done by basic authentication on the
remote system
* The module has not been tested against non-Drupal remote systems, but this
may work
* The module does not provide and Field Formatters so currently displays the
GUID of the resource object as text
......@@ -4,4 +4,3 @@ jsonapi_reference.json_api_reference_config_form:
description: 'Configure access to the remote JSON:API system for referencing in Typed Resource Object fields.'
parent: system.admin_config_services
weight: 99
......@@ -58,13 +58,6 @@ class JsonApiReferenceConfigForm extends ConfigFormBase {
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
......
......@@ -94,10 +94,10 @@ class TypedResourceObjectItem extends FieldItemBase {
$elements['resource_object_type'] = [
'#type' => 'select',
'#title' => t('Type'),
'#title' => $this->t('Type'),
'#default_value' => $this->getSetting('resource_object_type'),
'#required' => TRUE,
'#description' => t('The type of resource object.'),
'#description' => $this->t('The type of resource object.'),
'#disabled' => $has_data,
'#options' => array_combine($types, $types),
];
......
......@@ -35,9 +35,9 @@ class TypedResourceObjectAutocompleteWidget extends WidgetBase {
public function settingsForm(array $form, FormStateInterface $form_state) {
$element['autocomplete_attribute'] = [
'#type' => 'textfield',
'#title' => t('Autocomplete attribute'),
'#title' => $this->t('Autocomplete attribute'),
'#default_value' => $this->getSetting('autocomplete_attribute'),
'#description' => t('The attribute in the JSON:API resource object against which to match when autocompleting.'),
'#description' => $this->t('The attribute in the JSON:API resource object against which to match when autocompleting.'),
'#required' => TRUE,
];
......@@ -87,7 +87,7 @@ class TypedResourceObjectAutocompleteWidget extends WidgetBase {
* @return mixed
* The value to assign to the element.
*/
public static function valueCallback($element, $input, FormStateInterface $form_state) {
public static function valueCallback(array $element, $input, FormStateInterface $form_state) {
$value = '';
// If we're rebuilding the form due to AJAX (eg adding another item to the
......
......@@ -18,14 +18,6 @@ class JsonApiReferenceTest extends BrowserTestBase {
*/
static protected $modules = ['jsonapi_reference'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
}
/**
* Test configuration form protected by permissions.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment