Skip to content

SYL-4341 Remove documentation links #74

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

Merged
merged 12 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
25 changes: 0 additions & 25 deletions config/services/documentation.xml

This file was deleted.

7 changes: 0 additions & 7 deletions config/services/form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

<services>
<service id="sylius_mollie.form.type.mollie_gateway_configuration" class="Sylius\MolliePlugin\Form\Type\MollieGatewayConfigurationType">
<argument type="service" id="sylius_mollie.documentation.documentation_links"/>
<argument type="service" id="sylius_mollie.mollie_api_client"/>
<tag name="sylius.gateway_configuration_type" type="mollie" label="sylius_mollie_plugin.ui.mollie_gateway_label"/>
<tag name="form.type"/>
Expand Down Expand Up @@ -134,12 +133,6 @@
<tag name="form.type" />
</service>

<service id="sylius_mollie.form.type.payment_type_choice" class="Sylius\MolliePlugin\Form\Type\PaymentTypeChoiceType">
<argument type="service" id="sylius_mollie.documentation.documentation_links" />

<tag name="form.type" />
</service>

<service id="sylius_mollie.form.type.payment_surcharge_type_choice" class="Sylius\MolliePlugin\Form\Type\PaymentSurchargeFeeTypeChoiceType">
<tag name="form.type" />
</service>
Expand Down
78 changes: 0 additions & 78 deletions src/Documentation/DocumentationLinks.php

This file was deleted.

25 changes: 0 additions & 25 deletions src/Documentation/DocumentationLinksInterface.php

This file was deleted.

8 changes: 2 additions & 6 deletions src/Form/Type/MollieGatewayConfigurationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace Sylius\MolliePlugin\Form\Type;

use Sylius\MolliePlugin\Client\MollieApiClient;
use Sylius\MolliePlugin\Documentation\DocumentationLinksInterface;
use Sylius\MolliePlugin\Validator\Constraints\LiveApiKeyIsNotBlank;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
Expand All @@ -34,7 +33,7 @@ final class MollieGatewayConfigurationType extends AbstractType

public const API_KEY_TEST = 'api_key_test';

public function __construct(private readonly DocumentationLinksInterface $documentationLinks, private readonly MollieApiClient $apiClient)
public function __construct(private readonly MollieApiClient $apiClient)
{
}

Expand All @@ -52,8 +51,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
])
->add(self::API_KEY_TEST, PasswordType::class, [
'always_empty' => false,
'label' => $this->documentationLinks->getApiKeyDoc(),
'help' => ' ',
'label' => 'sylius_mollie_plugin.ui.api_key_test',
'constraints' => [
new NotBlank([
'message' => 'sylius_mollie_plugin.api_key.not_blank',
Expand Down Expand Up @@ -105,13 +103,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('components', CheckboxType::class, [
'label' => 'sylius_mollie_plugin.ui.enable_components',
'attr' => ['class' => 'mollie-components'],
'help' => $this->documentationLinks->getMollieComponentsDoc(),
'help_html' => true,
])
->add('single_click_enabled', CheckboxType::class, [
'label' => 'sylius_mollie_plugin.ui.single_click_enabled',
'attr' => ['class' => 'mollie-single-click-payment'],
'help' => $this->documentationLinks->getSingleClickDoc(),
'help_html' => true,
])
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {
Expand Down
8 changes: 1 addition & 7 deletions src/Form/Type/PaymentTypeChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,19 @@

namespace Sylius\MolliePlugin\Form\Type;

use Sylius\MolliePlugin\Documentation\DocumentationLinksInterface;
use Sylius\MolliePlugin\Payments\PaymentType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;

final class PaymentTypeChoiceType extends AbstractType
{
public function __construct(
private readonly DocumentationLinksInterface $documentationLinks,
) {
}

public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'label' => 'sylius_mollie_plugin.ui.payment_type',
'choices' => PaymentType::getAllAvailable(),
'help' => $this->documentationLinks->getPaymentMethodDoc(),
'help' => 'sylius_mollie_plugin.help.payment_methods_doc',
'help_html' => true,
]);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{% import '@SyliusAdmin/PaymentMethod/_documentation_helpers.html.twig' as doc %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% import '@SyliusAdmin/PaymentMethod/_documentation_helpers.html.twig' as doc %}
{% import '@SyliusMolliePlugin/Admin/PaymentMethod/_documentation_helpers.html.twig' as doc %}

Custom templates should live in the app

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exaple
Maybe we should move it to a new PR, since there are many more like this here—it might be better to handle all of them at once. What do you think?


<div class="field">
<label for="sylius_payment_method_gatewayConfig_config_{{ field.vars.name }}" class="required">
{{ field.vars.label|trans|raw|nl2br }}
</label>
<div class="ui input">
{{ form_widget(field) }}
<button id="{{ field.vars.name }}" type="button" class="ui button primary">{{ 'sylius_mollie_plugin.ui.show_hide'|trans }}</button>
<button id="{{ field.vars.name }}" type="button" class="ui button primary">
{{ 'sylius_mollie_plugin.ui.show_hide'|trans }}
</button>
</div>

<div class="ui pointing label">
{{ doc.documentation_help('api_key_live') }}
</div>
{{ form_help(field) }}

{{ form_errors(field) }}
</div>

Expand All @@ -19,4 +27,5 @@
{{ 'sylius_mollie_plugin.ui.test_api_keys'|trans }}
</button>
</div>

<div class="ui test-api-key-div"></div>
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
{% import '@SyliusAdmin/PaymentMethod/_documentation_helpers.html.twig' as doc %}

<div class="required field">
<label for="sylius_payment_method_gatewayConfig_config_{{ field.vars.name }}" class="required">
{{ field.vars.label|trans|raw|nl2br }}
</label>
<div class="ui input js-onboardingWizard-apiKey">
{{ form_widget(field) }}
<button id="{{ field.vars.name }}" type="button" class="ui button primary">{{ 'sylius_mollie_plugin.ui.show_hide'|trans }}</button>
<button id="{{ field.vars.name }}" type="button" class="ui button primary">
{{ 'sylius_mollie_plugin.ui.show_hide'|trans }}
</button>
</div>

<div class="ui pointing label">
{{ doc.documentation_help('api_key_test') }}
</div>

{{ form_errors(field) }}
</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if adding this macro makes sense, as these keys are used once 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just create form_theme for each field and set the links in there?
Then we don't have to if into oblivion, but have a block per case

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% macro documentation_help(key) %}
{% set links = {
'single_click': 'https://help.mollie.com/hc/en-us/articles/115000671249-What-are-single-click-payments-and-how-does-it-work-',
'mollie_components': 'https://www.mollie.com/en/news/post/better-checkout-flows-with-mollie-components',
'payment_methods': 'https://docs.mollie.com/orders/why-use-orders',
'api_key': 'https://www.mollie.com/dashboard/developers/api-keys'
} %}

{% if key == 'single_click' %}
{{ 'sylius_mollie_plugin.ui.read_more_single_click_enabled'|trans({
'%link%': '<a target="_blank" href="' ~ links.single_click ~ '">' ~ 'sylius_mollie_plugin.ui.mollie_single_click'|trans ~ '</a>'
})|raw }}

{% elseif key == 'mollie_components' %}
{{ 'sylius_mollie_plugin.ui.read_more_enable_components'|trans({
'%link%': '<a target="_blank" href="' ~ links.mollie_components ~ '">' ~ 'sylius_mollie_plugin.ui.mollie_components'|trans ~ '</a>'
})|raw }}

{% elseif key == 'api_key_live' %}
{{ 'sylius_mollie_plugin.ui.read_more_live_api_key'|trans({
'%link%': '<a target="_blank" href="' ~ links.api_key ~ '">' ~ 'sylius_mollie_plugin.ui.mollie_profile'|trans ~ '</a>'
})|raw }}

{% elseif key == 'api_key_test' %}
{{ 'sylius_mollie_plugin.ui.read_more_test_api_key'|trans({
'%link%': '<a target="_blank" href="' ~ links.api_key ~ '">' ~ 'sylius_mollie_plugin.ui.mollie_profile'|trans ~ '</a>'
})|raw }}

{% endif %}
{% endmacro %}
Loading