3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00

Issue #3207716 by paul121: Use BundleFieldDefinition for additional Consumer fields

This commit is contained in:
paul121 2021-04-07 21:02:02 -07:00 committed by Michael Stenta
parent 2b95c6458c
commit 2c5a38dc6f
11 changed files with 68 additions and 248 deletions

View file

@ -1,71 +0,0 @@
langcode: en
status: true
dependencies:
config:
- field.field.consumer.consumer.client_id
- field.field.consumer.consumer.grant_user_access
- field.field.consumer.consumer.limit_requested_access
- field.field.consumer.consumer.limit_user_access
- image.style.thumbnail
enforced:
module:
- farm_api
module:
- consumers
- image
id: consumer.consumer.default
targetEntityType: consumer
bundle: consumer
mode: default
content:
client_id:
weight: -4
settings:
size: 255
placeholder: ''
third_party_settings: { }
type: string_textfield
region: content
description:
type: string_textfield
weight: 0
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
grant_user_access:
weight: 4
settings: { }
third_party_settings: { }
type: boolean_checkbox
region: content
image:
type: image_image
weight: -3
settings:
preview_image_style: thumbnail
progress_indicator: throbber
region: content
third_party_settings: { }
label:
type: string_textfield
weight: -5
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
limit_requested_access:
weight: 4
settings: { }
third_party_settings: { }
type: boolean_checkbox
region: content
limit_user_access:
weight: 4
settings: { }
third_party_settings: { }
type: boolean_checkbox
region: content
hidden: { }

View file

@ -1,22 +0,0 @@
langcode: en
status: true
dependencies:
config:
- field.storage.consumer.client_id
enforced:
module:
- farm_api
module:
- consumers
id: consumer.consumer.client_id
field_name: client_id
entity_type: consumer
bundle: consumer
label: 'Client ID'
description: 'OAuth client_id associated with this consumer.'
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string

View file

@ -1,24 +0,0 @@
langcode: en
status: true
dependencies:
config:
- field.storage.consumer.grant_user_access
enforced:
module:
- farm_api
module:
- consumers
id: consumer.consumer.grant_user_access
field_name: grant_user_access
entity_type: consumer
bundle: consumer
label: 'Grant user access'
description: 'Always grant the authorizing user''s access to this consumer.'
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
on_label: 'On'
off_label: 'Off'
field_type: boolean

View file

@ -1,24 +0,0 @@
langcode: en
status: true
dependencies:
config:
- field.storage.consumer.limit_requested_access
enforced:
module:
- farm_api
module:
- consumers
id: consumer.consumer.limit_requested_access
field_name: limit_requested_access
entity_type: consumer
bundle: consumer
label: 'Limit to requested access'
description: 'Only grant this consumer the scopes requested during authorization.'
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
on_label: 'On'
off_label: 'Off'
field_type: boolean

View file

@ -1,24 +0,0 @@
langcode: en
status: true
dependencies:
config:
- field.storage.consumer.limit_user_access
enforced:
module:
- farm_api
module:
- consumers
id: consumer.consumer.limit_user_access
field_name: limit_user_access
entity_type: consumer
bundle: consumer
label: 'Limit to user access'
description: 'Never grant this consumer more access than the authorizing user.'
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
on_label: 'On'
off_label: 'Off'
field_type: boolean

View file

@ -1,23 +0,0 @@
langcode: en
status: true
dependencies:
module:
- consumers
enforced:
module:
- farm_api
id: consumer.client_id
field_name: client_id
entity_type: consumer
type: string
settings:
max_length: 255
is_ascii: false
case_sensitive: false
module: core
locked: false
cardinality: 1
translatable: false
indexes: { }
persist_with_no_fields: false
custom_storage: false

View file

@ -1,20 +0,0 @@
langcode: en
status: true
dependencies:
module:
- consumers
enforced:
module:
- farm_api
id: consumer.grant_user_access
field_name: grant_user_access
entity_type: consumer
type: boolean
settings: { }
module: core
locked: false
cardinality: 1
translatable: false
indexes: { }
persist_with_no_fields: false
custom_storage: false

View file

@ -1,20 +0,0 @@
langcode: en
status: true
dependencies:
module:
- consumers
enforced:
module:
- farm_api
id: consumer.limit_requested_access
field_name: limit_requested_access
entity_type: consumer
type: boolean
settings: { }
module: core
locked: false
cardinality: 1
translatable: false
indexes: { }
persist_with_no_fields: false
custom_storage: false

View file

@ -1,20 +0,0 @@
langcode: en
status: true
dependencies:
module:
- consumers
enforced:
module:
- farm_api
id: consumer.limit_user_access
field_name: limit_user_access
entity_type: consumer
type: boolean
settings: { }
module: core
locked: false
cardinality: 1
translatable: false
indexes: { }
persist_with_no_fields: false
custom_storage: false

View file

@ -6,6 +6,7 @@ core_version_requirement: ^9
dependencies:
- config_rewrite:config_rewrite
- drupal:jsonapi
- entity:entity
- jsonapi_extras:jsonapi_extras
- jsonapi_schema:jsonapi_schema
- simple_oauth:simple_oauth

View file

@ -5,6 +5,9 @@
* Contains farm_api.module.
*/
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\entity\BundleFieldDefinition;
/**
* Implements hook_consumers_list_alter().
*
@ -23,3 +26,67 @@ function farm_api_consumers_list_alter(&$data, $context) {
}
}
}
/**
* Implements hook_entity_base_field_info().
*/
function farm_api_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = [];
$fields['client_id'] = BundleFieldDefinition::create('string')
->setLabel(t('Client ID'))
->setDescription(t('OAuth client_id associated with this consumer.'))
->setSetting('max_length', 255)
->setSetting('is_ascii', FALSE)
->setSetting('case_sensitive', FALSE)
->setDisplayOptions('form', [
'type' => 'string_textfield',
'settings' => [
'size' => 255,
'placeholder' => '',
],
'weight' => '-4',
]);
$fields['grant_user_access'] = BundleFieldDefinition::create('boolean')
->setLabel(t('Grant user access'))
->setDescription(t("Always grant the authorizing user's access to this consumer."))
->setSetting('on_label', t('Yes'))
->setSetting('off_label', t('No'))
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'settings' => [
'display_label' => TRUE,
],
'weight' => 4,
]);
$fields['limit_requested_access'] = BundleFieldDefinition::create('boolean')
->setLabel(t('Limit to requested access'))
->setDescription(t('Only grant this consumer the scopes requested during authorization.'))
->setSetting('on_label', t('Yes'))
->setSetting('off_label', t('No'))
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'settings' => [
'display_label' => TRUE,
],
'weight' => 4,
]);
$fields['limit_user_access'] = BundleFieldDefinition::create('boolean')
->setLabel(t('Limit to user access'))
->setDescription(t('Never grant this consumer more access than the authorizing user.'))
->setSetting('on_label', t('Yes'))
->setSetting('off_label', t('No'))
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'settings' => [
'display_label' => TRUE,
],
'weight' => 4,
]);
return $fields;
}