style: fix indentation, alignment, and docblock annotations

- Correct getChoices() docblock to reflect translated label => enum
  backing value order instead of value => label
- Re-indent Smart Links menu config to match actual array nesting
- Align assignment operators in RefreshStatsCommand
- Add missing newline at end of RefreshStatsCommand.php
This commit is contained in:
Alexandre Gain committed 2026-11-21 11:23:33 +01:00
1 parent 07773acb8d
commit b138056e43
90 files changed
+622 -272

No files matched your search

-2
View File
@@ -14,8 +14,6 @@ use Symfony\Component\Form\FormBuilderInterface;
* the Email form (EmailType) and the Focus Item form (FocusType), so this covers both.
*
* Registered as `form.type_extension` by autoconfiguration (Config/services.php).
*
* @extends AbstractTypeExtension<mixed>
*/
final class UtmTagsTypeExtension extends AbstractTypeExtension
{
+2 -4
View File
@@ -28,8 +28,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
* fixed type (persona, ICP, …), the segments (purely informational), then the persona attributes
* the admin switched on in Settings > Configuration > Program Settings (AudienceAttributes): one
* toggle per attribute, so a b2b install and a b2c install define their personas differently.
*
* @extends AbstractType<Audience>
*/
class AudienceType extends AbstractType
{
@@ -167,7 +165,7 @@ class AudienceType extends AbstractType
if (in_array('stages', $enabled, true)) {
$builder->add('stages', EntityType::class, [
'label' => 'mt3s.marketing_program.audience.field.stages',
'label' => 'mt3s.marketing_program.audience.field.stages',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Stage::class,
@@ -210,4 +208,4 @@ class AudienceType extends AbstractType
{
return 'mt3s_marketing_program_audience';
}
}
}
+2 -4
View File
@@ -4,13 +4,13 @@ declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel;
use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
use MauticPlugin\MT3SMarketingProgramBundle\Service\AudienceAttributes;
use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
@@ -24,8 +24,6 @@ use Symfony\Component\Validator\Constraints\NotBlank;
*
* The item type lists moved to their own page under Programs (ItemTypesController, Programs >
* Item types).
*
* @extends AbstractType<array<string, mixed>>
*/
class ConfigType extends AbstractType
{
-2
View File
@@ -25,8 +25,6 @@ use Symfony\Component\Validator\Constraints\NotBlank;
*
* The key is hidden. It is generated when the type is created and never changes, so that renaming a
* type doesn't affect the items that use it.
*
* @extends AbstractType<array<string, mixed>>
*/
class ItemTypeConfigType extends AbstractType
{
+7 -9
View File
@@ -17,8 +17,6 @@ use Symfony\Component\Form\FormBuilderInterface;
* an audience's decision roles and tones. Each child is one of ItemTypeProvider::PARAMETERS,
* keyed exactly by the local.php parameter that stores the list, so saving is a straight merge
* into the local configuration.
*
* @extends AbstractType<array<string, mixed>>
*/
class ItemTypesType extends AbstractType
{
@@ -29,15 +27,15 @@ class ItemTypesType extends AbstractType
$withIcon = !in_array($kind, [ItemTypeProvider::KIND_AUDIENCE_DECISION_ROLE, ItemTypeProvider::KIND_AUDIENCE_TONE], true);
$builder->add($parameter, CollectionType::class, [
'label' => false,
'entry_type' => ItemTypeConfigType::class,
'entry_options' => ['label' => false, 'with_icon' => $withIcon],
'label' => false,
'entry_type' => ItemTypeConfigType::class,
'entry_options' => ['label' => false, 'with_icon' => $withIcon],
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
'prototype_name' => '__type__',
'required' => false,
'error_bubbling' => false,
'prototype_name' => '__type__',
'required' => false,
'error_bubbling' => false,
]);
// Stored as a clean list (0..n-1, empty texts dropped), in the order shown on the page.
@@ -55,4 +53,4 @@ class ItemTypesType extends AbstractType
// The POST data keys: mt3s_marketing_program_item_types[<parameter>][<index>][…].
return 'mt3s_marketing_program_item_types';
}
}
}
-2
View File
@@ -21,8 +21,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
* real cost (both in the general currency). Works like ProgramDescriptionItemType (type description shown
* under the dropdown and its pictogram next to it, hidden position kept in display order by
* Assets/js/mt3s-mp-program.js).
*
* @extends AbstractType<ProgramAllocationItem>
*/
class ProgramAllocationItemType extends AbstractType
{
+1 -3
View File
@@ -20,8 +20,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
* One row of the audiences collection in ProgramType: an audience of the global directory (only the
* active ones are offered), the audience's priority in this plan, and possibly a program-specific
* message. The position field is hidden and kept in display order by Assets/js/mt3s-mp-program.js.
*
* @extends AbstractType<ProgramAudience>
*/
class ProgramAudienceType extends AbstractType
{
@@ -73,4 +71,4 @@ class ProgramAudienceType extends AbstractType
{
return 'mt3s_marketing_program_program_audience';
}
}
}
-2
View File
@@ -18,8 +18,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
* types set up in Settings > Configuration > Program; each option carries the type's description, which
* Assets/js/mt3s-mp-program.js shows under the dropdown. The position field is hidden and kept in display order by
* mt3s-mp-program.js.
*
* @extends AbstractType<ProgramDescriptionItem>
*/
class ProgramDescriptionItemType extends AbstractType
{
+1 -3
View File
@@ -20,8 +20,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
* One row of the objectives collection in ProgramType: type, title, priority, description and the achieved
* flag. Works like ProgramDescriptionItemType (type description shown under the dropdown and its pictogram
* next to it, hidden position kept in display order by Assets/js/mt3s-mp-program.js).
*
* @extends AbstractType<ProgramObjective>
*/
class ProgramObjectiveType extends AbstractType
{
@@ -58,7 +56,7 @@ class ProgramObjectiveType extends AbstractType
'label' => 'mt3s.marketing_program.objective.field.priority',
'label_attr' => ['class' => 'control-label'],
'invalid_message' => 'mt3s.marketing_program.objective.priority.range',
'attr' => [
'attr' => [
'class' => 'form-control',
'min' => ProgramObjective::PRIORITY_MIN,
'max' => ProgramObjective::PRIORITY_MAX,
-2
View File
@@ -18,8 +18,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
* One row of the stakeholders collection in ProgramType: a stakeholder of the global directory (only the
* active ones are offered) and the stakeholder's role in this plan. The position field is hidden and
* kept in display order by Assets/js/mt3s-mp-program.js.
*
* @extends AbstractType<ProgramStakeholder>
*/
class ProgramStakeholderType extends AbstractType
{
+9 -14
View File
@@ -16,8 +16,6 @@ use Mautic\UserBundle\Form\Type\UserListType;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramStatus;
use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\ProgramAudienceType;
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\ProgramStakeholderType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
@@ -27,9 +25,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @extends AbstractType<Program>
*/
class ProgramType extends AbstractType
{
public function __construct(
@@ -81,15 +76,15 @@ class ProgramType extends AbstractType
// The Audiences tab's links to the global directory. by_reference false: Symfony calls
// Program::addAudience()/removeAudience().
$builder->add('audiences', CollectionType::class, [
'label' => 'mt3s.marketing_program.field.audiences',
'entry_type' => ProgramAudienceType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
'label' => 'mt3s.marketing_program.field.audiences',
'entry_type' => ProgramAudienceType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'prototype' => true,
'prototype_name' => '__audience__',
'required' => false,
'prototype' => true,
'prototype_name' => '__audience__',
'required' => false,
]);
// The Stakeholders tab's links to the global directory. by_reference false: Symfony calls
@@ -110,7 +105,7 @@ class ProgramType extends AbstractType
'label' => 'mt3s.marketing_program.field.version',
'label_attr' => ['class' => 'control-label'],
'invalid_message' => 'mt3s.marketing_program.version.range',
'attr' => [
'attr' => [
'class' => 'form-control',
'min' => Program::VERSION_MIN,
'max' => Program::VERSION_MAX,
+6 -9
View File
@@ -48,8 +48,6 @@ use Symfony\Contracts\Translation\TranslatorInterface;
* data-show-on switcher shows the fieldset of the chosen taxonomy; the values posted for
* the others are dropped on submit. A stored value outside the list stays selectable,
* labelled "(not in taxonomy)", so an old link is still editable.
*
* @extends AbstractType<SmartLink>
*/
final class SmartLinkType extends AbstractType
{
@@ -183,7 +181,6 @@ final class SmartLinkType extends AbstractType
$this->buildTaxonomyFieldOptions($taxonomy, $key, $smartLink)
);
}
}
// The stored values (parameter key => value) feed the fieldset children
@@ -506,20 +503,20 @@ final class SmartLinkType extends AbstractType
private function buildMauticDestinationChoices(SmartLink $smartLink): array
{
$choices = [];
$values = [];
$values = [];
$pages = $this->getPageRepository()->findBy(['isPublished' => true], ['title' => 'ASC']);
foreach ($pages as $page) {
$value = 'page:'.$page->getId();
$value = 'page:'.$page->getId();
$choices['mt3s.smart_links.smart_links.destination.pages'][$page->getTitle()] = $value;
$values[] = $value;
$values[] = $value;
}
$forms = $this->getFormRepository()->findBy(['isPublished' => true], ['name' => 'ASC']);
foreach ($forms as $form) {
$value = 'form:'.$form->getId();
$value = 'form:'.$form->getId();
$choices['mt3s.smart_links.smart_links.destination.forms'][$form->getName()] = $value;
$values[] = $value;
$values[] = $value;
}
// A stored destination that is no longer published stays selectable, so an old link
@@ -528,7 +525,7 @@ final class SmartLinkType extends AbstractType
// back to index-based values for every option.
$current = $this->currentMauticDestination($smartLink);
if (null !== $current && !in_array($current, $values, true)) {
$label = $smartLink->getPage()?->getTitle() ?? $smartLink->getForm()?->getName() ?? '';
$label = $smartLink->getPage()?->getTitle() ?? $smartLink->getForm()?->getName() ?? '';
$choices['mt3s.smart_links.smart_links.destination.unpublished'][$label] = $current;
}
+1 -3
View File
@@ -14,8 +14,6 @@ use Symfony\Component\Form\FormBuilderInterface;
* The single "Smart Links Settings" tab of Settings > Configuration: the general UTM rules and
* the short link domain (section "UTM Settings"), the catalog and custom parameters (section
* "Parameters"). Each child is a local.php parameter.
*
* @extends AbstractType<array<string, mixed>>
*/
final class SmartLinksConfigType extends AbstractType
{
@@ -50,4 +48,4 @@ final class SmartLinksConfigType extends AbstractType
// The Configuration tab title key: mautic.config.tab.smartlinksconfig.
return 'smartlinksconfig';
}
}
}
-2
View File
@@ -17,8 +17,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* The `mt3s_smart_links_utm_config` parameter: general settings, catalog parameters and custom parameters.
*
* @extends AbstractType<array<string, mixed>>
*/
final class SmartlinksSettingsType extends AbstractType
{
+2 -4
View File
@@ -4,10 +4,10 @@ declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Stakeholder;
use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
use Mautic\CoreBundle\Form\Type\FormButtonsType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Stakeholder;
use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
@@ -18,8 +18,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* The create and edit form of a stakeholder of the global directory (Programs > Stakeholders).
*
* @extends AbstractType<Stakeholder>
*/
class StakeholderType extends AbstractType
{
-2
View File
@@ -20,8 +20,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
* One row of the dependencies collection in TaskType: the task this one depends on, and the type of
* the relation. Only the tasks of the same program are offered; cycles and self-edges are refused by
* ValidTaskDependency.
*
* @extends AbstractType<TaskDependency>
*/
class TaskDependencyType extends AbstractType
{
-2
View File
@@ -19,8 +19,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the RACI collection in TaskType: a role (R/A/C/I) and the stakeholders carrying it.
* The stakeholders are picked from the program's assigned stakeholders; several may share a role.
*
* @extends AbstractType<TaskRaci>
*/
class TaskRaciType extends AbstractType
{
+1 -3
View File
@@ -30,8 +30,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
* Kind rules: a milestone's end date is enslaved to its start date (the entity's setTaskKind copies
* the start onto the end, and the TaskDates validator keeps it in step); a phase has no status
* field — its state comes from its tasks.
*
* @extends AbstractType<Task>
*/
class TaskType extends AbstractType
{
@@ -45,7 +43,7 @@ class TaskType extends AbstractType
$builder->addEventSubscriber(new CleanFormSubscriber(['description' => 'strict_html']));
/** @var Task $task */
$task = $options['data'];
$task = $options['data'];
$program = $task->getProgram();
$kind = ItemTypeProvider::KIND_TASK;
+3 -5
View File
@@ -29,8 +29,6 @@ use Symfony\Contracts\Translation\TranslatorInterface;
/**
* One parameter row: a catalog entry (option `definition`) or a custom parameter (`definition` = null).
*
* @extends AbstractType<array<string, mixed>>
*/
final class UtmParameterType extends AbstractType
{
@@ -137,15 +135,15 @@ final class UtmParameterType extends AbstractType
$view->vars['utm_custom'] = null === $definition;
$view->vars['utm_key'] = $definition?->key;
$view->vars['utm_group'] = $definition?->group ?? UtmParameterCatalog::GROUP_CUSTOM;
$view->vars['utm_group'] = $definition->group ?? UtmParameterCatalog::GROUP_CUSTOM;
$view->vars['utm_description_key'] = $definition?->getDescriptionKey();
$view->vars['utm_auto_generated'] = $definition?->autoGenerated ?? false;
$view->vars['utm_auto_generated'] = $definition->autoGenerated ?? false;
$view->vars['utm_suggestions'] = array_map(
fn (string $value): array => [
'value' => $value,
'label' => $this->translator->trans(UtmParameterDefinition::getSuggestionLabelKey($value)),
],
$definition?->suggestions ?? []
$definition->suggestions ?? []
);
}
+4 -7
View File
@@ -7,7 +7,6 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Mautic\CoreBundle\Form\Type\FormButtonsType;
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy;
use MauticPlugin\MT3SMarketingProgramBundle\Form\Validator\UtmSettingsValidator;
use MauticPlugin\MT3SMarketingProgramBundle\Form\Validator\UtmTaxonomyValidator;
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider;
use Symfony\Component\Form\AbstractType;
@@ -35,8 +34,6 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
* selection -- nothing can be typed), and a `free` parameter gets its own editable value
* list here (one `value` or `value;Label` per line): a Smart Link using this taxonomy picks
* a value from it instead of typing freely.
*
* @extends AbstractType<UtmTaxonomy>
*/
final class UtmTaxonomyType extends AbstractType
{
@@ -211,7 +208,7 @@ final class UtmTaxonomyType extends AbstractType
* free ones (a `value;Label` line when the label differs from the value).
*
* @param array<string, array<string, string>> $dropdowns
* @param list<string> $frees
* @param list<string> $frees
*
* @return array<string, mixed>
*/
@@ -268,7 +265,7 @@ final class UtmTaxonomyType extends AbstractType
* textarea lines become rows (labels default to the value); empty lists drop the key.
*
* @param array<string, array<string, string>> $dropdowns
* @param list<string> $frees
* @param list<string> $frees
*
* @return array<string, list<array{value: string, label: string}>>
*/
@@ -356,7 +353,7 @@ final class UtmTaxonomyType extends AbstractType
}
/**
* @param FormInterface|FormBuilderInterface $form
* @param FormInterface|FormBuilderInterface $form
* @param list<array{0: string, 1: array<string, string>}> $errors
*/
private function addErrorsOn(object $form, array $errors): void
@@ -365,4 +362,4 @@ final class UtmTaxonomyType extends AbstractType
$form->addError(new FormError($message, null, $parameters));
}
}
}
}
-2
View File
@@ -16,8 +16,6 @@ use Symfony\Component\Validator\Constraints\Regex;
/**
* One allowed value of a `dropdown` parameter.
*
* @extends AbstractType<array<string, mixed>>
*/
final class UtmValueType extends AbstractType
{
+9 -9
View File
@@ -9,8 +9,8 @@ use Mautic\PageBundle\Entity\Page;
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\SmartLinkRedirectType;
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy;
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider;
use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel;
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider;
/**
* Business rules of the Smart Link form. The form type calls these methods from Callback
@@ -18,15 +18,15 @@ use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel;
*/
final class SmartLinkValidator
{
public const ERROR_SLUG_TAKEN = 'mt3s.smart_links.smart_links.error.slug_taken';
public const ERROR_SLUG_REQUIRED = 'mt3s.smart_links.smart_links.error.slug_required';
public const ERROR_SLUG_LENGTH = 'mt3s.smart_links.smart_links.error.slug_length';
public const ERROR_DESTINATION_REQUIRED = 'mt3s.smart_links.smart_links.error.destination_required';
public const ERROR_SLUG_TAKEN = 'mt3s.smart_links.smart_links.error.slug_taken';
public const ERROR_SLUG_REQUIRED = 'mt3s.smart_links.smart_links.error.slug_required';
public const ERROR_SLUG_LENGTH = 'mt3s.smart_links.smart_links.error.slug_length';
public const ERROR_DESTINATION_REQUIRED = 'mt3s.smart_links.smart_links.error.destination_required';
public const ERROR_DESTINATION_REQUIRED_MAUTIC = 'mt3s.smart_links.smart_links.error.destination_required_mautic';
public const ERROR_DESTINATION_INVALID = 'mt3s.smart_links.smart_links.error.destination_invalid';
public const ERROR_UTM_VALUE_INVALID = 'mt3s.smart_links.smart_links.error.utm_value_invalid';
public const ERROR_UTM_VALUE_NOT_ALLOWED = 'mt3s.smart_links.smart_links.error.utm_value_not_allowed';
public const ERROR_TAXONOMY_PARAMETER_UNKNOWN = 'mt3s.smart_links.smart_links.error.taxonomy_parameter_unknown';
public const ERROR_DESTINATION_INVALID = 'mt3s.smart_links.smart_links.error.destination_invalid';
public const ERROR_UTM_VALUE_INVALID = 'mt3s.smart_links.smart_links.error.utm_value_invalid';
public const ERROR_UTM_VALUE_NOT_ALLOWED = 'mt3s.smart_links.smart_links.error.utm_value_not_allowed';
public const ERROR_TAXONOMY_PARAMETER_UNKNOWN = 'mt3s.smart_links.smart_links.error.taxonomy_parameter_unknown';
public function __construct(
private readonly SmartLinkModel $smartLinkModel,
+1 -1
View File
@@ -70,4 +70,4 @@ final class UtmTaxonomyValidator
return $errors;
}
}
}