Skip to content
Snippets Groups Projects
Commit 2f77a656 authored by Mark Fullmer's avatar Mark Fullmer Committed by Mark Fullmer
Browse files

Issue #3212820 by mark_fullmer, SamLerner, trackleft2: Provide backward...

Issue #3212820 by mark_fullmer, SamLerner, trackleft2: Provide backward compatibilty layer for upcasting linkit profile in linkit.autocomplete route
parent b325c7e5
No related branches found
No related tags found
3 merge requests!78Issue #3472672: Fix the issues reported by PHP_CodeSniffer,!59Revert "Issue #2900766 by rubendello: Not all autocomplete values are...,!40Issue #3262401 by Dom., Berdir: Deprecated function : Return type of...
......@@ -91,7 +91,7 @@ function linkit_form_editor_link_dialog_alter(&$form, FormStateInterface $form_s
'#description' => t('Start typing to find content.'),
'#autocomplete_route_name' => 'linkit.autocomplete',
'#autocomplete_route_parameters' => [
'linkit_profile' => $linkit_profile_id,
'linkit_profile_id' => $linkit_profile_id,
],
"#weight" => -10,
'#default_value' => $input['href'] ?? '',
......
......@@ -61,7 +61,7 @@ linkit.matcher.edit:
_permission: 'administer linkit profiles'
linkit.autocomplete:
path: '/linkit/autocomplete/{linkit_profile}'
path: '/linkit/autocomplete/{linkit_profile_id}'
defaults:
_controller: '\Drupal\linkit\Controller\AutocompleteController::autocomplete'
requirements:
......@@ -69,3 +69,6 @@ linkit.autocomplete:
_access: 'TRUE'
options:
_theme: ajax_base_page
parameters:
linkit_profile_id:
type: entity:linkit_profile
......@@ -48,16 +48,19 @@ class AutocompleteController implements ContainerInjectionInterface {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request.
* @param \Drupal\linkit\ProfileInterface $linkit_profile
* @param \Drupal\linkit\ProfileInterface $linkit_profile_id
* The linkit profile.
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
* A JSON response containing the autocomplete suggestions.
*/
public function autocomplete(Request $request, ProfileInterface $linkit_profile) {
public function autocomplete(Request $request, ProfileInterface $linkit_profile_id) {
// We do not need to load the entity, since it is upcaste automatically,
// per https://www.drupal.org/project/linkit/issues/3212820.
// The erroneous variable name $linkit_profile_id is to avoid BC breaks.
$string = $request->query->get('q');
$suggestionCollection = $this->suggestionManager->getSuggestions($linkit_profile, mb_strtolower($string));
$suggestionCollection = $this->suggestionManager->getSuggestions($linkit_profile_id, mb_strtolower($string));
/*
* If there are no suggestions from the matcher plugins, we have to add a
......
......@@ -147,7 +147,7 @@ class Linkit extends CKEditor5PluginDefault implements CKEditor5PluginConfigurab
return [
'linkit' => [
'profile' => $this->configuration['linkit_profile'],
'autocompleteUrl' => Url::fromRoute('linkit.autocomplete', ['linkit_profile' => $this->configuration['linkit_profile']])
'autocompleteUrl' => Url::fromRoute('linkit.autocomplete', ['linkit_profile_id' => $this->configuration['linkit_profile']])
->toString(TRUE)
->getGeneratedUrl()
],
......
......@@ -181,7 +181,7 @@ class LinkitWidget extends LinkWidget {
$element['uri']['#description'] = $this->t('Start typing to find content or paste a URL and click on the suggestion below.');
$element['uri']['#autocomplete_route_name'] = 'linkit.autocomplete';
$element['uri']['#autocomplete_route_parameters'] = [
'linkit_profile' => $this->getSetting('linkit_profile'),
'linkit_profile_id' => $this->getSetting('linkit_profile'),
];
// Add a class to the title field.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment