Skip to content
Snippets Groups Projects
Commit cb9da807 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 d07b0c38
Branches 6.0.x
Tags 6.0.2
1 merge request!36Update phone matcher patch with tests and fix Drupal coding standards
......@@ -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 register or to comment