Browse Source

Add display for free form license text.

wip
Alexander O'Neill 6 years ago
parent
commit
e6c6226f0a
  1. 13
      config/optional/core.entity_form_display.paragraph.license_attribution.default.yml
  2. 21
      config/optional/field.field.paragraph.license_attribution.field_attribution_note.yml
  3. 2
      config/optional/field.field.paragraph.license_attribution.field_license.yml
  4. 20
      config/optional/field.storage.paragraph.field_attribution_note.yml
  5. 13
      media_attribution.module

13
config/optional/core.entity_form_display.paragraph.license_attribution.default.yml

@ -1,15 +1,18 @@
uuid: 20c075d8-ec9f-407a-8564-9918dfff6dd6
langcode: en
status: true
dependencies:
config:
- field.field.paragraph.license_attribution.field_attribution_author
- field.field.paragraph.license_attribution.field_attribution_note
- field.field.paragraph.license_attribution.field_attribution_source
- field.field.paragraph.license_attribution.field_license
- paragraphs.paragraphs_type.license_attribution
module:
- link
- text
_core:
default_config_hash: TX7aCKFhicHNk-Ce09bQTNTKUZhRXX0QsSWzjuGutWA
default_config_hash: WCcyeF8AktyxDRFDYOVNNyfYpTfjnlsm53vdo1EP968
id: paragraph.license_attribution.default
targetEntityType: paragraph
bundle: license_attribution
@ -23,6 +26,14 @@ content:
third_party_settings: { }
type: link_default
region: content
field_attribution_note:
weight: 3
settings:
size: 80
placeholder: ''
third_party_settings: { }
type: text_textfield
region: content
field_attribution_source:
weight: 0
settings:

21
config/optional/field.field.paragraph.license_attribution.field_attribution_note.yml

@ -0,0 +1,21 @@
langcode: en
status: true
dependencies:
config:
- field.storage.paragraph.field_attribution_note
- paragraphs.paragraphs_type.license_attribution
module:
- text
third_party_settings: { }
id: paragraph.license_attribution.field_attribution_note
field_name: field_attribution_note
entity_type: paragraph
bundle: license_attribution
label: 'Free-form Attribution Note'
description: 'Specify custom attribution and / or copyright info. E.g., "All rights reserved. Used with permission."'
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: text

2
config/optional/field.field.paragraph.license_attribution.field_license.yml

@ -11,7 +11,7 @@ entity_type: paragraph
bundle: license_attribution
label: License
description: ''
required: true
required: false
translatable: false
default_value: { }
default_value_callback: ''

20
config/optional/field.storage.paragraph.field_attribution_note.yml

@ -0,0 +1,20 @@
langcode: en
status: true
dependencies:
module:
- paragraphs
- text
third_party_settings: { }
id: paragraph.field_attribution_note
field_name: field_attribution_note
entity_type: paragraph
type: text
settings:
max_length: 1024
module: text
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

13
media_attribution.module

@ -91,8 +91,8 @@ function media_attribution_preprocess_entity_embed_container(&$variables) {
$source = $attribution->get('field_attribution_source')->getValue()[0];
$license = $attribution->get('field_license')->entity;
$license_link = $license->get('field_license_link')->getValue()[0];
$license_link = !empty($license) ? $license->get('field_license_link')->getValue()[0] : FALSE;
$attribution_note = $attribution->get('field_attribution_note')->getValue()[0];
$attribution_text = [
'source' => [
'#type' => 'link',
@ -109,6 +109,7 @@ function media_attribution_preprocess_entity_embed_container(&$variables) {
'#title' => $author['title'],
'#prefix' => ' ' . t('by') . ' ',
'#url' => Url::fromUri($author['uri']),
'#suffix' => '. ',
];
}
if (!empty($license_link)) {
@ -121,7 +122,13 @@ function media_attribution_preprocess_entity_embed_container(&$variables) {
];
}
if (!empty($attribution_note)) {
$attribution_text['note'] = [
'#type' => 'markup',
'#markup' => $attribution_note['value'],
'#prefix' => ' ',
];
}
$variables['children'] = [
'first' => [
'#type' => 'markup',

Loading…
Cancel
Save