Skip to content

Commit

Permalink
Merge 16c7b3d into 2c441c9
Browse files Browse the repository at this point in the history
  • Loading branch information
khalima authored Feb 27, 2024
2 parents 2c441c9 + 16c7b3d commit deb8a8d
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions modules/hdbt_admin_tools/hdbt_admin_tools.module
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use Drupal\hdbt_admin_tools\Plugin\Field\FieldType\SelectIcon;
use Drupal\helfi_api_base\Link\UrlHelper;
use Drupal\helfi_tpr\Entity\Service;
use Drupal\node\NodeInterface;
use Drupal\paragraphs\Entity\ParagraphsType;
use Drupal\user\UserInterface;

/**
Expand Down Expand Up @@ -895,40 +894,6 @@ function hdbt_admin_tools_preprocess_links__dropbutton__operations__paragraphs(&
}
}

/**
* Implements hook_preprocess_HOOK().
*/
function hdbt_admin_tools_preprocess_input__submit__paragraph_action(array &$variables): void {

// According to UX team it's better to show the "Add @type" buttons without
// the Add word. Fix the texts from these buttons.
$paragraph_add_more_buttons = [
'accordion_item_add_more',
];

foreach ($paragraph_add_more_buttons as $button) {
if (
!isset($variables['element']['#name']) ||
!str_contains($variables['element']['#name'], $button)
) {
return;
}

// Get the label from the paragraph type and change the button label to
// match the label of the paragraph type.
$paragraph_storage = \Drupal::entityTypeManager()->getStorage('paragraphs_type');
$paragraph_type = $paragraph_storage->load($variables['element']['#bundle_machine_name']);

if (!$paragraph_type instanceof ParagraphsType) {
return;
}

$variables['attributes']['value'] = t('@type', [
'@type' => $paragraph_type->get('label'),
]);
}
}

/**
* Implements hook_form_alter().
*/
Expand Down

0 comments on commit deb8a8d

Please sign in to comment.