Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions apigee_api_catalog.install
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,13 @@ function apigee_api_catalog_update_8809() {
function apigee_api_catalog_update_8810() {
return \Drupal::service('apigee_api_catalog.updates')->update8810();
}

/**
* Implements hook_update_N().
*
* Readded yml extension to field_apidoc_file_link and
* field_apidoc_spec allowed values.
*/
function apigee_api_catalog_update_11001() {
return \Drupal::service('apigee_api_catalog.updates')->addYmlExtension();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ default_value_callback: ''
settings:
link_type: 17
title: 0
file_extensions: 'yaml json'
file_extensions: 'yml yaml json'
no_extension: false
field_type: file_link
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ default_value: { }
default_value_callback: ''
settings:
file_directory: apidoc_specs
file_extensions: 'yaml json'
file_extensions: 'yml yaml json'
max_filesize: ''
description_field: false
handler: 'default:file'
Expand Down

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add the update function for this field as well?

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ settings:
handler: 'default:file'
handler_settings: { }
file_directory: asyncapi_specs
file_extensions: 'yaml json'
file_extensions: 'yml yaml json'
max_filesize: ''
description_field: false
field_type: file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is missing in update function.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ settings:
handler: 'default:file'
handler_settings: { }
file_directory: freeform_specs_doc
file_extensions: 'zip jpg jpeg gif png txt html doc xls pdf ppt pps yaml'
file_extensions: 'zip jpg jpeg gif png txt html doc xls pdf ppt pps yaml yml'
max_filesize: ''
description_field: false
field_type: file
25 changes: 24 additions & 1 deletion src/UpdateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public function update8810() {
}
}

return 'Removed the yml extension from field_apidoc_file_link and field_apidoc_spec allowed values for security reasons.';
return 'Removed the yml extension from field_apidoc_file_link and field_apidoc_spec allowed values.';
}

/**
Expand Down Expand Up @@ -477,4 +477,27 @@ protected function addToFieldMap(string $old, string $new) {
\Drupal::state()->set('apigee_api_catalog_update_8803_fieldmap', $map);
}

/**
* Re-added .yml file upload.
*/
public function addYmlExtension() {
$fields = [
'field_apidoc_file_link',
'field_apidoc_spec',
];

foreach ($fields as $field) {
$fieldConfig = FieldConfig::loadByName('node', 'apidoc', $field);
// Check if yml extension present before adding it.
$extensions = $fieldConfig->getSetting('file_extensions');
if (strpos($extensions, 'yml') === FALSE) {
// Readd yml extension from allowed values.
$fieldConfig->setSetting('file_extensions', $extensions . ' yml')
->save();
}
}

return 'Added the yml extension from field_apidoc_file_link and field_apidoc_spec allowed values.';
}

}
Loading