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,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Controller;
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
|
||||
|
||||
use Mautic\CoreBundle\Controller\AbstractStandardFormController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -10,26 +10,26 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* List, create, edit and delete audiences (Programs > Audiences), the global directory of who the
|
||||
* initiatives are aimed at, using core's standard CRUD flow. Audiences are independent of initiatives; initiatives
|
||||
* link to them from their Audiences tab (InitiativeAudience carries the audience's priority in that
|
||||
* initiative).
|
||||
* programs are aimed at, using core's standard CRUD flow. Audiences are independent of programs; programs
|
||||
* link to them from their Audiences tab (ProgramAudience carries the audience's priority in that
|
||||
* program).
|
||||
*
|
||||
* Model program.audience (mautic.program.model.audience), permission base program:audiences, translation
|
||||
* base mautic.program.audience.
|
||||
* Model mt3smp.audience (mt3s.marketing_program.model.audience), permission base mt3smarketingprogram:audiences, translation
|
||||
* base mt3s.marketing_program.audience.
|
||||
*/
|
||||
class AudienceController extends AbstractStandardFormController
|
||||
{
|
||||
public const ROUTE_INDEX = 'initiative_audience_index';
|
||||
public const ROUTE_ACTION = 'initiative_audience_action';
|
||||
public const ROUTE_INDEX = 'mt3s_marketing_program_audience_index';
|
||||
public const ROUTE_ACTION = 'mt3s_marketing_program_audience_action';
|
||||
|
||||
protected function getModelName(): string
|
||||
{
|
||||
return 'program.audience';
|
||||
return 'mt3smp.audience';
|
||||
}
|
||||
|
||||
protected function getTemplateBase(): string
|
||||
{
|
||||
return '@Program/Audience';
|
||||
return '@MT3SMarketingProgram/Audience';
|
||||
}
|
||||
|
||||
protected function getIndexRoute(): string
|
||||
@@ -44,7 +44,7 @@ class AudienceController extends AbstractStandardFormController
|
||||
|
||||
protected function getJsLoadMethodPrefix(): string
|
||||
{
|
||||
return 'programAudience';
|
||||
return 'mt3sMpProgramAudience';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,14 +62,14 @@ class AudienceController extends AbstractStandardFormController
|
||||
|
||||
/**
|
||||
* The audience's detail page (the directory entry, its persona attributes, its segments and
|
||||
* the initiatives it is assigned to). The standard controller has no view action of its own, so it
|
||||
* the programs it is assigned to). The standard controller has no view action of its own, so it
|
||||
* is routed here.
|
||||
*
|
||||
* @param int $objectId
|
||||
*/
|
||||
public function viewAction(Request $request, $objectId): Response
|
||||
{
|
||||
return $this->viewStandard($request, $objectId, 'audience', 'initiative');
|
||||
return $this->viewStandard($request, $objectId, 'audience', 'program');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Controller;
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
|
||||
|
||||
use Mautic\CoreBundle\Configurator\Configurator;
|
||||
use Mautic\CoreBundle\Controller\AbstractFormController;
|
||||
use Mautic\CoreBundle\Helper\CacheHelper;
|
||||
use MauticPlugin\ProgramBundle\Form\Type\ItemTypesType;
|
||||
use MauticPlugin\ProgramBundle\Service\ItemTypeInUseGuard;
|
||||
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\ItemTypesType;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeInUseGuard;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
@@ -20,18 +20,18 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* The Item types page (Programs > Item types): the type lists of the plugin's items — insights
|
||||
* (description items), allocations, objectives, tasks, stakeholders, and the values offered for
|
||||
* an audience's decision roles and tones. Formerly part of Settings > Configuration > Program
|
||||
* Settings; now on its own page under Programs, so a user with the program:itemtypes permissions
|
||||
* Settings; now on its own page under Programs, so a user with the mt3smarketingprogram:itemtypes permissions
|
||||
* manages the types without being an administrator.
|
||||
*
|
||||
* Each list is a local.php parameter (ItemTypeProvider::PARAMETERS), saved through core's
|
||||
* Configurator exactly like Settings > Configuration saves its own forms: merge, write, refresh
|
||||
* the config. A type that items still use cannot be removed (ItemTypeInUseGuard).
|
||||
*
|
||||
* Permissions: program:itemtypes:view shows the page, program:itemtypes:edit saves it.
|
||||
* Permissions: mt3smarketingprogram:itemtypes:view shows the page, mt3smarketingprogram:itemtypes:edit saves it.
|
||||
*/
|
||||
class ItemTypesController extends AbstractFormController
|
||||
{
|
||||
public const ROUTE_INDEX = 'program_item_types_index';
|
||||
public const ROUTE_INDEX = 'mt3s_marketing_program_item_types_index';
|
||||
|
||||
/**
|
||||
* Shows the lists, and saves them on POST.
|
||||
@@ -44,7 +44,7 @@ class ItemTypesController extends AbstractFormController
|
||||
Configurator $configurator,
|
||||
CacheHelper $cacheHelper,
|
||||
): Response {
|
||||
if (!$this->security->isGranted('program:itemtypes:view')) {
|
||||
if (!$this->security->isGranted('mt3smarketingprogram:itemtypes:view')) {
|
||||
$this->throwAccessDenied();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class ItemTypesController extends AbstractFormController
|
||||
$isWritable = $configurator->isFileWritable();
|
||||
|
||||
if ('POST' === $request->getMethod()) {
|
||||
if (!$this->security->isGranted('program:itemtypes:edit')) {
|
||||
if (!$this->security->isGranted('mt3smarketingprogram:itemtypes:edit')) {
|
||||
$this->throwAccessDenied();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class ItemTypesController extends AbstractFormController
|
||||
if ([] !== $removedInUse) {
|
||||
foreach ($removedInUse as $names) {
|
||||
$form->addError(new FormError(
|
||||
$this->translator->trans('mautic.program.config.type.in_use', ['%types%' => implode(', ', $names)], 'validators')
|
||||
$this->translator->trans('mt3s.marketing_program.config.type.in_use', ['%types%' => implode(', ', $names)], 'validators')
|
||||
));
|
||||
}
|
||||
} else {
|
||||
@@ -92,7 +92,7 @@ class ItemTypesController extends AbstractFormController
|
||||
|
||||
$configurator->write();
|
||||
|
||||
$this->addFlashMessage('mautic.program.item_type.saved');
|
||||
$this->addFlashMessage('mt3s.marketing_program.item_type.saved');
|
||||
|
||||
// local.php changed: the cached container is stale until refreshed.
|
||||
$cacheHelper->refreshConfig();
|
||||
@@ -107,10 +107,10 @@ class ItemTypesController extends AbstractFormController
|
||||
'form' => $form->createView(),
|
||||
'isWritable' => $isWritable,
|
||||
],
|
||||
'contentTemplate' => '@Program/ItemTypes/form.html.twig',
|
||||
'contentTemplate' => '@MT3SMarketingProgram/ItemTypes/form.html.twig',
|
||||
'passthroughVars' => [
|
||||
'activeLink' => '#'.self::ROUTE_INDEX,
|
||||
'mauticContent' => 'programItemTypes',
|
||||
'mauticContent' => 'mt3sMpProgramItemTypes',
|
||||
'route' => $action,
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -2,37 +2,37 @@
|
||||
|
||||
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\Model\TaskModel;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Model\TaskModel;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* List, view, create, edit and delete plans, using core's standard CRUD flow.
|
||||
*
|
||||
* Core derives most names from the model name "initiative": model mautic.program.model.initiative, permission base
|
||||
* program:initiatives (from InitiativeModel), translation base mautic.program, session base mautic.program.
|
||||
* Core derives most names from the model name "program": model mt3s.marketing_program.model.program, permission base
|
||||
* mt3smarketingprogram:programs (from ProgramModel), translation base mt3s.marketing_program, session base mt3s.marketing_program.
|
||||
*/
|
||||
class InitiativeController extends AbstractStandardFormController
|
||||
class ProgramController extends AbstractStandardFormController
|
||||
{
|
||||
public const ROUTE_INDEX = 'initiative_index';
|
||||
public const ROUTE_ACTION = 'initiative_action';
|
||||
public const ROUTE_INDEX = 'mt3s_marketing_program_index';
|
||||
public const ROUTE_ACTION = 'mt3s_marketing_program_action';
|
||||
|
||||
protected function getModelName(): string
|
||||
{
|
||||
return 'program.initiative';
|
||||
return 'mt3smp.program';
|
||||
}
|
||||
|
||||
protected function getTemplateBase(): string
|
||||
{
|
||||
return '@Program/Initiative';
|
||||
return '@MT3SMarketingProgram/Program';
|
||||
}
|
||||
|
||||
/**
|
||||
* Core would build mautic_initiative_index; the plugin's routes use the plan_ prefix.
|
||||
* Core would build mautic_mt3s_marketing_program_index; the plugin's routes use the plan_ prefix.
|
||||
*/
|
||||
protected function getIndexRoute(): string
|
||||
{
|
||||
@@ -53,7 +53,7 @@ class InitiativeController extends AbstractStandardFormController
|
||||
}
|
||||
|
||||
/**
|
||||
* The initiative detail page (tabs: Details, Description, Objectives, Allocations, Audiences, Stakeholders, Tasks).
|
||||
* The program detail page (tabs: Details, Description, Objectives, Allocations, Audiences, Stakeholders, Tasks).
|
||||
*
|
||||
* Core's viewStandard() isn't used: for users who aren't administrators it checks an
|
||||
* "<entity>:export:enable" permission, which plans don't have.
|
||||
@@ -62,13 +62,13 @@ class InitiativeController extends AbstractStandardFormController
|
||||
*/
|
||||
public function viewAction(Request $request, $objectId): Response
|
||||
{
|
||||
$initiative = $this->getModel($this->getModelName())->getEntity((int) $objectId);
|
||||
$program = $this->getModel($this->getModelName())->getEntity((int) $objectId);
|
||||
|
||||
if (!$initiative instanceof Initiative) {
|
||||
return $this->notFound('mautic.program.error.notfound');
|
||||
if (!$program instanceof Program) {
|
||||
return $this->notFound('mt3s.marketing_program.error.notfound');
|
||||
}
|
||||
|
||||
if (!$this->checkActionPermission('view', $initiative)) {
|
||||
if (!$this->checkActionPermission('view', $program)) {
|
||||
return $this->accessDenied();
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ class InitiativeController extends AbstractStandardFormController
|
||||
|
||||
$taskPermissions = $this->security->isGranted(
|
||||
[
|
||||
'program:tasks:create',
|
||||
'program:tasks:editown',
|
||||
'program:tasks:editother',
|
||||
'mt3smarketingprogram:tasks:create',
|
||||
'mt3smarketingprogram:tasks:editown',
|
||||
'mt3smarketingprogram:tasks:editother',
|
||||
],
|
||||
'RETURN_ARRAY',
|
||||
null,
|
||||
@@ -99,9 +99,9 @@ class InitiativeController extends AbstractStandardFormController
|
||||
|
||||
return $this->delegateView([
|
||||
'viewParameters' => [
|
||||
'item' => $initiative,
|
||||
'item' => $program,
|
||||
'permissions' => $permissions,
|
||||
'taskTree' => $this->getTaskModel()->getTaskTree($initiative),
|
||||
'taskTree' => $this->getTaskModel()->getTaskTree($program),
|
||||
'taskPermissions' => $taskPermissions,
|
||||
// Core's page_actions helper would otherwise build mautic_plan_* route names.
|
||||
'indexRoute' => self::ROUTE_INDEX,
|
||||
@@ -110,15 +110,15 @@ class InitiativeController extends AbstractStandardFormController
|
||||
],
|
||||
'contentTemplate' => $this->getTemplateName('details.html.twig'),
|
||||
'passthroughVars' => [
|
||||
'activeLink' => '#initiative_index',
|
||||
'activeLink' => '#mt3s_marketing_program_index',
|
||||
'mauticContent' => $this->getJsLoadMethodPrefix(),
|
||||
'route' => $this->generateUrl(self::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $initiative->getId()]),
|
||||
'route' => $this->generateUrl(self::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $program->getId()]),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the initiative's task tree to the form, for the read-only Tasks tab.
|
||||
* Adds the program's task tree to the form, for the read-only Tasks tab.
|
||||
*
|
||||
* @param array<string, mixed> $args
|
||||
* @param string $action
|
||||
@@ -127,10 +127,10 @@ class InitiativeController extends AbstractStandardFormController
|
||||
*/
|
||||
protected function getViewArguments(array $args, $action): array
|
||||
{
|
||||
$initiative = $args['viewParameters']['entity'] ?? null;
|
||||
$program = $args['viewParameters']['entity'] ?? null;
|
||||
|
||||
if (in_array($action, ['new', 'edit'], true) && $initiative instanceof Initiative && null !== $initiative->getId()) {
|
||||
$args['viewParameters']['taskTree'] = $this->getTaskModel()->getTaskTree($initiative);
|
||||
if (in_array($action, ['new', 'edit'], true) && $program instanceof Program && null !== $program->getId()) {
|
||||
$args['viewParameters']['taskTree'] = $this->getTaskModel()->getTaskTree($program);
|
||||
}
|
||||
|
||||
return parent::getViewArguments($args, $action);
|
||||
@@ -138,7 +138,7 @@ class InitiativeController extends AbstractStandardFormController
|
||||
|
||||
private function getTaskModel(): TaskModel
|
||||
{
|
||||
$model = $this->getModel('program.task');
|
||||
$model = $this->getModel('mt3smp.task');
|
||||
\assert($model instanceof TaskModel);
|
||||
|
||||
return $model;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Controller;
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
|
||||
|
||||
use Mautic\CoreBundle\Controller\AbstractStandardFormController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -10,25 +10,25 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* List, create, edit and delete stakeholders (Programs > Stakeholders), the global directory, using
|
||||
* core's standard CRUD flow. Stakeholders are independent of initiatives; initiatives link to them from their
|
||||
* core's standard CRUD flow. Stakeholders are independent of programs; programs link to them from their
|
||||
* Stakeholders tab.
|
||||
*
|
||||
* Model program.stakeholder (mautic.program.model.stakeholder), permission base program:stakeholders,
|
||||
* translation base mautic.program.stakeholder.
|
||||
* Model mt3smp.stakeholder (mt3s.marketing_program.model.stakeholder), permission base mt3smarketingprogram:stakeholders,
|
||||
* translation base mt3s.marketing_program.stakeholder.
|
||||
*/
|
||||
class StakeholderController extends AbstractStandardFormController
|
||||
{
|
||||
public const ROUTE_INDEX = 'initiative_stakeholder_index';
|
||||
public const ROUTE_ACTION = 'initiative_stakeholder_action';
|
||||
public const ROUTE_INDEX = 'mt3s_marketing_program_stakeholder_index';
|
||||
public const ROUTE_ACTION = 'mt3s_marketing_program_stakeholder_action';
|
||||
|
||||
protected function getModelName(): string
|
||||
{
|
||||
return 'program.stakeholder';
|
||||
return 'mt3smp.stakeholder';
|
||||
}
|
||||
|
||||
protected function getTemplateBase(): string
|
||||
{
|
||||
return '@Program/Stakeholder';
|
||||
return '@MT3SMarketingProgram/Stakeholder';
|
||||
}
|
||||
|
||||
protected function getIndexRoute(): string
|
||||
@@ -43,7 +43,7 @@ class StakeholderController extends AbstractStandardFormController
|
||||
|
||||
protected function getJsLoadMethodPrefix(): string
|
||||
{
|
||||
return 'programStakeholder';
|
||||
return 'mt3sMpProgramStakeholder';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -2,20 +2,21 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Controller;
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
|
||||
|
||||
use Mautic\CoreBundle\Controller\CommonController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* UTM Taxonomies (Programs > UTM Taxonomies): a placeholder for now, so the menu entry has a
|
||||
* page. The content (classifying the UTM parameters of the programs' campaigns and links) comes
|
||||
* UTM Taxonomies: a placeholder page for the coming feature, kept out of the menu since
|
||||
* 0.17.0 (the route stays; the page is reachable at /s/marketing-program-utm-taxonomies).
|
||||
* The content (classifying the UTM parameters of the programs' campaigns and links) comes
|
||||
* later; until then the page shows an empty content block.
|
||||
*/
|
||||
class UtmTaxonomyController extends CommonController
|
||||
{
|
||||
public const ROUTE_INDEX = 'program_utm_taxonomy_index';
|
||||
public const ROUTE_INDEX = 'mt3s_marketing_program_utm_taxonomy_index';
|
||||
|
||||
/**
|
||||
* @param int $page
|
||||
@@ -28,10 +29,10 @@ class UtmTaxonomyController extends CommonController
|
||||
'viewParameters' => [
|
||||
'tmpl' => $tmpl,
|
||||
],
|
||||
'contentTemplate' => '@Program/UtmTaxonomy/list.html.twig',
|
||||
'contentTemplate' => '@MT3SMarketingProgram/UtmTaxonomy/list.html.twig',
|
||||
'passthroughVars' => [
|
||||
'activeLink' => '#'.self::ROUTE_INDEX,
|
||||
'mauticContent' => 'programUtmTaxonomy',
|
||||
'mauticContent' => 'mt3sMpProgramUtmTaxonomy',
|
||||
'route' => $this->generateUrl(self::ROUTE_INDEX),
|
||||
],
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user