Problem/Motivation
If we look at the contents of radiostoslider.module file:
/**
* Implements hook_help().
*/
// @phpstan-ignore-next-line
#[LegacyHook]
// phpcs:ignore
function radiostoslider_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.radiostoslider':
$output = '<p> ' . t(
'@radiostoslider is a module that allows the content managers to use the
@lib plugin for the List radios entity field types. <br/>
The module also provides a WebForm element that uses the Radio to Slider
plugin. <br />
No additional module\'s configuration required.<br />
<h3>How to install:</h3><br />
<ol>
<li>Install the module.</li>
<li>Install the Radios to Slider library: Download it and save it to
your "/libraries/radios-to-slider" folder.</li>
</ol>
<h3>How to use:</h3><br />
Go to Edit the Entity display form and select the Radios to Slider
widget for the select list fields, configure it.',
[
'@radiostoslider' => Link::fromTextAndUrl(
t('Radios to Slider'),
Url::fromUri('https://www.drupal.org/project/radiostoslider')
)->toString(),
'@lib' => Link::fromTextAndUrl(
t('Radios to Slider'),
Url::fromUri('https://github.com/rubentd/radios-to-slider')
)->toString(),
]
) . '</p>';
return $output;
}
}
/**
* Implements hook_page_attachments().
*/
// @phpstan-ignore-next-line
#[LegacyHook]
// phpcs:ignore
function radios_to_slider_page_attachments(array &$page): void {
$page['#attached']['library'][] = 'radiostoslider/global-scripts';
}
/**
* Implements hook_theme().
*/
// @phpstan-ignore-next-line
#[LegacyHook]
// phpcs:ignore
function radiostoslider_theme() {
return [
'radios_to_slider' => [
'render element' => 'element',
],
];
}
/**
* Prepares variables for radios-to-slider templates.
*
* Default template: radios-to-slider.html.twig.
*
* @param array $vars
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #options, #description, #required,
* #attributes, #children.
*/
// @phpstan-ignore-next-line
#[LegacyHook]
// phpcs:ignore
function template_preprocess_radios_to_slider(array &$vars) {
$element = $vars['element'];
$vars['attributes'] = [];
if (isset($element['#id'])) {
$vars['attributes']['id'] = $element['#id'];
}
if (isset($element['#attributes']['title'])) {
$vars['attributes']['title'] = $element['#attributes']['title'];
}
$vars['attributes']['data-animation'] =
!empty($element['#animation']) ? 1 : 0;
$vars['attributes']['data-fit-container'] =
!empty($element['#fit_container']) ? 1 : 0;
$vars['children'] = $element['#children'];
}
This is duplicated code that is already implemented as service methods at /src/Hook/RadiosToSlider.php so these need to converted to calls to these service methods.
Steps to reproduce
N/A
Proposed resolution
Look for the info above
Remaining tasks
N/A
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Comments
Comment #5
ritarshi_chakraborty commentedPlease review my MR.
Comment #6
danrodI tested this on my local D10.5.6 environment and I got this error:
This needs to be fixed.
Comment #7
danrodComment #8
ritarshi_chakraborty commentedThat is weird. My site is running well and I'm getting no such error :)
Comment #9
ritarshi_chakraborty commentedHey @danrod, do you still see the error?
Comment #10
danrodHi @ritarshi_chakraborty , yes, I still see the error, I'll review this again later today. Thank you.
Comment #11
danrodHi @ritarshi_chakraborty , I reviewed this again and it's working on me now, thanks a lot for your work on this, I'll move this to "Fixed" and merge it to the 2.0.x branch. Thanks !
Comment #12
danrodComment #13
danrodComment #15
danrod