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

+1 -1
View File
@@ -93,4 +93,4 @@ class AudienceController extends AbstractStandardFormController
{
return $this->batchDeleteStandard($request);
}
}
}
+1 -1
View File
@@ -115,4 +115,4 @@ class ItemTypesController extends AbstractFormController
],
]);
}
}
}
+1 -1
View File
@@ -80,7 +80,7 @@ class ProgramController extends AbstractStandardFormController
}
if (!$this->checkActionPermission('view', $program)) {
return $this->accessDenied();
$this->throwAccessDenied();
}
$base = $this->getPermissionBase();
+32 -9
View File
@@ -4,13 +4,21 @@ declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
use Doctrine\Persistence\ManagerRegistry;
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 Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\Service\Attribute\Required;
/**
* 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
{
private SmartLinkModel $smartLinkModel;
#[Required]
public function autowirePublicController(SmartLinkModel $smartLinkModel): void
{
$this->smartLinkModel = $smartLinkModel;
public function __construct(
private readonly SmartLinkModel $smartLinkModel,
private readonly LoggerInterface $logger,
ManagerRegistry $doctrine,
ModelFactory $modelFactory,
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
@@ -64,7 +80,14 @@ class PublicController extends CommonController
$this->smartLinkModel->recordHit($link, $request);
} catch (\Throwable $e) {
// 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);
+13 -3
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
* 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
{
if ($entity instanceof SmartLink && null !== $entity->getId()) {
$formSlug = $form->has('slug') ? (string) $form->get('slug')->getData() : '';
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;
}
@@ -123,6 +128,7 @@ class SmartLinkController extends AbstractStandardFormController
* also displayed above the form of a link), and the number of hits of each link.
*
* @param array<string, mixed> $args
* @param string $action
*
* @return array<string, mixed>
*/
@@ -134,7 +140,7 @@ class SmartLinkController extends AbstractStandardFormController
$model = $this->getModel($this->getModelName());
\assert($model instanceof SmartLinkModel);
$args['viewParameters']['shortLinkDomain'] = $model->getShortLinkDomain();
$args['viewParameters']['shortLinkDomain'] = $model->getShortLinkDomain();
$args['viewParameters']['hitCounts'] = $model->getHitCounts();
}
@@ -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.
*
* @param string $action
*/
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.
*
* @param int|null $objectId
*/
public function cloneAction(Request $request, $objectId): Response
{
$this->accessDenied();
$this->throwAccessDenied();
}
}
+13 -1
View File
@@ -97,7 +97,7 @@ class TaskController extends AbstractStandardFormController
*/
public function editAction(Request $request, $objectId, $ignorePost = false): Response
{
$task = $this->getModel($this->getModelName())->getEntity((int) $objectId);
$task = $this->getModel($this->getModelName())->getEntity((int) $objectId);
$programId = $task instanceof Task ? $task->getProgram()?->getId() : null;
$this->returnProgramId = $this->resolveReturnProgram($request, (string) (int) $objectId, $programId);
@@ -137,6 +137,10 @@ class TaskController extends AbstractStandardFormController
}
/**
* @param string $action
* @param int|null $objectId
* @param bool $isClone
*
* @return object|null
*/
protected function getFormEntity($action, &$objectId = null, &$isClone = false)
@@ -153,6 +157,13 @@ class TaskController extends AbstractStandardFormController
return $entity;
}
/**
* @param Task $entity
* @param string $action
* @param mixed $pass
*
* @return mixed
*/
protected function afterEntitySave($entity, Form $form, $action, $pass = null)
{
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.
*
* @param array<string, mixed> $args
* @param string $action
*
* @return array<string, mixed>
*/
+6 -2
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.
*
* @param string $action
*/
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.
*
* @param int|null $objectId
*/
public function cloneAction(Request $request, $objectId): Response
{
$this->accessDenied();
$this->throwAccessDenied();
}
}
}