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
61 files changed
+453 -103

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
# Coding standards of the plugin: the same ruleset Mautic core runs
# (@Symfony + the core tweaks, see .php-cs-fixer.dist.php) and PHPStan level 6
# (see phpstan.neon). `composer install` in the plugin directory pulls
# mautic/core-lib (^7.0) so the analysis sees the real Mautic signatures.
#
# The PHPUnit suite is not run here: it needs a full Mautic installation
# (see Tests/bootstrap.php). Run it from the mautic-dev-env container:
# vendor/bin/phpunit -c docroot/plugins/MT3SMarketingProgramBundle/phpunit.xml.dist
stages:
- lint
.default-before-script: &default-before-script
- composer install --no-interaction --no-progress --prefer-dist
php-cs-fixer:
stage: lint
image: composer:2
before_script: *default-before-script
script:
- composer cs-check
phpstan:
stage: lint
image: composer:2
before_script: *default-before-script
script:
- composer phpstan
+1
View File
@@ -0,0 +1 @@
{"php":"8.3.36","version":"3.95.32:v3.95.32#c12acc751f4039935429057f1fadf0e5f62601c1","indent":" ","lineEnding":"\n","rules":{"align_multiline_comment":true,"backtick_to_shell_exec":true,"binary_operator_spaces":{"operators":{"=>":"align","=":"align"}},"blank_line_before_statement":{"statements":["return"]},"braces_position":{"allow_single_line_anonymous_functions":true,"allow_single_line_empty_anonymous_classes":true},"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":{"single_line":true},"class_reference_name_casing":true,"clean_namespace":true,"concat_space":true,"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_body":{"style":"braces"},"empty_loop_condition":true,"fully_qualified_strict_types":true,"function_declaration":{"closure_fn_spacing":"one"},"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"global_namespace_import":{"import_classes":false,"import_constants":false,"import_functions":false},"include":true,"increment_style":true,"integer_literal_case":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"after_heredoc":true,"on_multiline":"ignore"},"native_function_casing":true,"native_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["attribute","case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_null_property_initialization":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true},"no_trailing_comma_in_singleline":true,"no_unneeded_braces":{"namespaces":true},"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","negative_instanceof","others","return","switch_case","yield","yield_from"]},"no_unneeded_import_alias":true,"no_unset_cast":true,"no_unused_imports":true,"no_useless_concat_operator":true,"no_useless_else":true,"no_useless_nullsafe_operator":true,"no_useless_return":true,"no_whitespace_before_comma_in_array":{"after_heredoc":true},"normalize_index_brace":true,"object_operator_without_whitespace":true,"operator_linebreak":{"only_booleans":true},"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":{"replacements":{"const":"var","link":"see","property-read":"property","property-write":"property","type":"var"}},"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_order":{"order":["param","return","throws"]},"phpdoc_return_self_reference":true,"phpdoc_scalar":{"types":["boolean","callback","double","integer","never-return","never-returns","no-return","real","str"]},"phpdoc_separation":{"groups":[["Annotation","NamedArgumentConstructor","Target"],["author","copyright","license"],["category","package","subpackage"],["property","property-read","property-write"],["deprecated","link","see","since"]],"skip_unlisted_annotations":false},"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_annotation_correct_order":true,"phpdoc_var_without_name":true,"protected_to_private":true,"semicolon_after_instruction":true,"simple_to_complex_string_variable":true,"single_import_per_statement":true,"single_line_comment_spacing":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_space_around_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"statement_indentation":{"stick_comment_to_next_continuous_control_statement":true},"switch_continue_to_break":true,"trailing_comma_in_multiline":{"after_heredoc":true,"elements":["array_destructuring","arrays","match","parameters"]},"trim_array_spaces":true,"type_declaration_spaces":{"elements":["function","property"]},"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"nullable_type_declaration":true,"ordered_types":{"null_adjustment":"always_last","sort_algorithm":"none"},"single_class_element_per_statement":true,"types_spaces":true,"array_indentation":true,"array_syntax":{"syntax":"short"},"attribute_block_no_spaces":true,"cast_spaces":true,"new_with_parentheses":{"anonymouLine truncated
+72
View File
@@ -0,0 +1,72 @@
<?php
declare(strict_types=1);
/*
* PHP-CS-Fixer configuration of the plugin: the same ruleset Mautic core runs
* (see its .php-cs-fixer.php), minus the custom fixer of the mautic/coding-standards
* package, which a standalone plugin repository cannot require.
*
* Check the coding style (CI runs this with --dry-run --diff):
*
* vendor/bin/php-cs-fixer fix --dry-run --diff --config=.php-cs-fixer.dist.php
*
* Fix in place:
*
* vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php
*/
$finder = (new PhpCsFixer\Finder())
->in([
__DIR__.'/Catalog',
__DIR__.'/Command',
__DIR__.'/Config',
__DIR__.'/Controller',
__DIR__.'/DependencyInjection',
__DIR__.'/Entity',
__DIR__.'/Event',
__DIR__.'/EventListener',
__DIR__.'/Form',
__DIR__.'/Integration',
__DIR__.'/Migrations',
__DIR__.'/Model',
__DIR__.'/Security',
__DIR__.'/Service',
__DIR__.'/Tests',
__DIR__.'/Twig',
__DIR__.'/Validator',
])
->append([
__DIR__.'/MT3SMarketingProgramBundle.php',
]);
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'binary_operator_spaces' => [
'operators' => [
'=>' => 'align',
'=' => 'align',
],
],
'phpdoc_to_comment' => false,
'ordered_imports' => true,
'array_syntax' => [
'syntax' => 'short',
],
'no_unused_imports' => true,
/**
* The plugin's templates use the alternative syntax (endforeach, endif, ...)
* that Mautic's Twig templates rely on, so the rule stays off like in core.
*/
'no_alternative_syntax' => false,
'header_comment' => [
'header' => '',
],
'multiline_whitespace_before_semicolons' => true,
'nullable_type_declaration_for_default_null_value' => false, // Enforces potential BC breaks.
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
],
])
->setFinder($finder);
+3 -1
View File
@@ -13,7 +13,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
trait SmartLinkRedirectEnumHelper trait SmartLinkRedirectEnumHelper
{ {
/** /**
* @return array<int|string, string> value (as string) => label * The choices of the form's redirect dropdowns and the list views: translated label => backing value.
*
* @return array<string, int|string> translated label => backing value of the enum case
*/ */
public static function getChoices(TranslatorInterface $translator): array public static function getChoices(TranslatorInterface $translator): array
{ {
+1 -1
View File
@@ -80,7 +80,7 @@ class ProgramController extends AbstractStandardFormController
} }
if (!$this->checkActionPermission('view', $program)) { if (!$this->checkActionPermission('view', $program)) {
return $this->accessDenied(); $this->throwAccessDenied();
} }
$base = $this->getPermissionBase(); $base = $this->getPermissionBase();
+32 -9
View File
@@ -4,13 +4,21 @@ declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Controller; namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
use Doctrine\Persistence\ManagerRegistry;
use Mautic\CoreBundle\Controller\CommonController; use Mautic\CoreBundle\Controller\CommonController;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink; use Mautic\CoreBundle\Factory\ModelFactory;
use Mautic\CoreBundle\Helper\CoreParametersHelper;
use Mautic\CoreBundle\Helper\UserHelper;
use Mautic\CoreBundle\Security\Permissions\CorePermissions;
use Mautic\CoreBundle\Service\FlashBag;
use Mautic\CoreBundle\Translation\Translator;
use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel; use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\Service\Attribute\Required;
/** /**
* The public side of the Smart Links: https://{short_link_domain}/l/{slug}. * The public side of the Smart Links: https://{short_link_domain}/l/{slug}.
@@ -24,12 +32,20 @@ use Symfony\Contracts\Service\Attribute\Required;
*/ */
class PublicController extends CommonController class PublicController extends CommonController
{ {
private SmartLinkModel $smartLinkModel; public function __construct(
private readonly SmartLinkModel $smartLinkModel,
#[Required] private readonly LoggerInterface $logger,
public function autowirePublicController(SmartLinkModel $smartLinkModel): void ManagerRegistry $doctrine,
{ ModelFactory $modelFactory,
$this->smartLinkModel = $smartLinkModel; UserHelper $userHelper,
CoreParametersHelper $coreParametersHelper,
EventDispatcherInterface $dispatcher,
Translator $translator,
FlashBag $flashBag,
RequestStack $requestStack,
CorePermissions $security,
) {
parent::__construct($doctrine, $modelFactory, $userHelper, $coreParametersHelper, $dispatcher, $translator, $flashBag, $requestStack, $security);
} }
public function goAction(Request $request, string $slug): Response public function goAction(Request $request, string $slug): Response
@@ -64,7 +80,14 @@ class PublicController extends CommonController
$this->smartLinkModel->recordHit($link, $request); $this->smartLinkModel->recordHit($link, $request);
} catch (\Throwable $e) { } catch (\Throwable $e) {
// Statistics must never block the redirect. // Statistics must never block the redirect.
error_log('Smart Link hit could not be recorded for slug "'.$slug.'": '.$e->getMessage().' in '.$e->getFile().':'.$e->getLine()); $this->logger->error(
'Smart Link hit could not be recorded for slug "{slug}": {message}',
[
'slug' => $slug,
'message' => $e->getMessage(),
'exception' => $e,
]
);
} }
return new RedirectResponse($this->smartLinkModel->buildRedirectUrl($link), $link->getRedirectCode()->value); return new RedirectResponse($this->smartLinkModel->buildRedirectUrl($link), $link->getRedirectCode()->value);
+12 -2
View File
@@ -103,13 +103,18 @@ class SmartLinkController extends AbstractStandardFormController
/** /**
* Never save the slug of an existing link: it is immutable once created. The field is * Never save the slug of an existing link: it is immutable once created. The field is
* disabled in the form, so nothing is submitted for it, this is a safety net. * disabled in the form, so nothing is submitted for it, this is a safety net.
*
* @param SmartLink $entity
* @param string $action
* @param int|null $objectId
* @param bool $isClone
*/ */
protected function beforeEntitySave($entity, Form $form, $action, $objectId = null, $isClone = false): bool protected function beforeEntitySave($entity, Form $form, $action, $objectId = null, $isClone = false): bool
{ {
if ($entity instanceof SmartLink && null !== $entity->getId()) { if ($entity instanceof SmartLink && null !== $entity->getId()) {
$formSlug = $form->has('slug') ? (string) $form->get('slug')->getData() : ''; $formSlug = $form->has('slug') ? (string) $form->get('slug')->getData() : '';
if ('' !== $formSlug && $formSlug !== (string) $entity->getSlug()) { if ('' !== $formSlug && $formSlug !== (string) $entity->getSlug()) {
$this->addFlashMessage('mt3s.smart_links.smart_links.error.slug_immutable', ['%slug%' => $formSlug], \Mautic\CoreBundle\FlashBag::LEVEL_ERROR); $this->addFlashMessage('mt3s.smart_links.smart_links.error.slug_immutable', ['%slug%' => $formSlug], \Mautic\CoreBundle\Service\FlashBag::LEVEL_ERROR);
return false; return false;
} }
@@ -123,6 +128,7 @@ class SmartLinkController extends AbstractStandardFormController
* also displayed above the form of a link), and the number of hits of each link. * also displayed above the form of a link), and the number of hits of each link.
* *
* @param array<string, mixed> $args * @param array<string, mixed> $args
* @param string $action
* *
* @return array<string, mixed> * @return array<string, mixed>
*/ */
@@ -151,6 +157,8 @@ class SmartLinkController extends AbstractStandardFormController
/** /**
* Smart Links don't have a detail page; after Save or Cancel go back to the list. * Smart Links don't have a detail page; after Save or Cancel go back to the list.
*
* @param string $action
*/ */
protected function getPostActionControllerAction($action): string protected function getPostActionControllerAction($action): string
{ {
@@ -159,9 +167,11 @@ class SmartLinkController extends AbstractStandardFormController
/** /**
* A saved Smart Link is never cloned: its slug is immutable, and a clone would need a new one. * A saved Smart Link is never cloned: its slug is immutable, and a clone would need a new one.
*
* @param int|null $objectId
*/ */
public function cloneAction(Request $request, $objectId): Response public function cloneAction(Request $request, $objectId): Response
{ {
$this->accessDenied(); $this->throwAccessDenied();
} }
} }
+12
View File
@@ -137,6 +137,10 @@ class TaskController extends AbstractStandardFormController
} }
/** /**
* @param string $action
* @param int|null $objectId
* @param bool $isClone
*
* @return object|null * @return object|null
*/ */
protected function getFormEntity($action, &$objectId = null, &$isClone = false) protected function getFormEntity($action, &$objectId = null, &$isClone = false)
@@ -153,6 +157,13 @@ class TaskController extends AbstractStandardFormController
return $entity; return $entity;
} }
/**
* @param Task $entity
* @param string $action
* @param mixed $pass
*
* @return mixed
*/
protected function afterEntitySave($entity, Form $form, $action, $pass = null) protected function afterEntitySave($entity, Form $form, $action, $pass = null)
{ {
if ($entity instanceof Task) { if ($entity instanceof Task) {
@@ -167,6 +178,7 @@ class TaskController extends AbstractStandardFormController
* was moved to another program, go to its new program. Otherwise keep core's default: the task list. * was moved to another program, go to its new program. Otherwise keep core's default: the task list.
* *
* @param array<string, mixed> $args * @param array<string, mixed> $args
* @param string $action
* *
* @return array<string, mixed> * @return array<string, mixed>
*/ */
+5 -1
View File
@@ -97,6 +97,8 @@ class UtmTaxonomyController extends AbstractStandardFormController
/** /**
* Taxonomies don't have a detail page; after Save or Cancel go back to the list. * Taxonomies don't have a detail page; after Save or Cancel go back to the list.
*
* @param string $action
*/ */
protected function getPostActionControllerAction($action): string protected function getPostActionControllerAction($action): string
{ {
@@ -113,9 +115,11 @@ class UtmTaxonomyController extends AbstractStandardFormController
/** /**
* A saved taxonomy is never cloned: its name is unique, and a clone would collide on save. * A saved taxonomy is never cloned: its name is unique, and a clone would collide on save.
*
* @param int|null $objectId
*/ */
public function cloneAction(Request $request, $objectId): Response public function cloneAction(Request $request, $objectId): Response
{ {
$this->accessDenied(); $this->throwAccessDenied();
} }
} }
+5 -3
View File
@@ -163,8 +163,10 @@ class Program extends FormEntity implements DateRangeInterface
->setCustomRepositoryClass(ProgramRepository::class) ->setCustomRepositoryClass(ProgramRepository::class)
->addIndex(['status'], 'program_status'); ->addIndex(['status'], 'program_status');
// id and name; no description column (replaced by description items). // id and name; no description column (replaced by description items). The false is
$builder->addIdColumns('name', false); // core's own way to skip the column (addIdColumns checks it for truthiness); core's
// @param string docblock just doesn't mention it.
$builder->addIdColumns('name', false); // @phpstan-ignore argument.type (false is core's own way to skip the column; its @param string docblock doesn't mention it)
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191). // Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191).
$metadata->mapField([ $metadata->mapField([
@@ -468,7 +470,7 @@ class Program extends FormEntity implements DateRangeInterface
} }
/** /**
* @template T of ProgramObjective|ProgramDescriptionItem|ProgramAllocationItem|Audience|ProgramStakeholder * @template T of ProgramObjective|ProgramDescriptionItem|ProgramAllocationItem|ProgramAudience|ProgramStakeholder
* *
* @param Collection<int, T> $collection * @param Collection<int, T> $collection
* *
+4
View File
@@ -71,10 +71,13 @@ class SmartLinkRepository extends CommonRepository
$this->getTableAlias().'.destinationUrl', $this->getTableAlias().'.destinationUrl',
]); ]);
} }
/** /**
* The Hits column of the list sorts by the number of hits of each link: the virtual * The Hits column of the list sorts by the number of hits of each link: the virtual
* "hitCount" order by maps to the HIDDEN hitCount scalar of the list query. Everything * "hitCount" order by maps to the HIDDEN hitCount scalar of the list query. Everything
* else falls back to core's column handling. * else falls back to core's column handling.
*
* @param array<string, mixed> $args
*/ */
protected function buildOrderByClause($q, array $args): void protected function buildOrderByClause($q, array $args): void
{ {
@@ -92,6 +95,7 @@ class SmartLinkRepository extends CommonRepository
parent::buildOrderByClause($q, $args); parent::buildOrderByClause($q, $args);
} }
/** /**
* @return array<array{0: string, 1: string}> * @return array<array{0: string, 1: string}>
*/ */
+3 -2
View File
@@ -19,9 +19,10 @@ class StakeholderRepository extends CommonRepository
} }
/** /**
* The list's search box matches the name, email, role and type. * The list's search box matches the name, email, role and type. Core passes the filter
* as an object with ->string and ->strict (its own docblock), not an array.
* *
* @param array<int, mixed> $filter * @param \stdClass $filter
* *
* @return array<int, mixed> * @return array<int, mixed>
*/ */
+1 -1
View File
@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder; use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
-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. * the Email form (EmailType) and the Focus Item form (FocusType), so this covers both.
* *
* Registered as `form.type_extension` by autoconfiguration (Config/services.php). * Registered as `form.type_extension` by autoconfiguration (Config/services.php).
*
* @extends AbstractTypeExtension<mixed>
*/ */
final class UtmTagsTypeExtension extends AbstractTypeExtension final class UtmTagsTypeExtension extends AbstractTypeExtension
{ {
-2
View File
@@ -28,8 +28,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
* fixed type (persona, ICP, …), the segments (purely informational), then the persona attributes * fixed type (persona, ICP, …), the segments (purely informational), then the persona attributes
* the admin switched on in Settings > Configuration > Program Settings (AudienceAttributes): one * 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. * toggle per attribute, so a b2b install and a b2c install define their personas differently.
*
* @extends AbstractType<Audience>
*/ */
class AudienceType extends AbstractType class AudienceType extends AbstractType
{ {
+2 -4
View File
@@ -4,13 +4,13 @@ declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel; use MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel;
use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
use MauticPlugin\MT3SMarketingProgramBundle\Service\AudienceAttributes; use MauticPlugin\MT3SMarketingProgramBundle\Service\AudienceAttributes;
use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank; 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 > * The item type lists moved to their own page under Programs (ItemTypesController, Programs >
* Item types). * Item types).
*
* @extends AbstractType<array<string, mixed>>
*/ */
class ConfigType extends AbstractType 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 * 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. * type doesn't affect the items that use it.
*
* @extends AbstractType<array<string, mixed>>
*/ */
class ItemTypeConfigType extends AbstractType class ItemTypeConfigType extends AbstractType
{ {
-2
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, * 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 * keyed exactly by the local.php parameter that stores the list, so saving is a straight merge
* into the local configuration. * into the local configuration.
*
* @extends AbstractType<array<string, mixed>>
*/ */
class ItemTypesType extends AbstractType class ItemTypesType extends AbstractType
{ {
-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 * 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 * under the dropdown and its pictogram next to it, hidden position kept in display order by
* Assets/js/mt3s-mp-program.js). * Assets/js/mt3s-mp-program.js).
*
* @extends AbstractType<ProgramAllocationItem>
*/ */
class ProgramAllocationItemType extends AbstractType class ProgramAllocationItemType extends AbstractType
{ {
-2
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 * 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 * 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. * 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 class ProgramAudienceType extends AbstractType
{ {
-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 * 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 * 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. * mt3s-mp-program.js.
*
* @extends AbstractType<ProgramDescriptionItem>
*/ */
class ProgramDescriptionItemType extends AbstractType class ProgramDescriptionItemType extends AbstractType
{ {
-2
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 * 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 * 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). * next to it, hidden position kept in display order by Assets/js/mt3s-mp-program.js).
*
* @extends AbstractType<ProgramObjective>
*/ */
class ProgramObjectiveType extends AbstractType class ProgramObjectiveType extends AbstractType
{ {
-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 * 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 * 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. * kept in display order by Assets/js/mt3s-mp-program.js.
*
* @extends AbstractType<ProgramStakeholder>
*/ */
class ProgramStakeholderType extends AbstractType class ProgramStakeholderType extends AbstractType
{ {
-5
View File
@@ -16,8 +16,6 @@ use Mautic\UserBundle\Form\Type\UserListType;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramStatus; use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramStatus;
use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider; 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\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\EnumType; 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\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @extends AbstractType<Program>
*/
class ProgramType extends AbstractType class ProgramType extends AbstractType
{ {
public function __construct( public function __construct(
-3
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 * 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, * 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. * labelled "(not in taxonomy)", so an old link is still editable.
*
* @extends AbstractType<SmartLink>
*/ */
final class SmartLinkType extends AbstractType final class SmartLinkType extends AbstractType
{ {
@@ -183,7 +181,6 @@ final class SmartLinkType extends AbstractType
$this->buildTaxonomyFieldOptions($taxonomy, $key, $smartLink) $this->buildTaxonomyFieldOptions($taxonomy, $key, $smartLink)
); );
} }
} }
// The stored values (parameter key => value) feed the fieldset children // The stored values (parameter key => value) feed the fieldset children
-2
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 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 * the short link domain (section "UTM Settings"), the catalog and custom parameters (section
* "Parameters"). Each child is a local.php parameter. * "Parameters"). Each child is a local.php parameter.
*
* @extends AbstractType<array<string, mixed>>
*/ */
final class SmartLinksConfigType extends AbstractType final class SmartLinksConfigType extends AbstractType
{ {
-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. * The `mt3s_smart_links_utm_config` parameter: general settings, catalog parameters and custom parameters.
*
* @extends AbstractType<array<string, mixed>>
*/ */
final class SmartlinksSettingsType extends AbstractType final class SmartlinksSettingsType extends AbstractType
{ {
+2 -4
View File
@@ -4,10 +4,10 @@ declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type; 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\FormButtonsType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType; 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\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType; 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). * The create and edit form of a stakeholder of the global directory (Programs > Stakeholders).
*
* @extends AbstractType<Stakeholder>
*/ */
class StakeholderType extends AbstractType 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 * 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 * the relation. Only the tasks of the same program are offered; cycles and self-edges are refused by
* ValidTaskDependency. * ValidTaskDependency.
*
* @extends AbstractType<TaskDependency>
*/ */
class TaskDependencyType extends AbstractType 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. * 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. * The stakeholders are picked from the program's assigned stakeholders; several may share a role.
*
* @extends AbstractType<TaskRaci>
*/ */
class TaskRaciType extends AbstractType class TaskRaciType extends AbstractType
{ {
-2
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 * 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 * 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. * field — its state comes from its tasks.
*
* @extends AbstractType<Task>
*/ */
class TaskType extends AbstractType class TaskType extends AbstractType
{ {
+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). * One parameter row: a catalog entry (option `definition`) or a custom parameter (`definition` = null).
*
* @extends AbstractType<array<string, mixed>>
*/ */
final class UtmParameterType extends AbstractType final class UtmParameterType extends AbstractType
{ {
@@ -137,15 +135,15 @@ final class UtmParameterType extends AbstractType
$view->vars['utm_custom'] = null === $definition; $view->vars['utm_custom'] = null === $definition;
$view->vars['utm_key'] = $definition?->key; $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_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( $view->vars['utm_suggestions'] = array_map(
fn (string $value): array => [ fn (string $value): array => [
'value' => $value, 'value' => $value,
'label' => $this->translator->trans(UtmParameterDefinition::getSuggestionLabelKey($value)), 'label' => $this->translator->trans(UtmParameterDefinition::getSuggestionLabelKey($value)),
], ],
$definition?->suggestions ?? [] $definition->suggestions ?? []
); );
} }
-3
View File
@@ -7,7 +7,6 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Mautic\CoreBundle\Form\Type\FormButtonsType; use Mautic\CoreBundle\Form\Type\FormButtonsType;
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode; use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy; use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy;
use MauticPlugin\MT3SMarketingProgramBundle\Form\Validator\UtmSettingsValidator;
use MauticPlugin\MT3SMarketingProgramBundle\Form\Validator\UtmTaxonomyValidator; use MauticPlugin\MT3SMarketingProgramBundle\Form\Validator\UtmTaxonomyValidator;
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider;
use Symfony\Component\Form\AbstractType; 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 * 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 * list here (one `value` or `value;Label` per line): a Smart Link using this taxonomy picks
* a value from it instead of typing freely. * a value from it instead of typing freely.
*
* @extends AbstractType<UtmTaxonomy>
*/ */
final class UtmTaxonomyType extends AbstractType final class UtmTaxonomyType extends AbstractType
{ {
-2
View File
@@ -16,8 +16,6 @@ use Symfony\Component\Validator\Constraints\Regex;
/** /**
* One allowed value of a `dropdown` parameter. * One allowed value of a `dropdown` parameter.
*
* @extends AbstractType<array<string, mixed>>
*/ */
final class UtmValueType extends AbstractType final class UtmValueType extends AbstractType
{ {
+1 -1
View File
@@ -9,8 +9,8 @@ use Mautic\PageBundle\Entity\Page;
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\SmartLinkRedirectType; use MauticPlugin\MT3SMarketingProgramBundle\Catalog\SmartLinkRedirectType;
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode; use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy; use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy;
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider;
use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel; 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 * Business rules of the Smart Link form. The form type calls these methods from Callback
+1
View File
@@ -6,6 +6,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration; use Mautic\IntegrationsBundle\Migration\AbstractMigration;
/** /**
* Since 0.10.0 objectives have a type, the key of an objective type set up in Settings > * Since 0.10.0 objectives have a type, the key of an objective type set up in Settings >
* Configuration > Plan Settings (parameter plan_objective_types). Adds initiative_objectives.type for * Configuration > Plan Settings (parameter plan_objective_types). Adds initiative_objectives.type for
+2 -1
View File
@@ -6,6 +6,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration; use Mautic\IntegrationsBundle\Migration\AbstractMigration;
/** /**
* Since 0.10.1 objectives have a priority, a whole number from 1 (highest) to 99 (lowest). Adds * Since 0.10.1 objectives have a priority, a whole number from 1 (highest) to 99 (lowest). Adds
* initiative_objectives.priority for installs created before 0.10.1: NOT NULL with the default 1, and the * initiative_objectives.priority for installs created before 0.10.1: NOT NULL with the default 1, and the
@@ -29,7 +30,7 @@ class Version_0_10_1 extends AbstractMigration
if (!$table->hasColumn('priority')) { if (!$table->hasColumn('priority')) {
$this->addSql(sprintf( $this->addSql(sprintf(
"ALTER TABLE %s ADD priority INT NOT NULL DEFAULT %d", 'ALTER TABLE %s ADD priority INT NOT NULL DEFAULT %d',
$objectives, $objectives,
1 1
)); ));
+1
View File
@@ -9,6 +9,7 @@ use Doctrine\ORM\Tools\SchemaTool;
use Mautic\IntegrationsBundle\Migration\AbstractMigration; use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceType as AudienceTypeEnum; use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceType as AudienceTypeEnum;
/** /**
* Since 0.11.0 a plan has audiences (table initiative_audiences, initiative_audiences_stages before 0.15.0) with any * Since 0.11.0 a plan has audiences (table initiative_audiences, initiative_audiences_stages before 0.15.0) with any
* number of Mautic stages (join table initiative_audiences_stages). Creates both tables for installs created * number of Mautic stages (join table initiative_audiences_stages). Creates both tables for installs created
+1
View File
@@ -7,6 +7,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration; use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
/** /**
* Since 0.14.0 audiences are a global directory (Planning > Audiences, called Targets before 0.15.0), * Since 0.14.0 audiences are a global directory (Planning > Audiences, called Targets before 0.15.0),
* like stakeholders: * like stakeholders:
+1
View File
@@ -7,6 +7,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration; use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
/** /**
* Historical migration (from 0.15.0, when the bundle was still PlanBundle): it renamed "targets" * Historical migration (from 0.15.0, when the bundle was still PlanBundle): it renamed "targets"
* to "audiences" — plan_targets became plan_audiences (its target_type column audience_type), * to "audiences" — plan_targets became plan_audiences (its target_type column audience_type),
+1
View File
@@ -7,6 +7,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Mautic\IntegrationsBundle\Migration\AbstractMigration; use Mautic\IntegrationsBundle\Migration\AbstractMigration;
/** /**
* Brings the plans table in line with the entity mapping. * Brings the plans table in line with the entity mapping.
* *
+1
View File
@@ -6,6 +6,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration; use Mautic\IntegrationsBundle\Migration\AbstractMigration;
/** /**
* Adds plans.version and the initiative_objectives table to installs created before 0.3.0. * Adds plans.version and the initiative_objectives table to installs created before 0.3.0.
* *
+1 -1
View File
@@ -76,7 +76,7 @@ class Version_0_4_0 extends AbstractMigration
} }
} }
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.'initiative_tasks'.'.'); throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for initiative_tasks.');
} }
/** /**
+2 -1
View File
@@ -7,6 +7,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\SchemaTool;
use Mautic\IntegrationsBundle\Migration\AbstractMigration; use Mautic\IntegrationsBundle\Migration\AbstractMigration;
/** /**
* For installs created before 0.6.0: * For installs created before 0.6.0:
* - creates initiative_description_items (and its foreign key to plans, ON DELETE CASCADE); * - creates initiative_description_items (and its foreign key to plans, ON DELETE CASCADE);
@@ -80,6 +81,6 @@ class Version_0_6_0 extends AbstractMigration
} }
} }
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.'initiative_description_items'.'.'); throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for initiative_description_items.');
} }
} }
+2 -1
View File
@@ -7,6 +7,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\SchemaTool;
use Mautic\IntegrationsBundle\Migration\AbstractMigration; use Mautic\IntegrationsBundle\Migration\AbstractMigration;
/** /**
* Creates initiative_allocation_items (and its foreign key to plans, ON DELETE CASCADE) for installs created * Creates initiative_allocation_items (and its foreign key to plans, ON DELETE CASCADE) for installs created
* before 0.7.0. Each step runs only if needed. As in Version_0_4_0, only the CREATE TABLE statement for * before 0.7.0. Each step runs only if needed. As in Version_0_4_0, only the CREATE TABLE statement for
@@ -71,6 +72,6 @@ class Version_0_7_0 extends AbstractMigration
} }
} }
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.'initiative_allocation_items'.'.'); throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for initiative_allocation_items.');
} }
} }
+1
View File
@@ -6,6 +6,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration; use Mautic\IntegrationsBundle\Migration\AbstractMigration;
/** /**
* Since 0.8.0 every amount is in one general currency (Settings > Configuration > Plan Settings, parameter * Since 0.8.0 every amount is in one general currency (Settings > Configuration > Plan Settings, parameter
* program_currency), so the per-record currency columns are dropped: plans.currency, * program_currency), so the per-record currency columns are dropped: plans.currency,
+1 -1
View File
@@ -129,7 +129,7 @@ class SmartLinkModel extends FormModel
} }
/** /**
* @param array<string, string> $utmParameters * @param array<string, string|null> $utmParameters values may be null (an empty form field); they are dropped
* *
* @return array<string, string> * @return array<string, string>
*/ */
@@ -24,14 +24,14 @@ class MT3SMarketingProgramPermissions extends AbstractPermissions
{ {
parent::__construct($params); parent::__construct($params);
$this->addStandardPermissions('categories'); $this->addStandardPermissions(['categories']);
$this->addExtendedPermissions('programs'); $this->addExtendedPermissions(['programs']);
$this->addExtendedPermissions('tasks'); $this->addExtendedPermissions(['tasks']);
$this->addExtendedPermissions('stakeholders'); $this->addExtendedPermissions(['stakeholders']);
$this->addExtendedPermissions('audiences'); $this->addExtendedPermissions(['audiences']);
$this->addExtendedPermissions('smart_links'); $this->addExtendedPermissions(['smart_links']);
$this->addExtendedPermissions('taxonomies'); $this->addExtendedPermissions(['taxonomies']);
$this->addStandardPermissions('itemtypes'); $this->addStandardPermissions(['itemtypes']);
} }
public function getName(): string public function getName(): string
+1 -1
View File
@@ -65,7 +65,7 @@ final class UtmConfigurationNormalizer
*/ */
private function normalizeParameter(mixed $stored, ?UtmParameterDefinition $definition): array private function normalizeParameter(mixed $stored, ?UtmParameterDefinition $definition): array
{ {
$defaultMode = $definition?->defaultMode ?? UtmParameterMode::DISABLED; $defaultMode = $definition->defaultMode ?? UtmParameterMode::DISABLED;
$allowedModes = $definition?->getAllowedModes() ?? UtmParameterMode::ALL; $allowedModes = $definition?->getAllowedModes() ?? UtmParameterMode::ALL;
if (!is_array($stored)) { if (!is_array($stored)) {
+2 -2
View File
@@ -127,9 +127,9 @@ final class UtmConfigurationProvider
} }
return ['key' => $key] + $parameter + [ return ['key' => $key] + $parameter + [
'group' => $definition?->group ?? UtmParameterCatalog::GROUP_CUSTOM, 'group' => $definition->group ?? UtmParameterCatalog::GROUP_CUSTOM,
'custom' => null === $definition, 'custom' => null === $definition,
'auto_generated' => $definition?->autoGenerated ?? false, 'auto_generated' => $definition->autoGenerated ?? false,
]; ];
} }
} }
@@ -35,6 +35,9 @@ final class SmartLinkValidatorTest extends TestCase
], ],
]; ];
/**
* @param array<string, mixed> $raw
*/
private function createValidator(array $raw = self::RAW_CONFIG): SmartLinkValidator private function createValidator(array $raw = self::RAW_CONFIG): SmartLinkValidator
{ {
$parameters = $this->createMock(CoreParametersHelper::class); $parameters = $this->createMock(CoreParametersHelper::class);
@@ -55,6 +58,9 @@ final class SmartLinkValidatorTest extends TestCase
return new SmartLinkValidator($this->createMock(SmartLinkModel::class), $provider); return new SmartLinkValidator($this->createMock(SmartLinkModel::class), $provider);
} }
/**
* @param array<string, mixed> $parameters
*/
private function createTaxonomy(array $parameters): UtmTaxonomy private function createTaxonomy(array $parameters): UtmTaxonomy
{ {
$taxonomy = new UtmTaxonomy(); $taxonomy = new UtmTaxonomy();
+4 -1
View File
@@ -14,7 +14,6 @@ use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel; use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel;
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationNormalizer; use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationNormalizer;
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@@ -26,6 +25,8 @@ final class SmartLinkModelTest extends TestCase
{ {
/** /**
* A real provider with the given raw configuration, served through the normalizer. * A real provider with the given raw configuration, served through the normalizer.
*
* @param array<string, mixed> $raw
*/ */
private function createProvider(array $raw): UtmConfigurationProvider private function createProvider(array $raw): UtmConfigurationProvider
{ {
@@ -47,6 +48,8 @@ final class SmartLinkModelTest extends TestCase
/** /**
* The model with mocked core dependencies; the UTM configuration is real. * The model with mocked core dependencies; the UTM configuration is real.
*
* @param array<string, mixed> $raw
*/ */
private function createModel(array $raw, ?PageModel $pageModel = null, ?UrlGeneratorInterface $router = null): SmartLinkModel private function createModel(array $raw, ?PageModel $pageModel = null, ?UrlGeneratorInterface $router = null): SmartLinkModel
{ {
@@ -171,6 +171,9 @@ final class UtmConfigurationProviderTest extends TestCase
); );
} }
/**
* @param array<string, mixed>|null $legacy
*/
private function createProvider(mixed $stored, ?array $legacy = null): UtmConfigurationProvider private function createProvider(mixed $stored, ?array $legacy = null): UtmConfigurationProvider
{ {
$parameters = $this->createMock(CoreParametersHelper::class); $parameters = $this->createMock(CoreParametersHelper::class);
-5
View File
@@ -1,11 +1,6 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/*
* Finds the autoloader of the Mautic installation this plugin is mounted in
* (docroot/plugins/MT3SMarketingProgramBundle in the recommended project).
*/
$directory = __DIR__; $directory = __DIR__;
for ($level = 0; $level < 6; ++$level) { for ($level = 0; $level < 6; ++$level) {
$directory = dirname($directory); $directory = dirname($directory);
+4 -3
View File
@@ -5,11 +5,11 @@ declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Twig; namespace MauticPlugin\MT3SMarketingProgramBundle\Twig;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceType;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceRepository; use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceRepository;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceType;
use MauticPlugin\MT3SMarketingProgramBundle\Service\AudienceAttributes;
use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
use MauticPlugin\MT3SMarketingProgramBundle\Service\AudienceAttributes;
use Twig\Extension\AbstractExtension; use Twig\Extension\AbstractExtension;
use Twig\TwigFilter; use Twig\TwigFilter;
use Twig\TwigFunction; use Twig\TwigFunction;
@@ -39,7 +39,6 @@ class MT3SMarketingProgramExtension extends AbstractExtension
public function __construct( public function __construct(
private ItemTypeProvider $typeProvider, private ItemTypeProvider $typeProvider,
private CurrencyProvider $currencyProvider, private CurrencyProvider $currencyProvider,
private AudienceAttributes $audienceAttributes,
private AudienceRepository $audienceRepository, private AudienceRepository $audienceRepository,
) { ) {
} }
@@ -79,6 +78,8 @@ class MT3SMarketingProgramExtension extends AbstractExtension
/** /**
* The pictogram of an audience type. Accepts the enum itself (what the form's and entity's value * The pictogram of an audience type. Accepts the enum itself (what the form's and entity's value
* holds) or its backing value ('persona'); null defaults to Persona, the form's default. * holds) or its backing value ('persona'); null defaults to Persona, the form's default.
*
* @param AudienceType|string|null $value
*/ */
private static function audienceTypeIcon($value): string private static function audienceTypeIcon($value): string
{ {
-1
View File
@@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraint;
* *
* The start-before-end rule itself is EndDateAfterStartDate, shared by plans and tasks. * The start-before-end rule itself is EndDateAfterStartDate, shared by plans and tasks.
*/ */
#[\Symfony\Component\Validator\Attribute\HasNamedArguments]
class TaskDates extends Constraint class TaskDates extends Constraint
{ {
public const MILESTONE_END_ENSLAVED = 'mt3s.marketing_program.task.milestone.end_enslaved'; public const MILESTONE_END_ENSLAVED = 'mt3s.marketing_program.task.milestone.end_enslaved';
@@ -27,7 +27,7 @@ class ValidTaskDependencyValidator extends ConstraintValidator
*/ */
public function validate($task, Constraint $constraint): void public function validate($task, Constraint $constraint): void
{ {
if (!$task instanceof Task) { if (!$task instanceof Task || !$constraint instanceof ValidTaskDependency) {
return; return;
} }
@@ -36,7 +36,7 @@ class ValidTaskDependencyValidator extends ConstraintValidator
} }
} }
private function validateEdge(Task $task, TaskDependency $dependency, Constraint $constraint): void private function validateEdge(Task $task, TaskDependency $dependency, ValidTaskDependency $constraint): void
{ {
$dependsOn = $dependency->getDependsOn(); $dependsOn = $dependency->getDependsOn();
+9
View File
@@ -12,6 +12,15 @@
"php": ">=8.2", "php": ">=8.2",
"mautic/core-lib": "^7.0" "mautic/core-lib": "^7.0"
}, },
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan": "^2.0"
},
"scripts": {
"cs-check": "php-cs-fixer fix --dry-run --diff --config=.php-cs-fixer.dist.php",
"cs-fix": "php-cs-fixer fix --config=.php-cs-fixer.dist.php",
"phpstan": "phpstan analyse --no-progress -c phpstan.neon"
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"MauticPlugin\\MT3SMarketingProgramBundle\\": "" "MauticPlugin\\MT3SMarketingProgramBundle\\": ""
+127
View File
@@ -0,0 +1,127 @@
parameters:
ignoreErrors:
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\Audience\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/Audience.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\Program\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/Program.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\ProgramAllocationItem\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/ProgramAllocationItem.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\ProgramAudience\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/ProgramAudience.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\ProgramDescriptionItem\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/ProgramDescriptionItem.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\ProgramObjective\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/ProgramObjective.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\ProgramStakeholder\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/ProgramStakeholder.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\SmartLink\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/SmartLink.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\SmartLinkHit\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/SmartLinkHit.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\Stakeholder\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/Stakeholder.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\Task\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/Task.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\TaskDependency\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/TaskDependency.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\TaskRaci\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/TaskRaci.php
-
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\UtmTaxonomy\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: Entity/UtmTaxonomy.php
-
message: '#^Method MauticPlugin\\MT3SMarketingProgramBundle\\Migrations\\Version_0_11_0\:\:hasForeignKeys\(\) is unused\.$#'
identifier: method.unused
count: 1
path: Migrations/Version_0_11_0.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
count: 1
path: Migrations/Version_0_11_0.php
-
message: '#^Class MauticPlugin\\MT3SMarketingProgramBundle\\Migrations\\InitiativeStakeholder not found\.$#'
identifier: class.notFound
count: 1
path: Migrations/Version_0_12_0.php
-
message: '#^Class MauticPlugin\\MT3SMarketingProgramBundle\\Migrations\\InitiativeDescriptionItem not found\.$#'
identifier: class.notFound
count: 1
path: Migrations/Version_0_6_0.php
-
message: '#^Class MauticPlugin\\MT3SMarketingProgramBundle\\Migrations\\InitiativeAllocationItem not found\.$#'
identifier: class.notFound
count: 1
path: Migrations/Version_0_7_0.php
-
message: '#^Return type \(MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\AudienceRepository\) of method MauticPlugin\\MT3SMarketingProgramBundle\\Model\\AudienceModel\:\:getRepository\(\) should be compatible with return type \(Mautic\\CoreBundle\\Entity\\CommonRepository\<object\>\) of method Mautic\\CoreBundle\\Model\\AbstractCommonModel\<object\>\:\:getRepository\(\)$#'
identifier: method.childReturnType
count: 1
path: Model/AudienceModel.php
-
message: '#^Return type \(MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\StakeholderRepository\) of method MauticPlugin\\MT3SMarketingProgramBundle\\Model\\StakeholderModel\:\:getRepository\(\) should be compatible with return type \(Mautic\\CoreBundle\\Entity\\CommonRepository\<object\>\) of method Mautic\\CoreBundle\\Model\\AbstractCommonModel\<object\>\:\:getRepository\(\)$#'
identifier: method.childReturnType
count: 1
path: Model/StakeholderModel.php
+62
View File
@@ -0,0 +1,62 @@
# PHPStan configuration of the plugin, modeled on Mautic core's phpstan.neon.
#
# The analysis needs the autoloader of a Mautic installation: the bootstrap file
# (Tests/bootstrap.php) walks up from the plugin directory until it finds
# vendor/autoload.php. Run it either from a Mautic installation that has this
# plugin in docroot/plugins/, or after a `composer install` in the plugin
# directory (which pulls mautic/core-lib and the require-dev tools):
#
# vendor/bin/phpstan analyse --no-progress -c phpstan.neon
includes:
# The documented debt found when the tooling was introduced (see readme.md, Coding
# standards): Doctrine-assigned entity ids, historical migrations referencing the
# pre-rename entity classes, and core's generic AbstractCommonModel::getRepository()
# annotations. New errors still fail the analysis; regenerate the baseline after
# fixing entries with `phpstan analyse --generate-baseline -c phpstan.neon`.
- phpstan-baseline.neon
parameters:
level: 6
reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false
paths:
- Catalog
- Command
- Config
- Controller
- DependencyInjection
- Entity
- Event
- EventListener
- Form
- Integration
- Migrations
- Model
- Security
- Service
- Tests
- Twig
- Validator
- MT3SMarketingProgramBundle.php
excludePaths:
- Resources
- Translations
- Assets
# The same pragmatic ignores Mautic core keeps in its own phpstan.neon.
ignoreErrors:
- identifier: missingType.generics
# not all IDEs are as smart as PHPSTAN and need the type hint
- identifier: function.alreadyNarrowedType
- identifier: instanceof.alwaysTrue
- '/Variable \$\w+ might not be defined\./'
# test mocks
- '#Parameter (.*?) class (.*?) expects (.*?)PHPUnit\\Framework\\MockObject\\MockObject given#'
- '#is not subtype of native type PHPUnit\\Framework\\MockObject\\MockObject#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject#'
- '#expects (.*?) PHPUnit\\Framework\\MockObject\\MockObject given#'
bootstrapFiles:
- Tests/bootstrap.php
+23
View File
@@ -56,6 +56,29 @@ cd ../mautic-dev-env
For the complete list of commands, see the dev environment's README. For the complete list of commands, see the dev environment's README.
## Coding standards
The plugin runs the same code quality tools as Mautic core, configured in the repository root:
- **PHP-CS-Fixer** (`.php-cs-fixer.dist.php`): core's own ruleset — `@Symfony` plus its tweaks (aligned `=>`/`=` operators, ordered imports, short arrays, no unused imports, no header comments) minus the custom fixer of the `mautic/coding-standards` package, which a standalone plugin repository cannot require.
- **PHPStan** (`phpstan.neon`): level 6, with the same pragmatic ignores core keeps, and the plugin's `Tests/bootstrap.php` as the bootstrap so the analysis resolves the classes of the Mautic installation. The documented pre-existing debt (Doctrine-assigned entity ids, historical migrations referencing the pre-rename entity classes, core's generic `AbstractCommonModel::getRepository()` annotations) is recorded in `phpstan-baseline.neon`; new errors still fail the analysis. Regenerate after fixing entries: `vendor/bin/phpstan analyse --generate-baseline -c phpstan.neon`.
- **GitLab CI** (`.gitlab-ci.yml`): every push runs `composer cs-check` and `composer phpstan`. The PHPUnit suite is not run in CI: it needs a full Mautic installation (its bootstrap walks up to the nearest `vendor/autoload.php`).
The tools are `require-dev` dependencies (`composer install` in the plugin directory pulls `mautic/core-lib` and the tools, so the analysis sees the real Mautic signatures):
```bash
composer install # once, in the plugin directory
composer cs-check # dry run with the diff
composer cs-fix # fix in place
composer phpstan # PHPStan level 6
```
From the dev environment's running Mautic container instead (no local `composer install` needed):
```bash
docker compose exec mautic_web php vendor/bin/phpunit -c docroot/plugins/MT3SMarketingProgramBundle/phpunit.xml.dist
```
## Plugin structure ## Plugin structure
The plugin uses the IntegrationsBundle conventions: The plugin uses the IntegrationsBundle conventions: