refactor(plugin): rename Plan to Program and add audience/UTM routes

Rename the Plan bundle to Program across config, routes, menus, and
controllers (Plan -> Initiative), bump version to 0.16.0, and introduce
new audience and UTM taxonomy routes and permissions to support the
expanded Programs feature set.
This commit is contained in:
Alexandre Gain committed 2026-11-13 22:01:32 +01:00
1 parent 8268fad886
commit 71ff11390b
121 files changed
+5011 -2874

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Model;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\ProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\AudienceRepository;
use MauticPlugin\ProgramBundle\Form\Type\AudienceType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* Available as mautic.program.model.audience, or getModel('program.audience').
*
* Audiences are a global directory (Programs > Audiences), independent of plans; plans link to
* them from their Audiences tab through InitiativeAudience (which carries the audience's priority in
* that initiative).
*/
class AudienceModel extends FormModel
{
public function getRepository(): AudienceRepository
{
$repository = $this->em->getRepository(Audience::class);
\assert($repository instanceof AudienceRepository);
return $repository;
}
public function getPermissionBase(): string
{
return 'program:audiences';
}
public function getEntity($id = null): ?Audience
{
if (null === $id) {
return new Audience();
}
$audience = parent::getEntity($id);
return $audience instanceof Audience ? $audience : null;
}
/**
* @param array<string, mixed> $options
*/
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
{
if (!$entity instanceof Audience) {
throw new MethodNotAllowedHttpException(['Audience']);
}
if (!empty($action)) {
$options['action'] = $action;
}
return $formFactory->create(AudienceType::class, $entity, $options);
}
}
+77
View File
@@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Model;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeRepository;
use MauticPlugin\ProgramBundle\Form\Type\InitiativeType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* @extends FormModel<Initiative>
*/
class InitiativeModel extends FormModel
{
public function getRepository(): InitiativeRepository
{
$repository = $this->em->getRepository(Initiative::class);
\assert($repository instanceof InitiativeRepository);
return $repository;
}
public function getPermissionBase(): string
{
return 'program:initiatives';
}
/**
* With no ID, returns a new initiative with the current user as owner.
*/
public function getEntity($id = null): ?Initiative
{
if (null === $id) {
$initiative = new Initiative();
$initiative->setOwner($this->userHelper->getUser(true));
return $initiative;
}
$initiative = parent::getEntity($id);
return $initiative instanceof Initiative ? $initiative : null;
}
/**
* Keeps objective and description item positions contiguous (0..n-1) before saving.
*/
public function saveEntity($entity, $unlock = true): void
{
if ($entity instanceof Initiative) {
$entity->normalizePositions();
}
parent::saveEntity($entity, $unlock);
}
/**
* @param array<string, mixed> $options
*/
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
{
if (!$entity instanceof Initiative) {
throw new MethodNotAllowedHttpException(['Initiative']);
}
if (!empty($action)) {
$options['action'] = $action;
}
return $formFactory->create(InitiativeType::class, $entity, $options);
}
}
-77
View File
@@ -1,77 +0,0 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Model;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\PlanRepository;
use MauticPlugin\PlanBundle\Form\Type\PlanType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* @extends FormModel<Plan>
*/
class PlanModel extends FormModel
{
public function getRepository(): PlanRepository
{
$repository = $this->em->getRepository(Plan::class);
\assert($repository instanceof PlanRepository);
return $repository;
}
public function getPermissionBase(): string
{
return 'plan:plans';
}
/**
* With no ID, returns a new plan with the current user as owner.
*/
public function getEntity($id = null): ?Plan
{
if (null === $id) {
$plan = new Plan();
$plan->setOwner($this->userHelper->getUser(true));
return $plan;
}
$plan = parent::getEntity($id);
return $plan instanceof Plan ? $plan : null;
}
/**
* Keeps objective and description item positions contiguous (0..n-1) before saving.
*/
public function saveEntity($entity, $unlock = true): void
{
if ($entity instanceof Plan) {
$entity->normalizePositions();
}
parent::saveEntity($entity, $unlock);
}
/**
* @param array<string, mixed> $options
*/
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
{
if (!$entity instanceof Plan) {
throw new MethodNotAllowedHttpException(['Plan']);
}
if (!empty($action)) {
$options['action'] = $action;
}
return $formFactory->create(PlanType::class, $entity, $options);
}
}
+8 -8
View File
@@ -2,24 +2,24 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Model;
namespace MauticPlugin\ProgramBundle\Model;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberUtil;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\PlanBundle\Entity\Stakeholder;
use MauticPlugin\PlanBundle\Entity\StakeholderRepository;
use MauticPlugin\PlanBundle\Form\Type\StakeholderType;
use MauticPlugin\ProgramBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Entity\StakeholderRepository;
use MauticPlugin\ProgramBundle\Form\Type\StakeholderType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* Available as mautic.plan.model.stakeholder, or getModel('plan.stakeholder').
* Available as mautic.program.model.stakeholder, or getModel('program.stakeholder').
*
* On save, the phone number is normalized to E.164 using the default region from Settings >
* Configuration > Plan Settings (parameter plan_stakeholder_phone_region, FR by default). A number that
* Configuration > Initiative Settings (parameter program_stakeholder_phone_region, FR by default). A number that
* doesn't parse (free input, extensions…) is kept exactly as typed: the save is never blocked.
*/
class StakeholderModel extends FormModel
@@ -27,7 +27,7 @@ class StakeholderModel extends FormModel
/**
* local.php parameter: default region for phone numbers typed without a country prefix.
*/
public const PHONE_REGION_PARAMETER = 'plan_stakeholder_phone_region';
public const PHONE_REGION_PARAMETER = 'program_stakeholder_phone_region';
public const DEFAULT_PHONE_REGION = 'FR';
@@ -41,7 +41,7 @@ class StakeholderModel extends FormModel
public function getPermissionBase(): string
{
return 'plan:stakeholders';
return 'program:stakeholders';
}
public function getEntity($id = null): ?Stakeholder
+10 -10
View File
@@ -2,19 +2,19 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Model;
namespace MauticPlugin\ProgramBundle\Model;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\PlanBundle\Entity\TaskRepository;
use MauticPlugin\PlanBundle\Form\Type\TaskType;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskRepository;
use MauticPlugin\ProgramBundle\Form\Type\TaskType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* Available as mautic.plan.model.task, or getModel('plan.task').
* Available as mautic.program.model.task, or getModel('program.task').
*
* @extends FormModel<Task>
*/
@@ -30,7 +30,7 @@ class TaskModel extends FormModel
public function getPermissionBase(): string
{
return 'plan:tasks';
return 'program:tasks';
}
public function getEntity($id = null): ?Task
@@ -45,16 +45,16 @@ class TaskModel extends FormModel
}
/**
* The plan's tasks as rows for the plan's Tasks tab: the tasks ordered by name, each with its
* The plan's tasks as rows for the initiative's Tasks tab: the tasks ordered by name, each with its
* dependencies and RACI rows loaded. The former parent/child tree is gone; the tab lists the
* tasks flat, and the dependencies are shown per task.
*
* @return array<int, array{task: Task, depth: int}>
*/
public function getTaskTree(Plan $plan): array
public function getTaskTree(Initiative $initiative): array
{
$rows = [];
foreach ($this->getRepository()->findByPlan($plan) as $task) {
foreach ($this->getRepository()->findByInitiative($initiative) as $task) {
$rows[] = ['task' => $task, 'depth' => 0];
}