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:
1 parent
687d33d30c
commit
ea88b7a772
131 files changed
+3238
-2836
No files matched your search
@@ -2,22 +2,22 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Model;
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Model;
|
||||
|
||||
use Mautic\CoreBundle\Model\FormModel;
|
||||
use MauticPlugin\ProgramBundle\Entity\Audience;
|
||||
use MauticPlugin\ProgramBundle\Entity\AudienceRepository;
|
||||
use MauticPlugin\ProgramBundle\Form\Type\AudienceType;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceRepository;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\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').
|
||||
* Available as mt3s.marketing_program.model.audience, or getModel('mt3smp.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).
|
||||
* them from their Audiences tab through ProgramAudience (which carries the audience's priority in
|
||||
* that program).
|
||||
*/
|
||||
class AudienceModel extends FormModel
|
||||
{
|
||||
@@ -31,7 +31,7 @@ class AudienceModel extends FormModel
|
||||
|
||||
public function getPermissionBase(): string
|
||||
{
|
||||
return 'program:audiences';
|
||||
return 'mt3smarketingprogram:audiences';
|
||||
}
|
||||
|
||||
public function getEntity($id = null): ?Audience
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Model;
|
||||
|
||||
use Mautic\CoreBundle\Model\FormModel;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramRepository;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Event\MT3SMarketingProgramEvents;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Event\ProgramEvent;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\ProgramType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
|
||||
/**
|
||||
* @extends FormModel<Program>
|
||||
*/
|
||||
class ProgramModel extends FormModel
|
||||
{
|
||||
public function getRepository(): ProgramRepository
|
||||
{
|
||||
$repository = $this->em->getRepository(Program::class);
|
||||
\assert($repository instanceof ProgramRepository);
|
||||
|
||||
return $repository;
|
||||
}
|
||||
|
||||
public function getPermissionBase(): string
|
||||
{
|
||||
return 'mt3smarketingprogram:programs';
|
||||
}
|
||||
|
||||
/**
|
||||
* With no ID, returns a new program with the current user as owner.
|
||||
*/
|
||||
public function getEntity($id = null): ?Program
|
||||
{
|
||||
if (null === $id) {
|
||||
$program = new Program();
|
||||
$program->setOwner($this->userHelper->getUser(true));
|
||||
|
||||
return $program;
|
||||
}
|
||||
|
||||
$program = parent::getEntity($id);
|
||||
|
||||
return $program instanceof Program ? $program : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps objective and description item positions contiguous (0..n-1) before saving, and
|
||||
* dispatches the plugin's pre/post save events (created vs updated by the entity's ID).
|
||||
*/
|
||||
public function saveEntity($entity, $unlock = true): void
|
||||
{
|
||||
if ($entity instanceof Program) {
|
||||
$isNew = null === $entity->getId();
|
||||
|
||||
$this->dispatcher->dispatch(new ProgramEvent($entity, $isNew), MT3SMarketingProgramEvents::PROGRAM_PRE_SAVE);
|
||||
|
||||
$entity->normalizePositions();
|
||||
|
||||
parent::saveEntity($entity, $unlock);
|
||||
|
||||
$this->dispatcher->dispatch(new ProgramEvent($entity, $isNew), MT3SMarketingProgramEvents::PROGRAM_POST_SAVE);
|
||||
$this->dispatcher->dispatch(
|
||||
new ProgramEvent($entity, $isNew),
|
||||
$isNew ? MT3SMarketingProgramEvents::PROGRAM_CREATED : MT3SMarketingProgramEvents::PROGRAM_UPDATED
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::saveEntity($entity, $unlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches the plugin's delete events around the removal.
|
||||
*/
|
||||
public function deleteEntity($entity): void
|
||||
{
|
||||
if ($entity instanceof Program) {
|
||||
$this->dispatcher->dispatch(new ProgramEvent($entity, false), MT3SMarketingProgramEvents::PROGRAM_PRE_DELETE);
|
||||
|
||||
parent::deleteEntity($entity);
|
||||
|
||||
$this->dispatcher->dispatch(new ProgramEvent($entity, false), MT3SMarketingProgramEvents::PROGRAM_POST_DELETE);
|
||||
$this->dispatcher->dispatch(new ProgramEvent($entity, false), MT3SMarketingProgramEvents::PROGRAM_DELETED);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::deleteEntity($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $options
|
||||
*/
|
||||
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
|
||||
{
|
||||
if (!$entity instanceof Program) {
|
||||
throw new MethodNotAllowedHttpException(['Program']);
|
||||
}
|
||||
|
||||
if (!empty($action)) {
|
||||
$options['action'] = $action;
|
||||
}
|
||||
|
||||
return $formFactory->create(ProgramType::class, $entity, $options);
|
||||
}
|
||||
}
|
||||
@@ -2,24 +2,24 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Model;
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Model;
|
||||
|
||||
use libphonenumber\NumberParseException;
|
||||
use libphonenumber\PhoneNumberFormat;
|
||||
use libphonenumber\PhoneNumberUtil;
|
||||
use Mautic\CoreBundle\Model\FormModel;
|
||||
use MauticPlugin\ProgramBundle\Entity\Stakeholder;
|
||||
use MauticPlugin\ProgramBundle\Entity\StakeholderRepository;
|
||||
use MauticPlugin\ProgramBundle\Form\Type\StakeholderType;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Stakeholder;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\StakeholderRepository;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\StakeholderType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
|
||||
/**
|
||||
* Available as mautic.program.model.stakeholder, or getModel('program.stakeholder').
|
||||
* Available as mt3s.marketing_program.model.stakeholder, or getModel('mt3smp.stakeholder').
|
||||
*
|
||||
* On save, the phone number is normalized to E.164 using the default region from Settings >
|
||||
* Configuration > Initiative Settings (parameter program_stakeholder_phone_region, FR by default). A number that
|
||||
* Configuration > Program Settings (parameter mt3s_marketing_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 = 'program_stakeholder_phone_region';
|
||||
public const PHONE_REGION_PARAMETER = 'mt3s_marketing_program_stakeholder_phone_region';
|
||||
|
||||
public const DEFAULT_PHONE_REGION = 'FR';
|
||||
|
||||
@@ -41,7 +41,7 @@ class StakeholderModel extends FormModel
|
||||
|
||||
public function getPermissionBase(): string
|
||||
{
|
||||
return 'program:stakeholders';
|
||||
return 'mt3smarketingprogram:stakeholders';
|
||||
}
|
||||
|
||||
public function getEntity($id = null): ?Stakeholder
|
||||
|
||||
+10
-10
@@ -2,19 +2,19 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Model;
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Model;
|
||||
|
||||
use Mautic\CoreBundle\Model\FormModel;
|
||||
use MauticPlugin\ProgramBundle\Entity\Initiative;
|
||||
use MauticPlugin\ProgramBundle\Entity\Task;
|
||||
use MauticPlugin\ProgramBundle\Entity\TaskRepository;
|
||||
use MauticPlugin\ProgramBundle\Form\Type\TaskType;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Task;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\TaskRepository;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\TaskType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
|
||||
/**
|
||||
* Available as mautic.program.model.task, or getModel('program.task').
|
||||
* Available as mt3s.marketing_program.model.task, or getModel('mt3smp.task').
|
||||
*
|
||||
* @extends FormModel<Task>
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ class TaskModel extends FormModel
|
||||
|
||||
public function getPermissionBase(): string
|
||||
{
|
||||
return 'program:tasks';
|
||||
return 'mt3smarketingprogram:tasks';
|
||||
}
|
||||
|
||||
public function getEntity($id = null): ?Task
|
||||
@@ -45,16 +45,16 @@ class TaskModel extends FormModel
|
||||
}
|
||||
|
||||
/**
|
||||
* The plan's tasks as rows for the initiative's Tasks tab: the tasks ordered by name, each with its
|
||||
* The plan's tasks as rows for the program'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(Initiative $initiative): array
|
||||
public function getTaskTree(Program $program): array
|
||||
{
|
||||
$rows = [];
|
||||
foreach ($this->getRepository()->findByInitiative($initiative) as $task) {
|
||||
foreach ($this->getRepository()->findByProgram($program) as $task) {
|
||||
$rows[] = ['task' => $task, 'depth' => 0];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user