Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-7459: Added missing dependency #177

Merged
merged 3 commits into from
Nov 16, 2022
Merged
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
1 change: 1 addition & 0 deletions modules/hdbt_admin_editorial/hdbt_admin_editorial.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ dependencies:
- drupal:editor
- drupal:linkit
- drupal:hdbt_admin_tools
- drupal:select2_icon
'interface translation project': hdbt_admin_editorial
'interface translation server pattern': themes/contrib/hdbt_admin/modules/hdbt_admin_editorial/translations/%language.po
19 changes: 8 additions & 11 deletions modules/select2_icon/src/Plugin/Field/FieldType/Select2Icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function isEmpty() {
* @return array
* Returns an array of icons or empty array.
*/
public static function loadIcons() {
public static function loadIcons() : array {
if ($icons = \Drupal::cache()->get(static::SELECT2_ICON_CACHE)) {
return $icons->data;
}
Expand All @@ -69,17 +69,14 @@ public static function loadIcons() {
$config = \Drupal::getContainer()->get('config.factory')->getEditable('select2_icon.settings');
$json_path = \Drupal::root() . $config->get('path_to_json');

try {
if (!$data = file_get_contents($json_path)) {
throw new \InvalidArgumentException(
'Failed to load icons due to missing icons data. Verify that the "path_to_json" key contains correct information in the select2_icon.settings configuration.'
);
}
}
catch (\InvalidArgumentException $e) {
\Drupal::messenger()->addWarning($e->getMessage());
}
if (!$data = file_get_contents($json_path)) {
\Drupal::messenger()
->addWarning('Failed to load icons due to missing icons data. Verify that the "path_to_json" key contains correct information in the select2_icon.settings configuration. Current value: @current_value', [
'@current_value' => $json_path,
]);

return [];
}
$json = json_decode($data, TRUE);

if (is_array($json) && !empty($json)) {
Expand Down