feat(call-script): add the Call Script component (0.19.0)

A new Mautic component, listed under Components > Call Scripts (/s/call-scripts),
built like the other domains on AbstractStandardFormController/FormModel.

- CallScript (mt3s_call_scripts): name, description, category, owner, status,
the publish window shown as start/end date and time, the HTML script with
dynamic tokens kept as typed (html cleaning mask), the calling window
(weekdays, hours, sentinel in the contact's or a fixed timezone) and the retry
policy (max attempts, delay, backoff: none/linear/exponential)
- CallScriptOutcome (mt3s_call_script_outcomes, ON DELETE CASCADE): label,
data type (checkbox/radio/free text/dropdown), options JSON ({value,label})
and position; nested collections reuse the program-collection JS
- validators: ValidCallingWindow, ValidCallScriptOutcomeOptions, and an atPath
option on EndDateAfterStartDate so its violation lands on publishDown
- config: routes, the Components menu item (parent mautic.core.components),
call_script category type, model alias, call_scripts permissions, version 0.19.0
- migration Version_0_19_0 creates both tables and their FKs immediately
(users/categories SET NULL, outcomes CASCADE), idempotent
- translations en_US/fr_FR, unit tests, readme/AGENTS documentation
This commit is contained in:
alexandre_gain_mt3s committed 2026-11-21 20:58:25 +01:00
1 parent 88256ca345
commit 4fb36eebfc
33 files changed
+2537 -6

No files matched your search

+118
View File
@@ -0,0 +1,118 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
use Mautic\CoreBundle\Controller\AbstractStandardFormController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Create, edit and delete call scripts (Components > Call Scripts), using core's standard CRUD flow.
*
* Model mt3smarketingprogram.call_script (mautic.mt3smarketingprogram.model.call_script), permission base
* mt3smarketingprogram:call_scripts, translation base mt3s.call_script.
*
* Call scripts have no detail page: after Save or Cancel the user goes back to the list. They are
* never cloned (the outcomes are part of the script).
*/
class CallScriptController extends AbstractStandardFormController
{
public const ROUTE_INDEX = 'mt3s_call_script_index';
public const ROUTE_ACTION = 'mt3s_call_script_action';
protected function getModelName(): string
{
return 'mt3smarketingprogram.call_script';
}
protected function getTemplateBase(): string
{
return '@MT3SMarketingProgram/CallScript';
}
protected function getIndexRoute(): string
{
return self::ROUTE_INDEX;
}
protected function getActionRoute(): string
{
return self::ROUTE_ACTION;
}
/**
* The OnLoad JS prefix: core dispatches Mautic[getJsLoadMethodPrefix() + "OnLoad"]()
* (Mautic.mt3sMpCallScriptOnLoad in Assets/js/mt3s-mp-program.js). Without this override,
* core falls back to the model name, which nothing listens to.
*/
protected function getJsLoadMethodPrefix(): string
{
return 'mt3sMpCallScript';
}
/**
* Core would build mautic.mt3smarketingprogram.call_script; every key of the feature lives
* under mt3s.call_script.
*/
protected function getTranslationBase(): string
{
return 'mt3s.call_script';
}
/**
* @param int $page
*/
public function indexAction(Request $request, $page = 1): Response
{
return $this->indexStandard($request, $page);
}
public function newAction(Request $request): Response
{
return $this->newStandard($request);
}
/**
* @param int $objectId
* @param bool $ignorePost
*/
public function editAction(Request $request, $objectId, $ignorePost = false): Response
{
return $this->editStandard($request, $objectId, $ignorePost);
}
/**
* @param int $objectId
*/
public function deleteAction(Request $request, $objectId): Response
{
return $this->deleteStandard($request, $objectId);
}
public function batchDeleteAction(Request $request): Response
{
return $this->batchDeleteStandard($request);
}
/**
* Call scripts don't have a detail page; after Save or Cancel go back to the list.
*
* @param string $action
*/
protected function getPostActionControllerAction($action): string
{
return 'index';
}
/**
* A saved call script is never cloned: its outcomes are part of it.
*
* @param int|null $objectId
*/
public function cloneAction(Request $request, $objectId): Response
{
$this->throwAccessDenied();
}
}