Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

added site app icon field #159

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
uuid: 3bfef526-070c-4a20-a671-7e4cd7799bc3
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.field_short_name
- taxonomy.vocabulary.sites
id: taxonomy_term.sites.field_short_name
field_name: field_short_name
entity_type: taxonomy_term
bundle: sites
label: 'Short name'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
uuid: 148ec44d-98a7-489f-af6a-c39ef740b4aa
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.field_site_app_icon
- taxonomy.vocabulary.sites
module:
- image
id: taxonomy_term.sites.field_site_app_icon
field_name: field_site_app_icon
entity_type: taxonomy_term
bundle: sites
label: 'Site app icon'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:file'
handler_settings: { }
file_directory: '[date:custom:Y]-[date:custom:m]'
file_extensions: 'png gif jpg jpeg webp'
max_filesize: ''
max_resolution: 512x512
min_resolution: 512x512
alt_field: true
alt_field_required: true
title_field: false
title_field_required: false
default_image:
uuid: ''
alt: ''
title: ''
width: null
height: null
field_type: image
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ settings:
file_directory: '[date:custom:Y]-[date:custom:m]'
file_extensions: 'png gif jpg jpeg'
max_filesize: ''
max_resolution: ''
min_resolution: ''
max_resolution: 128x128
min_resolution: 128x128
alt_field: true
alt_field_required: true
title_field: false
Expand Down
21 changes: 21 additions & 0 deletions config/install/field.storage.taxonomy_term.field_short_name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
uuid: 8fddc614-5935-4014-8a0a-9c4a200ddea9
langcode: en
status: true
dependencies:
module:
- taxonomy
id: taxonomy_term.field_short_name
field_name: field_short_name
entity_type: taxonomy_term
type: string
settings:
max_length: 12
case_sensitive: false
is_ascii: false
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
34 changes: 34 additions & 0 deletions config/install/field.storage.taxonomy_term.field_site_app_icon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
uuid: 5701f011-5ad2-46d5-9b59-24c52ed1fd36
langcode: en
status: true
dependencies:
module:
- field_permissions
- file
- image
- taxonomy
third_party_settings:
field_permissions:
permission_type: public
id: taxonomy_term.field_site_app_icon
field_name: field_site_app_icon
entity_type: taxonomy_term
type: image
settings:
target_type: file
display_field: false
display_default: false
uri_scheme: public
default_image:
uuid: ''
alt: ''
title: ''
width: null
height: null
module: image
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
56 changes: 54 additions & 2 deletions modules/tide_site_theming/src/TideSiteThemingOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,38 @@ public function requiredChangesForTheming() {
];
$entity_form_display->setThirdPartySetting('field_group', 'group_site_favicon_value', $field_group['group_site_favicon_value']);

// Adds app icon.
$entity_form_display->setComponent('field_site_app_icon', [
'type' => 'image_image',
'weight' => 20,
'region' => 'content',
'settings' => [
'progress_indicator' => 'throbber',
'preview_image_style' => 'thumbnail',
],
'third_party_settings' => [],
]);
$field_group = $entity_form_display->getThirdPartySettings('field_group');
$field_group['group_site_app_icon'] = [
'children' => [
'field_site_app_icon',
],
'parent_name' => '',
'label' => 'Site app icon',
'weight' => 19,
'format_type' => 'details',
'region' => 'content',
'format_settings' => [
'classes' => '',
'show_empty_fields' => FALSE,
'id' => 'tide-site-app-icon',
'open' => FALSE,
'required_fields' => TRUE,
'effect' => 'none',
],
];
$entity_form_display->setThirdPartySetting('field_group', 'group_site_app_icon', $field_group['group_site_app_icon']);

// Adds header corner graphics.
$entity_form_display->setComponent('field_top_corner_graphic', [
'type' => 'image_image',
Expand Down Expand Up @@ -219,7 +251,7 @@ public function requiredChangesForTheming() {
],
'third_party_settings' => [],
])->save();
$entity_view_display->setComponent('field_top_corner_graphic', [
$entity_view_display->setComponent('field_site_app_icon', [
'type' => 'image',
'weight' => 19,
'label' => 'above',
Expand All @@ -238,7 +270,7 @@ public function requiredChangesForTheming() {
],
'third_party_settings' => [],
])->save();
$entity_view_display->setComponent('field_bottom_corner_graphic', [
$entity_view_display->setComponent('field_top_corner_graphic', [
'type' => 'image',
'weight' => 20,
'label' => 'above',
Expand All @@ -257,6 +289,25 @@ public function requiredChangesForTheming() {
],
'third_party_settings' => [],
])->save();
$entity_view_display->setComponent('field_bottom_corner_graphic', [
'type' => 'image',
'weight' => 21,
'label' => 'above',
'region' => 'content',
'settings' => [
'image_link' => '',
'image_style' => '',
'svg_attributes' => [
'width' => NULL,
'height' => NULL,
],
'svg_render_as_image' => TRUE,
'image_loading' => [
'attribute' => 'lazy',
],
],
'third_party_settings' => [],
])->save();
}

// Grant view preview links block to default roles from tide_core.
Expand All @@ -272,6 +323,7 @@ public function requiredChangesForTheming() {
'field_site_theme_values',
'field_site_feature_flags',
'field_site_favicon',
'field_site_app_icon',
'field_top_corner_graphic',
'field_bottom_corner_graphic',
];
Expand Down
25 changes: 25 additions & 0 deletions modules/tide_site_theming/tide_site_theming.install
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,28 @@ function tide_site_theming_update_8001() {
}
$config->save();
}

/**
* Add site app icon and short name fields.
*/
function tide_site_theming_update_10001() {
$configs = [
'field.storage.taxonomy_term.field_short_name' => 'field_storage_config',
'field.storage.taxonomy_term.field_site_app_icon' => 'field_storage_config',
'field.field.taxonomy_term.sites.field_short_name' => 'field_config',
'field.field.taxonomy_term.sites.field_site_app_icon' => 'field_config',
];
module_load_include('inc', 'tide_core', 'includes/helpers');
$config_location = [\Drupal::service('extension.list.module')->getPath('tide_site') . '/config/install'];
// Check if field already exported to config/sync.
foreach ($configs as $config => $type) {
$config_read = _tide_read_config($config, $config_location, TRUE);
$storage = \Drupal::entityTypeManager()->getStorage($type);
$id = $storage->getIDFromConfigName($config, $storage->getEntityType()->getConfigPrefix());
if ($storage->load($id) == NULL) {
$config_entity = $storage->createFromStorageRecord($config_read);
$config_entity->save();
}
}

}
Loading