refactor(plugin): rebrand as MT3SMarketingProgram, release 0.17.0

Rename the plugin's vendor/namespace from experiential/Program to mt3s/MT3SMarketingProgram (composer: mt3s/mautic-marketing-program-bundle):

- ProgramBundle -> MT3SMarketingProgramBundle; extension, integration,
  config support, permissions, events and twig extension renamed likewise
- Initiative* -> Program*: controller (InitiativeController ->
  ProgramController), model, entities, repositories, form types and views
  (new _tabs/_task_table/_tab_table_filter partials, details page)
- Settings config form theme -> _config_mt3smarketingprogramconfig_widget;
  routes and translations re-prefixed (mt3s_marketing_program_*)
- Assets: icon.svg -> mt3s-mp-icon.svg; program.js -> mt3s-mp-program.js
  (OnLoad hooks renamed mt3sMpProgram*)
- Add Command/RefreshStatsCommand; Migrations/Version_0_17_0.php renames
  the tables to mt3s_mp_program_*
This commit is contained in:
Alexandre Gain committed 2026-11-15 17:48:01 +01:00
1 parent 687d33d30c
commit ea88b7a772
131 files changed
+3238 -2836

No files matched your search

+38 -38
View File
@@ -2,11 +2,11 @@
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Controller;
namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
use Mautic\CoreBundle\Controller\AbstractStandardFormController;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\Task;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Task;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -14,30 +14,30 @@ use Symfony\Component\HttpFoundation\Response;
/**
* List, create, edit and delete tasks (Programs > Tasks), using core's standard CRUD flow.
*
* Model program.task (mautic.program.model.task), permission base program:tasks, translation base mautic.program.task.
* Model mt3smp.task (mt3s.marketing_program.model.task), permission base mt3smarketingprogram:tasks, translation base mt3s.marketing_program.task.
*
* Where the user lands after Save or Cancel depends on where the task form was opened from:
* - from Programs > Tasks: back to the task list (core's default);
* - from an initiative's Tasks tab (links with ?returnTo=initiative): back to that initiative.
* - from an program's Tasks tab (links with ?returnTo=program): back to that program.
* The origin is kept in the session when the form is opened, because the form posts to a URL
* without the query string.
*/
class TaskController extends AbstractStandardFormController
{
public const ROUTE_INDEX = 'initiative_task_index';
public const ROUTE_ACTION = 'initiative_task_action';
public const ROUTE_INDEX = 'mt3s_marketing_program_task_index';
public const ROUTE_ACTION = 'mt3s_marketing_program_task_action';
/**
* Value of the returnTo query parameter that sends the user back to the initiative.
* Value of the returnTo query parameter that sends the user back to the program.
*/
public const RETURN_TO_PLAN = 'initiative';
public const RETURN_TO_PLAN = 'program';
private const SESSION_RETURN_PLAN = 'mautic.program.task.return_initiative.';
private const SESSION_RETURN_PLAN = 'mt3s.marketing_program.task.return_program.';
/**
* Initiative to preselect on a new task (from ?initiative=ID, used by the initiative's "Add task" button).
* Program to preselect on a new task (from ?program=ID, used by the program's "Add task" button).
*/
private ?int $preselectedInitiativeId = null;
private ?int $preselectedProgramId = null;
/**
* The task saved during this request, if any.
@@ -45,18 +45,18 @@ class TaskController extends AbstractStandardFormController
private ?Task $savedTask = null;
/**
* Initiative to go back to after Save or Cancel, or null for the task list.
* Program to go back to after Save or Cancel, or null for the task list.
*/
private ?int $returnInitiativeId = null;
private ?int $returnProgramId = null;
protected function getModelName(): string
{
return 'program.task';
return 'mt3smp.task';
}
protected function getTemplateBase(): string
{
return '@Program/Task';
return '@MT3SMarketingProgram/Task';
}
protected function getIndexRoute(): string
@@ -71,7 +71,7 @@ class TaskController extends AbstractStandardFormController
protected function getJsLoadMethodPrefix(): string
{
return 'programTask';
return 'mt3sMpProgramTask';
}
/**
@@ -84,9 +84,9 @@ class TaskController extends AbstractStandardFormController
public function newAction(Request $request): Response
{
$initiativeId = $request->query->getInt('initiative');
$this->preselectedInitiativeId = $initiativeId > 0 ? $initiativeId : null;
$this->returnInitiativeId = $this->resolveReturnInitiative($request, 'new', $this->preselectedInitiativeId);
$programId = $request->query->getInt('program');
$this->preselectedProgramId = $programId > 0 ? $programId : null;
$this->returnProgramId = $this->resolveReturnProgram($request, 'new', $this->preselectedProgramId);
return $this->newStandard($request);
}
@@ -98,24 +98,24 @@ class TaskController extends AbstractStandardFormController
public function editAction(Request $request, $objectId, $ignorePost = false): Response
{
$task = $this->getModel($this->getModelName())->getEntity((int) $objectId);
$initiativeId = $task instanceof Task ? $task->getInitiative()?->getId() : null;
$this->returnInitiativeId = $this->resolveReturnInitiative($request, (string) (int) $objectId, $initiativeId);
$programId = $task instanceof Task ? $task->getProgram()?->getId() : null;
$this->returnProgramId = $this->resolveReturnProgram($request, (string) (int) $objectId, $programId);
return $this->editStandard($request, $objectId, $ignorePost);
}
/**
* When the form is opened (GET), records whether it came from an initiative (?returnTo=initiative); when it is
* When the form is opened (GET), records whether it came from an program (?returnTo=program); when it is
* submitted (POST), reads that record back. Opening the same form from the task list clears it.
*/
private function resolveReturnInitiative(Request $request, string $formKey, ?int $initiativeId): ?int
private function resolveReturnProgram(Request $request, string $formKey, ?int $programId): ?int
{
$session = $request->getSession();
$key = self::SESSION_RETURN_PLAN.$formKey;
if (!$request->isMethod('POST')) {
$fromInitiative = self::RETURN_TO_PLAN === $request->query->get('returnTo') && null !== $initiativeId;
$session->set($key, $fromInitiative ? $initiativeId : null);
$fromProgram = self::RETURN_TO_PLAN === $request->query->get('returnTo') && null !== $programId;
$session->set($key, $fromProgram ? $programId : null);
}
$value = $session->get($key);
@@ -143,10 +143,10 @@ class TaskController extends AbstractStandardFormController
{
$entity = parent::getFormEntity($action, $objectId, $isClone);
if ('new' === $action && $entity instanceof Task && null === $entity->getInitiative() && null !== $this->preselectedInitiativeId) {
$initiative = $this->getModel('program.initiative')->getEntity($this->preselectedInitiativeId);
if ($initiative instanceof Initiative) {
$entity->setInitiative($initiative);
if ('new' === $action && $entity instanceof Task && null === $entity->getProgram() && null !== $this->preselectedProgramId) {
$program = $this->getModel('mt3smp.program')->getEntity($this->preselectedProgramId);
if ($program instanceof Program) {
$entity->setProgram($program);
}
}
@@ -163,8 +163,8 @@ class TaskController extends AbstractStandardFormController
}
/**
* After Save or Cancel (not Apply) on a form opened from an initiative, go back to that initiative. If the task
* was moved to another initiative, go to its new initiative. Otherwise keep core's default: the task list.
* After Save or Cancel (not Apply) on a form opened from an program, go back to that program. If the task
* was moved to another program, go to its new program. Otherwise keep core's default: the task list.
*
* @param array<string, mixed> $args
*
@@ -172,13 +172,13 @@ class TaskController extends AbstractStandardFormController
*/
protected function getPostActionRedirectArguments(array $args, $action): array
{
if (in_array($action, ['new', 'edit'], true) && null !== $this->returnInitiativeId) {
$initiativeId = $this->savedTask?->getInitiative()?->getId() ?? $this->returnInitiativeId;
if (in_array($action, ['new', 'edit'], true) && null !== $this->returnProgramId) {
$programId = $this->savedTask?->getProgram()?->getId() ?? $this->returnProgramId;
$args['returnUrl'] = $this->generateUrl(InitiativeController::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $initiativeId]);
$args['contentTemplate'] = InitiativeController::class.'::viewAction';
$args['viewParameters'] = ['objectId' => $initiativeId];
$args['passthroughVars'] = array_merge($args['passthroughVars'] ?? [], ['mauticContent' => 'initiative']);
$args['returnUrl'] = $this->generateUrl(ProgramController::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $programId]);
$args['contentTemplate'] = ProgramController::class.'::viewAction';
$args['viewParameters'] = ['objectId' => $programId];
$args['passthroughVars'] = array_merge($args['passthroughVars'] ?? [], ['mauticContent' => 'program']);
}
return parent::getPostActionRedirectArguments($args, $action);