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

+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);
}
}