Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2060818ac1 | ||
|
|
4fb36eebfc | ||
|
|
88256ca345 | ||
|
|
603e564037 | ||
|
|
d6b3488cad | ||
|
|
b138056e43 | ||
|
|
07773acb8d | ||
|
|
9d81d6c815 |
No files matched your search
@@ -6,3 +6,5 @@
|
|||||||
.claude/
|
.claude/
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
.phpunit.result/
|
.phpunit.result/
|
||||||
|
.php-cs-fixer.cache
|
||||||
|
/AGENTS.md
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Coding standards of the plugin: the same ruleset Mautic core runs
|
||||||
|
# (@Symfony + the core tweaks, see .php-cs-fixer.dist.php) and PHPStan level 6
|
||||||
|
# (see phpstan.neon). `composer install` in the plugin directory pulls
|
||||||
|
# mautic/core-lib (^7.0) so the analysis sees the real Mautic signatures.
|
||||||
|
#
|
||||||
|
# The PHPUnit suite is not run here: it needs a full Mautic installation
|
||||||
|
# (see Tests/bootstrap.php). Run it from the mautic-dev-env container:
|
||||||
|
# vendor/bin/phpunit -c docroot/plugins/MT3SMarketingProgramBundle/phpunit.xml.dist
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- lint
|
||||||
|
|
||||||
|
.default-before-script: &default-before-script
|
||||||
|
- composer install --no-interaction --no-progress --prefer-dist
|
||||||
|
|
||||||
|
php-cs-fixer:
|
||||||
|
stage: lint
|
||||||
|
image: composer:2
|
||||||
|
before_script: *default-before-script
|
||||||
|
script:
|
||||||
|
- composer cs-check
|
||||||
|
|
||||||
|
phpstan:
|
||||||
|
stage: lint
|
||||||
|
image: composer:2
|
||||||
|
before_script: *default-before-script
|
||||||
|
script:
|
||||||
|
- composer phpstan
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PHP-CS-Fixer configuration of the plugin: the same ruleset Mautic core runs
|
||||||
|
* (see its .php-cs-fixer.php), minus the custom fixer of the mautic/coding-standards
|
||||||
|
* package, which a standalone plugin repository cannot require.
|
||||||
|
*
|
||||||
|
* Check the coding style (CI runs this with --dry-run --diff):
|
||||||
|
*
|
||||||
|
* vendor/bin/php-cs-fixer fix --dry-run --diff --config=.php-cs-fixer.dist.php
|
||||||
|
*
|
||||||
|
* Fix in place:
|
||||||
|
*
|
||||||
|
* vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
$finder = (new PhpCsFixer\Finder())
|
||||||
|
->in([
|
||||||
|
__DIR__.'/Catalog',
|
||||||
|
__DIR__.'/Command',
|
||||||
|
__DIR__.'/Config',
|
||||||
|
__DIR__.'/Controller',
|
||||||
|
__DIR__.'/DependencyInjection',
|
||||||
|
__DIR__.'/Entity',
|
||||||
|
__DIR__.'/Event',
|
||||||
|
__DIR__.'/EventListener',
|
||||||
|
__DIR__.'/Form',
|
||||||
|
__DIR__.'/Integration',
|
||||||
|
__DIR__.'/Migrations',
|
||||||
|
__DIR__.'/Model',
|
||||||
|
__DIR__.'/Security',
|
||||||
|
__DIR__.'/Service',
|
||||||
|
__DIR__.'/Tests',
|
||||||
|
__DIR__.'/Twig',
|
||||||
|
__DIR__.'/Validator',
|
||||||
|
])
|
||||||
|
->append([
|
||||||
|
__DIR__.'/MT3SMarketingProgramBundle.php',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return (new PhpCsFixer\Config())
|
||||||
|
->setRules([
|
||||||
|
'@Symfony' => true,
|
||||||
|
'binary_operator_spaces' => [
|
||||||
|
'operators' => [
|
||||||
|
'=>' => 'align',
|
||||||
|
'=' => 'align',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'phpdoc_to_comment' => false,
|
||||||
|
'ordered_imports' => true,
|
||||||
|
'array_syntax' => [
|
||||||
|
'syntax' => 'short',
|
||||||
|
],
|
||||||
|
'no_unused_imports' => true,
|
||||||
|
/**
|
||||||
|
* The plugin's templates use the alternative syntax (endforeach, endif, ...)
|
||||||
|
* that Mautic's Twig templates rely on, so the rule stays off like in core.
|
||||||
|
*/
|
||||||
|
'no_alternative_syntax' => false,
|
||||||
|
'header_comment' => [
|
||||||
|
'header' => '',
|
||||||
|
],
|
||||||
|
'multiline_whitespace_before_semicolons' => true,
|
||||||
|
'nullable_type_declaration_for_default_null_value' => false, // Enforces potential BC breaks.
|
||||||
|
'no_superfluous_phpdoc_tags' => [
|
||||||
|
'allow_mixed' => true,
|
||||||
|
],
|
||||||
|
])
|
||||||
|
->setFinder($finder);
|
||||||
@@ -400,6 +400,14 @@ Mautic.mt3sMpProgramInitCollection = function ($editor) {
|
|||||||
var $row = mQuery($editor.attr('data-prototype').replace(prototypeName, nextIndex++));
|
var $row = mQuery($editor.attr('data-prototype').replace(prototypeName, nextIndex++));
|
||||||
$list.append($row);
|
$list.append($row);
|
||||||
refresh();
|
refresh();
|
||||||
|
// A new row may contain nested collections (a call script outcome's options): give them
|
||||||
|
// their own add/remove/drag handler.
|
||||||
|
$row.find('.program-collection').each(function () {
|
||||||
|
Mautic.mt3sMpProgramInitCollection(mQuery(this));
|
||||||
|
});
|
||||||
|
if (typeof Mautic.mt3sMpCallScriptInitOutcomeTypes === 'function') {
|
||||||
|
Mautic.mt3sMpCallScriptInitOutcomeTypes($row);
|
||||||
|
}
|
||||||
$row.find('select, input[type="text"], textarea').first().trigger('focus');
|
$row.find('select, input[type="text"], textarea').first().trigger('focus');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -430,6 +438,40 @@ Mautic.mt3sMpProgramInitCollection = function ($editor) {
|
|||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call Script form: show the options of an outcome only for the choice types (checkbox, radio,
|
||||||
|
* dropdown); a free text outcome has none.
|
||||||
|
*/
|
||||||
|
Mautic.mt3sMpCallScriptInitOutcomeTypes = function ($container) {
|
||||||
|
mQuery($container).find('select.program-outcome-type').each(function () {
|
||||||
|
var $select = mQuery(this);
|
||||||
|
|
||||||
|
if ($select.data('mt3sMpCallScriptTypeInitialized')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$select.data('mt3sMpCallScriptTypeInitialized', true);
|
||||||
|
|
||||||
|
var toggle = function () {
|
||||||
|
var $row = $select.closest('.program-collection-row');
|
||||||
|
$row.find('.program-outcome-options').first().toggleClass('hide', 'free_text' === $select.val());
|
||||||
|
};
|
||||||
|
|
||||||
|
$select.on('change', toggle);
|
||||||
|
toggle();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Call Script form (Components > Call Scripts): its outcomes and their nested options use the
|
||||||
|
* program collections, and the options block follows the chosen data type.
|
||||||
|
*/
|
||||||
|
Mautic.mt3sMpCallScriptOnLoad = function (container) {
|
||||||
|
mQuery(container).find('.program-collection').each(function () {
|
||||||
|
Mautic.mt3sMpProgramInitCollection(mQuery(this));
|
||||||
|
});
|
||||||
|
Mautic.mt3sMpCallScriptInitOutcomeTypes(mQuery(container));
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings > Configuration > Plan: add and remove item types (description and allocation).
|
* Settings > Configuration > Plan: add and remove item types (description and allocation).
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* UTM Manager
|
* Smart Links (the plugin's second domain)
|
||||||
*
|
*
|
||||||
* - Settings > Configuration > UTM Manager tab: delegated handlers only (the configuration
|
* - Settings > Configuration > Smart Links Settings tab: delegated handlers only (the
|
||||||
* page is loaded through Ajax). Showing / hiding the value editor by mode is done by
|
* configuration page is loaded through Ajax). Showing / hiding the value editor by
|
||||||
* Mautic's own data-show-on switcher.
|
* mode is done by Mautic's own data-show-on switcher.
|
||||||
* - Smart Link form: short link preview, "Generate" a random slug, destination URL shown
|
* - Smart Link form: short link preview, "Generate" a random slug, destination URL shown
|
||||||
* only for external redirects. Started by Mautic.smartlinksSmartLinkOnLoad(), which Mautic
|
* only for external redirects. Started by Mautic.mt3sMpSmartLinkOnLoad(), which Mautic
|
||||||
* calls after it loads any page whose mauticContent is "smartlinksSmartLink".
|
* calls after it loads any page whose mauticContent is "mt3sMpSmartLink".
|
||||||
*/
|
*/
|
||||||
(function ($) {
|
(function ($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
@@ -195,7 +195,7 @@
|
|||||||
$('#smartLinkMauticDestinationWrapper').toggleClass('hide', type !== 'mautic');
|
$('#smartLinkMauticDestinationWrapper').toggleClass('hide', type !== 'mautic');
|
||||||
};
|
};
|
||||||
|
|
||||||
Mautic.smartlinksSmartLinkOnLoad = function (container) {
|
Mautic.mt3sMpSmartLinkOnLoad = function (container) {
|
||||||
var $wrapper = $(container).find('.smart-link-slug-group').first();
|
var $wrapper = $(container).find('.smart-link-slug-group').first();
|
||||||
|
|
||||||
if ($wrapper.length) {
|
if ($wrapper.length) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ enum SmartLinkRedirectCode: int
|
|||||||
|
|
||||||
public function getLabelKey(): string
|
public function getLabelKey(): string
|
||||||
{
|
{
|
||||||
return 'mautic.smartlinks.smart_links.redirect_code.'.$this->value;
|
return 'mt3s.smart_links.smart_links.redirect_code.'.$this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPermanent(): bool
|
public function isPermanent(): bool
|
||||||
|
|||||||
@@ -7,13 +7,15 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Catalog;
|
|||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Choice labels for Smart Link redirect enums: t("mautic.smartlinks.smart_links.redirect_<x>.<value>")
|
* Choice labels for Smart Link redirect enums: t("mt3s.smart_links.smart_links.redirect_<x>.<value>")
|
||||||
* gives "301 - Moved permanently (permanent)" style labels shared by the form and the list view.
|
* gives "301 - Moved permanently (permanent)" style labels shared by the form and the list view.
|
||||||
*/
|
*/
|
||||||
trait SmartLinkRedirectEnumHelper
|
trait SmartLinkRedirectEnumHelper
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return array<int|string, string> value (as string) => label
|
* The choices of the form's redirect dropdowns and the list views: translated label => backing value.
|
||||||
|
*
|
||||||
|
* @return array<string, int|string> translated label => backing value of the enum case
|
||||||
*/
|
*/
|
||||||
public static function getChoices(TranslatorInterface $translator): array
|
public static function getChoices(TranslatorInterface $translator): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ enum SmartLinkRedirectType: string
|
|||||||
|
|
||||||
public function getLabelKey(): string
|
public function getLabelKey(): string
|
||||||
{
|
{
|
||||||
return 'mautic.smartlinks.smart_links.redirect_type.'.($this->isMautic() ? self::MAUTIC : self::EXTERNAL);
|
return 'mt3s.smart_links.smart_links.redirect_type.'.($this->isMautic() ? self::MAUTIC : self::EXTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isMautic(): bool
|
public function isMautic(): bool
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Catalog;
|
|||||||
*/
|
*/
|
||||||
final class UtmParameterDefinition
|
final class UtmParameterDefinition
|
||||||
{
|
{
|
||||||
private const TRANSLATION_PREFIX = 'mautic.smartlinks.config.parameter.';
|
private const TRANSLATION_PREFIX = 'mt3s.smart_links.config.parameter.';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string[] $suggestions Suggested values offered by the "Load suggested values" button
|
* @param string[] $suggestions Suggested values offered by the "Load suggested values" button
|
||||||
@@ -54,6 +54,6 @@ final class UtmParameterDefinition
|
|||||||
|
|
||||||
public static function getSuggestionLabelKey(string $value): string
|
public static function getSuggestionLabelKey(string $value): string
|
||||||
{
|
{
|
||||||
return 'mautic.smartlinks.config.suggestion.'.$value;
|
return 'mt3s.smart_links.config.suggestion.'.$value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ class RefreshStatsCommand extends Command
|
|||||||
|
|
||||||
$rows = [];
|
$rows = [];
|
||||||
foreach ($programs as $program) {
|
foreach ($programs as $program) {
|
||||||
$id = (string) $program->getId();
|
$id = (string) $program->getId();
|
||||||
$rows[] = [
|
$rows[] = [
|
||||||
$id,
|
$id,
|
||||||
$program->getName(),
|
$program->getName(),
|
||||||
@@ -132,4 +132,4 @@ class RefreshStatsCommand extends Command
|
|||||||
|
|
||||||
return $done;
|
return $done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+60
-43
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||||||
return [
|
return [
|
||||||
'name' => 'MT3S Marketing Program',
|
'name' => 'MT3S Marketing Program',
|
||||||
'description' => 'MT3S Marketing: programs, tasks, audiences, and smart links with their UTM taxonomies.',
|
'description' => 'MT3S Marketing: programs, tasks, audiences, and smart links with their UTM taxonomies.',
|
||||||
'version' => '0.18.0',
|
'version' => '0.19.0',
|
||||||
'author' => 'Experiential',
|
'author' => 'Experiential',
|
||||||
|
|
||||||
'routes' => [
|
'routes' => [
|
||||||
@@ -46,21 +46,31 @@ return [
|
|||||||
'path' => '/marketing-program-audiences/{objectAction}/{objectId}',
|
'path' => '/marketing-program-audiences/{objectAction}/{objectId}',
|
||||||
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\AudienceController::executeAction',
|
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\AudienceController::executeAction',
|
||||||
],
|
],
|
||||||
|
// Call Scripts component (Components > Call Scripts): the list and its object actions.
|
||||||
|
'mt3s_call_script_index' => [
|
||||||
|
'path' => '/call-scripts/{page}',
|
||||||
|
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\CallScriptController::indexAction',
|
||||||
|
],
|
||||||
|
// objectAction: new, edit, delete, batchDelete.
|
||||||
|
'mt3s_call_script_action' => [
|
||||||
|
'path' => '/call-scripts/{objectAction}/{objectId}',
|
||||||
|
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\CallScriptController::executeAction',
|
||||||
|
],
|
||||||
// Smart Links domain: the list and its object actions.
|
// Smart Links domain: the list and its object actions.
|
||||||
'mautic_smartlinks_index' => [
|
'mt3s_smart_links_index' => [
|
||||||
'path' => '/smart-links/{page}',
|
'path' => '/smart-links/{page}',
|
||||||
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\SmartLinkController::indexAction',
|
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\SmartLinkController::indexAction',
|
||||||
],
|
],
|
||||||
'mautic_smartlinks_action' => [
|
'mt3s_smart_links_action' => [
|
||||||
'path' => '/smart-links/{objectAction}/{objectId}',
|
'path' => '/smart-links/{objectAction}/{objectId}',
|
||||||
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\SmartLinkController::executeAction',
|
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\SmartLinkController::executeAction',
|
||||||
],
|
],
|
||||||
// UTM Taxonomies: the list and its object actions.
|
// UTM Taxonomies: the list and its object actions.
|
||||||
'mautic_smartlinks_taxonomies' => [
|
'mt3s_smart_links_taxonomies' => [
|
||||||
'path' => '/utm-taxonomies/{page}',
|
'path' => '/utm-taxonomies/{page}',
|
||||||
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\UtmTaxonomyController::indexAction',
|
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\UtmTaxonomyController::indexAction',
|
||||||
],
|
],
|
||||||
'mautic_smartlinks_taxonomy_action' => [
|
'mt3s_smart_links_taxonomy_action' => [
|
||||||
'path' => '/utm-taxonomies/{objectAction}/{objectId}',
|
'path' => '/utm-taxonomies/{objectAction}/{objectId}',
|
||||||
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\UtmTaxonomyController::executeAction',
|
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\UtmTaxonomyController::executeAction',
|
||||||
],
|
],
|
||||||
@@ -74,20 +84,21 @@ return [
|
|||||||
// https://{short_link_domain}/l/{slug}: the public entry point of the Smart Links.
|
// https://{short_link_domain}/l/{slug}: the public entry point of the Smart Links.
|
||||||
// Public routes are served without the /s/ prefix and without authentication.
|
// Public routes are served without the /s/ prefix and without authentication.
|
||||||
'public' => [
|
'public' => [
|
||||||
'mautic_smartlinks_go' => [
|
'mt3s_smart_links_go' => [
|
||||||
'path' => '/l/{slug}',
|
'path' => '/l/{slug}',
|
||||||
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\PublicController::goAction',
|
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\PublicController::goAction',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
// Top-level "Programs" menu. Future program objects go in its children, after Programs.
|
// Top-level "Marketing Programs" menu. Future program objects go in its children, after
|
||||||
|
// Programs; the Smart Links domain's pages (UTM Taxonomies, Smart Links) close the menu.
|
||||||
'menu' => [
|
'menu' => [
|
||||||
'main' => [
|
'main' => [
|
||||||
'mt3s.marketing_program.menu.root' => [
|
'mt3s.marketing_program.menu.root' => [
|
||||||
'id' => 'mt3s_marketing_program_root',
|
'id' => 'mt3s_marketing_program_root',
|
||||||
'iconClass' => 'ri-calendar-line',
|
'iconClass' => 'ri-calendar-line',
|
||||||
'access' => ['mt3smarketingprogram:programs:viewown', 'mt3smarketingprogram:programs:viewother', 'mt3smarketingprogram:tasks:viewown', 'mt3smarketingprogram:tasks:viewother', 'mt3smarketingprogram:stakeholders:viewown', 'mt3smarketingprogram:stakeholders:viewother', 'mt3smarketingprogram:audiences:viewown', 'mt3smarketingprogram:audiences:viewother', 'mt3smarketingprogram:itemtypes:view'],
|
'access' => ['mt3smarketingprogram:programs:viewown', 'mt3smarketingprogram:programs:viewother', 'mt3smarketingprogram:tasks:viewown', 'mt3smarketingprogram:tasks:viewother', 'mt3smarketingprogram:stakeholders:viewown', 'mt3smarketingprogram:stakeholders:viewother', 'mt3smarketingprogram:audiences:viewown', 'mt3smarketingprogram:audiences:viewother', 'mt3smarketingprogram:itemtypes:view', 'mt3smarketingprogram:smart_links:viewown', 'mt3smarketingprogram:smart_links:viewother', 'mt3smarketingprogram:taxonomies:viewown', 'mt3smarketingprogram:taxonomies:viewother'],
|
||||||
'priority' => 5,
|
'priority' => 5,
|
||||||
'children' => [
|
'children' => [
|
||||||
'mt3s.marketing_program.menu.index' => [
|
'mt3s.marketing_program.menu.index' => [
|
||||||
@@ -120,39 +131,34 @@ return [
|
|||||||
'access' => ['mt3smarketingprogram:itemtypes:view'],
|
'access' => ['mt3smarketingprogram:itemtypes:view'],
|
||||||
'priority' => 55,
|
'priority' => 55,
|
||||||
],
|
],
|
||||||
|
// The Smart Links domain (UTM taxonomies, then the links) closes the menu, in
|
||||||
|
// that order. It is no longer a top-level group of its own.
|
||||||
|
'mt3s.smart_links.menu.taxonomies' => [
|
||||||
|
'id' => 'mt3s_smart_links_taxonomies',
|
||||||
|
'route' => 'mt3s_smart_links_taxonomies',
|
||||||
|
'iconClass' => 'ri-price-tag-3-line',
|
||||||
|
'access' => ['mt3smarketingprogram:taxonomies:viewown', 'mt3smarketingprogram:taxonomies:viewother'],
|
||||||
|
'priority' => 50,
|
||||||
|
],
|
||||||
|
'mt3s.smart_links.menu.smartlinks' => [
|
||||||
|
'id' => 'mt3s_smart_links_index',
|
||||||
|
'route' => 'mt3s_smart_links_index',
|
||||||
|
'iconClass' => 'ri-link',
|
||||||
|
'access' => ['mt3smarketingprogram:smart_links:viewown', 'mt3smarketingprogram:smart_links:viewother'],
|
||||||
|
'priority' => 45,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
// Top-level "Smart Links" menu: UTM Taxonomies above the Smart Links list. The two
|
// The Call Script component: a flat item attached to core's Components menu. The
|
||||||
// domains (Marketing Program and Smart Links) stay separate menu groups.
|
// "parent" key hands it to Mautic's orphan mechanism, which places it in that group;
|
||||||
'mautic.smartlinks.menu.root' => [
|
// the key itself is the translation key of the label.
|
||||||
'id' => 'mautic_smartlinks',
|
'mt3s.call_script.menu.index' => [
|
||||||
'route' => 'mautic_smartlinks_index',
|
'route' => 'mt3s_call_script_index',
|
||||||
'iconClass' => 'ri-links-line',
|
'access' => ['mt3smarketingprogram:call_scripts:viewown', 'mt3smarketingprogram:call_scripts:viewother'],
|
||||||
'access' => [
|
'parent' => 'mautic.core.components',
|
||||||
'mt3smarketingprogram:smart_links:viewown',
|
'priority' => 80,
|
||||||
'mt3smarketingprogram:smart_links:viewother',
|
|
||||||
'mt3smarketingprogram:taxonomies:viewown',
|
|
||||||
'mt3smarketingprogram:taxonomies:viewother',
|
|
||||||
],
|
|
||||||
'priority' => 4,
|
|
||||||
'children' => [
|
|
||||||
'mautic.smartlinks.menu.taxonomies' => [
|
|
||||||
'id' => 'mautic_smartlinks_taxonomies',
|
|
||||||
'route' => 'mautic_smartlinks_taxonomies',
|
|
||||||
'iconClass' => 'ri-price-tag-3-line',
|
|
||||||
'access' => ['mt3smarketingprogram:taxonomies:viewown', 'mt3smarketingprogram:taxonomies:viewother'],
|
|
||||||
'priority' => 5,
|
|
||||||
],
|
],
|
||||||
'mautic.smartlinks.menu.smartlinks' => [
|
|
||||||
'id' => 'mautic_smartlinks_index',
|
|
||||||
'route' => 'mautic_smartlinks_index',
|
|
||||||
'iconClass' => 'ri-link',
|
|
||||||
'access' => ['mt3smarketingprogram:smart_links:viewown', 'mt3smarketingprogram:smart_links:viewother'],
|
|
||||||
'priority' => 4,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -179,7 +185,7 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
'mt3s.smart_links.integration.configuration' => [
|
'mt3s.smart_links.integration.configuration' => [
|
||||||
'class' => MauticPlugin\MT3SMarketingProgramBundle\Integration\Support\ConfigSupport::class,
|
'class' => MauticPlugin\MT3SMarketingProgramBundle\Integration\Support\SmartlinksConfigSupport::class,
|
||||||
'tags' => [
|
'tags' => [
|
||||||
'mautic.config_integration',
|
'mautic.config_integration',
|
||||||
],
|
],
|
||||||
@@ -187,12 +193,17 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
// Registers "program" as a category type (Settings > Categories), used by Program::$category.
|
// Registers "program" as a category type (Settings > Categories), used by Program::$category,
|
||||||
|
// and "call_script" for the Call Script component.
|
||||||
'categories' => [
|
'categories' => [
|
||||||
'program' => [
|
'program' => [
|
||||||
'class' => MauticPlugin\MT3SMarketingProgramBundle\Entity\Program::class,
|
'class' => MauticPlugin\MT3SMarketingProgramBundle\Entity\Program::class,
|
||||||
'label' => 'mt3s.marketing_program.category.type',
|
'label' => 'mt3s.marketing_program.category.type',
|
||||||
],
|
],
|
||||||
|
'call_script' => [
|
||||||
|
'class' => MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScript::class,
|
||||||
|
'label' => 'mt3s.call_script.category.type',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
'parameters' => [
|
'parameters' => [
|
||||||
@@ -237,13 +248,19 @@ return [
|
|||||||
// Stored by Settings > Configuration > Smart Links Settings (SmartLinksConfigSubscriber).
|
// Stored by Settings > Configuration > Smart Links Settings (SmartLinksConfigSubscriber).
|
||||||
// Read through UtmConfigurationProvider; the default stays empty, the catalog
|
// Read through UtmConfigurationProvider; the default stays empty, the catalog
|
||||||
// defaults are applied by UtmConfigurationNormalizer.
|
// defaults are applied by UtmConfigurationNormalizer.
|
||||||
|
'mt3s_smart_links_utm_config' => [],
|
||||||
|
'mt3s_smart_links_config' => [
|
||||||
|
'short_link_domain' => '',
|
||||||
|
],
|
||||||
|
// Legacy keys of the earlier eras. Declared so the read fallbacks
|
||||||
|
// (UtmConfigurationProvider, SmartLinkModel, SmartLinkShortUrlBuilder) can serve
|
||||||
|
// upgrades from local.php until the settings are saved again; new values are
|
||||||
|
// always written to the new keys: `smartlinks_*` (the standalone
|
||||||
|
// SmartlinksBundle, 0.1.0–0.18.0) and `utm_manager_*` (the UtmManagerBundle, < 0.5.0).
|
||||||
'smartlinks_utm_config' => [],
|
'smartlinks_utm_config' => [],
|
||||||
'smartlinks_config' => [
|
'smartlinks_config' => [
|
||||||
'short_link_domain' => '',
|
'short_link_domain' => '',
|
||||||
],
|
],
|
||||||
// Legacy keys of the standalone Smartlinks plugin era (< 0.18.0). Declared so the
|
|
||||||
// read fallbacks can serve upgrades from local.php until the settings are saved
|
|
||||||
// again; new values are always written to the new keys.
|
|
||||||
'utm_manager_config' => [],
|
'utm_manager_config' => [],
|
||||||
'utm_manager_smart_links' => [
|
'utm_manager_smart_links' => [
|
||||||
'short_link_domain' => '',
|
'short_link_domain' => '',
|
||||||
|
|||||||
+10
-17
@@ -25,21 +25,14 @@ return function (ContainerConfigurator $configurator): void {
|
|||||||
$services->load('MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\', '../Entity/*Repository.php')
|
$services->load('MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\', '../Entity/*Repository.php')
|
||||||
->tag(Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG);
|
->tag(Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG);
|
||||||
|
|
||||||
// Lets core resolve the model with getModel('mt3smp.program').
|
// Core resolves getModel('mt3smarketingprogram.<entity>') to mautic.mt3smarketingprogram.model.<entity>:
|
||||||
$services->alias('mt3s.marketing_program.model.program', MauticPlugin\MT3SMarketingProgramBundle\Model\ProgramModel::class);
|
// exactly one alias per model, under the bundle's canonical prefix.
|
||||||
$services->alias('mautic.mt3smp.model.program', MauticPlugin\MT3SMarketingProgramBundle\Model\ProgramModel::class);
|
$services->alias('mautic.mt3smarketingprogram.model.program', MauticPlugin\MT3SMarketingProgramBundle\Model\ProgramModel::class);
|
||||||
// getModel('mt3smp.task').
|
$services->alias('mautic.mt3smarketingprogram.model.task', MauticPlugin\MT3SMarketingProgramBundle\Model\TaskModel::class);
|
||||||
$services->alias('mt3s.marketing_program.model.task', MauticPlugin\MT3SMarketingProgramBundle\Model\TaskModel::class);
|
$services->alias('mautic.mt3smarketingprogram.model.call_script', MauticPlugin\MT3SMarketingProgramBundle\Model\CallScriptModel::class);
|
||||||
$services->alias('mautic.mt3smp.model.task', MauticPlugin\MT3SMarketingProgramBundle\Model\TaskModel::class);
|
$services->alias('mautic.mt3smarketingprogram.model.stakeholder', MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel::class);
|
||||||
// getModel('mt3smp.stakeholder').
|
$services->alias('mautic.mt3smarketingprogram.model.audience', MauticPlugin\MT3SMarketingProgramBundle\Model\AudienceModel::class);
|
||||||
$services->alias('mt3s.marketing_program.model.stakeholder', MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel::class);
|
// Smart Links domain: getModel('mt3smarketingprogram.smart_link') / getModel('mt3smarketingprogram.utm_taxonomy').
|
||||||
$services->alias('mautic.mt3smp.model.stakeholder', MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel::class);
|
$services->alias('mautic.mt3smarketingprogram.model.smart_link', MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel::class);
|
||||||
// getModel('mt3smp.audience').
|
$services->alias('mautic.mt3smarketingprogram.model.utm_taxonomy', MauticPlugin\MT3SMarketingProgramBundle\Model\UtmTaxonomyModel::class);
|
||||||
$services->alias('mt3s.marketing_program.model.audience', MauticPlugin\MT3SMarketingProgramBundle\Model\AudienceModel::class);
|
|
||||||
// Smart Links domain: getModel('smartlinks.smart_link') / getModel('smartlinks.utm_taxonomy').
|
|
||||||
$services->alias('mt3s.smart_links.model.smart_link', MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel::class);
|
|
||||||
$services->alias('mautic.smartlinks.model.smart_link', MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel::class);
|
|
||||||
$services->alias('mt3s.smart_links.model.utm_taxonomy', MauticPlugin\MT3SMarketingProgramBundle\Model\UtmTaxonomyModel::class);
|
|
||||||
$services->alias('mautic.smartlinks.model.utm_taxonomy', MauticPlugin\MT3SMarketingProgramBundle\Model\UtmTaxonomyModel::class);
|
|
||||||
$services->alias('mautic.mt3smp.model.audience', MauticPlugin\MT3SMarketingProgramBundle\Model\AudienceModel::class);
|
|
||||||
};
|
};
|
||||||
@@ -14,7 +14,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
* link to them from their Audiences tab (ProgramAudience carries the audience's priority in that
|
* link to them from their Audiences tab (ProgramAudience carries the audience's priority in that
|
||||||
* program).
|
* program).
|
||||||
*
|
*
|
||||||
* Model mt3smp.audience (mt3s.marketing_program.model.audience), permission base mt3smarketingprogram:audiences, translation
|
* Model mt3smarketingprogram.audience (mautic.mt3smarketingprogram.model.audience), permission base mt3smarketingprogram:audiences, translation
|
||||||
* base mt3s.marketing_program.audience.
|
* base mt3s.marketing_program.audience.
|
||||||
*/
|
*/
|
||||||
class AudienceController extends AbstractStandardFormController
|
class AudienceController extends AbstractStandardFormController
|
||||||
@@ -24,7 +24,7 @@ class AudienceController extends AbstractStandardFormController
|
|||||||
|
|
||||||
protected function getModelName(): string
|
protected function getModelName(): string
|
||||||
{
|
{
|
||||||
return 'mt3smp.audience';
|
return 'mt3smarketingprogram.audience';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTemplateBase(): string
|
protected function getTemplateBase(): string
|
||||||
@@ -93,4 +93,4 @@ class AudienceController extends AbstractStandardFormController
|
|||||||
{
|
{
|
||||||
return $this->batchDeleteStandard($request);
|
return $this->batchDeleteStandard($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -115,4 +115,4 @@ class ItemTypesController extends AbstractFormController
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,10 +11,11 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List, view, create, edit and delete plans, using core's standard CRUD flow.
|
* List, view, create, edit and delete marketing programs, using core's standard CRUD flow.
|
||||||
*
|
*
|
||||||
* Core derives most names from the model name "program": model mt3s.marketing_program.model.program, permission base
|
* Core derives the model alias and the permission base from the model name
|
||||||
* mt3smarketingprogram:programs (from ProgramModel), translation base mt3s.marketing_program, session base mt3s.marketing_program.
|
* "mt3smarketingprogram.program": model mautic.mt3smarketingprogram.model.program, permission
|
||||||
|
* base mt3smarketingprogram:programs (from ProgramModel). The views translate under mt3s.marketing_program.*.
|
||||||
*/
|
*/
|
||||||
class ProgramController extends AbstractStandardFormController
|
class ProgramController extends AbstractStandardFormController
|
||||||
{
|
{
|
||||||
@@ -23,7 +24,7 @@ class ProgramController extends AbstractStandardFormController
|
|||||||
|
|
||||||
protected function getModelName(): string
|
protected function getModelName(): string
|
||||||
{
|
{
|
||||||
return 'mt3smp.program';
|
return 'mt3smarketingprogram.program';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTemplateBase(): string
|
protected function getTemplateBase(): string
|
||||||
@@ -47,7 +48,7 @@ class ProgramController extends AbstractStandardFormController
|
|||||||
/**
|
/**
|
||||||
* The OnLoad JS prefix: core dispatches Mautic[getJsLoadMethodPrefix() + "OnLoad"]()
|
* The OnLoad JS prefix: core dispatches Mautic[getJsLoadMethodPrefix() + "OnLoad"]()
|
||||||
* (mt3sMpProgramOnLoad in Assets/js/mt3s-mp-program.js). Without this override, core
|
* (mt3sMpProgramOnLoad in Assets/js/mt3s-mp-program.js). Without this override, core
|
||||||
* falls back to the model name ("mt3smp.program"), which nothing listens to.
|
* falls back to the model name ("mt3smarketingprogram.program"), which nothing listens to.
|
||||||
*/
|
*/
|
||||||
protected function getJsLoadMethodPrefix(): string
|
protected function getJsLoadMethodPrefix(): string
|
||||||
{
|
{
|
||||||
@@ -79,7 +80,7 @@ class ProgramController extends AbstractStandardFormController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->checkActionPermission('view', $program)) {
|
if (!$this->checkActionPermission('view', $program)) {
|
||||||
return $this->accessDenied();
|
$this->throwAccessDenied();
|
||||||
}
|
}
|
||||||
|
|
||||||
$base = $this->getPermissionBase();
|
$base = $this->getPermissionBase();
|
||||||
@@ -148,7 +149,7 @@ class ProgramController extends AbstractStandardFormController
|
|||||||
|
|
||||||
private function getTaskModel(): TaskModel
|
private function getTaskModel(): TaskModel
|
||||||
{
|
{
|
||||||
$model = $this->getModel('mt3smp.task');
|
$model = $this->getModel('mt3smarketingprogram.task');
|
||||||
\assert($model instanceof TaskModel);
|
\assert($model instanceof TaskModel);
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
|
|||||||
@@ -4,13 +4,21 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
|
||||||
|
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
use Mautic\CoreBundle\Controller\CommonController;
|
use Mautic\CoreBundle\Controller\CommonController;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink;
|
use Mautic\CoreBundle\Factory\ModelFactory;
|
||||||
|
use Mautic\CoreBundle\Helper\CoreParametersHelper;
|
||||||
|
use Mautic\CoreBundle\Helper\UserHelper;
|
||||||
|
use Mautic\CoreBundle\Security\Permissions\CorePermissions;
|
||||||
|
use Mautic\CoreBundle\Service\FlashBag;
|
||||||
|
use Mautic\CoreBundle\Translation\Translator;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel;
|
use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Contracts\Service\Attribute\Required;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The public side of the Smart Links: https://{short_link_domain}/l/{slug}.
|
* The public side of the Smart Links: https://{short_link_domain}/l/{slug}.
|
||||||
@@ -24,12 +32,20 @@ use Symfony\Contracts\Service\Attribute\Required;
|
|||||||
*/
|
*/
|
||||||
class PublicController extends CommonController
|
class PublicController extends CommonController
|
||||||
{
|
{
|
||||||
private SmartLinkModel $smartLinkModel;
|
public function __construct(
|
||||||
|
private readonly SmartLinkModel $smartLinkModel,
|
||||||
#[Required]
|
private readonly LoggerInterface $logger,
|
||||||
public function autowirePublicController(SmartLinkModel $smartLinkModel): void
|
ManagerRegistry $doctrine,
|
||||||
{
|
ModelFactory $modelFactory,
|
||||||
$this->smartLinkModel = $smartLinkModel;
|
UserHelper $userHelper,
|
||||||
|
CoreParametersHelper $coreParametersHelper,
|
||||||
|
EventDispatcherInterface $dispatcher,
|
||||||
|
Translator $translator,
|
||||||
|
FlashBag $flashBag,
|
||||||
|
RequestStack $requestStack,
|
||||||
|
CorePermissions $security,
|
||||||
|
) {
|
||||||
|
parent::__construct($doctrine, $modelFactory, $userHelper, $coreParametersHelper, $dispatcher, $translator, $flashBag, $requestStack, $security);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function goAction(Request $request, string $slug): Response
|
public function goAction(Request $request, string $slug): Response
|
||||||
@@ -64,7 +80,14 @@ class PublicController extends CommonController
|
|||||||
$this->smartLinkModel->recordHit($link, $request);
|
$this->smartLinkModel->recordHit($link, $request);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
// Statistics must never block the redirect.
|
// Statistics must never block the redirect.
|
||||||
error_log('Smart Link hit could not be recorded for slug "'.$slug.'": '.$e->getMessage().' in '.$e->getFile().':'.$e->getLine());
|
$this->logger->error(
|
||||||
|
'Smart Link hit could not be recorded for slug "{slug}": {message}',
|
||||||
|
[
|
||||||
|
'slug' => $slug,
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'exception' => $e,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RedirectResponse($this->smartLinkModel->buildRedirectUrl($link), $link->getRedirectCode()->value);
|
return new RedirectResponse($this->smartLinkModel->buildRedirectUrl($link), $link->getRedirectCode()->value);
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
/**
|
/**
|
||||||
* Create, edit and delete Smart Links (main menu > Smart Links), using core's standard CRUD flow.
|
* Create, edit and delete Smart Links (main menu > Smart Links), using core's standard CRUD flow.
|
||||||
*
|
*
|
||||||
* Model smartlinks.smart_link (mautic.smartlinks.model.smart_link), permission base
|
* Model mt3smarketingprogram.smart_link (mautic.mt3smarketingprogram.model.smart_link), permission base
|
||||||
* smartlinks:smart_links, translation base mautic.smartlinks.smart_links.
|
* mt3smarketingprogram:smart_links, translation base mt3s.smart_links.smart_links.
|
||||||
*
|
*
|
||||||
* The slug of a saved link is immutable: the form disables the field, the model refuses another
|
* The slug of a saved link is immutable: the form disables the field, the model refuses another
|
||||||
* slug, and this controller drops the submitted value (nothing to re-check). There is no clone:
|
* slug, and this controller drops the submitted value (nothing to re-check). There is no clone:
|
||||||
@@ -23,12 +23,12 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
*/
|
*/
|
||||||
class SmartLinkController extends AbstractStandardFormController
|
class SmartLinkController extends AbstractStandardFormController
|
||||||
{
|
{
|
||||||
public const ROUTE_INDEX = 'mautic_smartlinks_index';
|
public const ROUTE_INDEX = 'mt3s_smart_links_index';
|
||||||
public const ROUTE_ACTION = 'mautic_smartlinks_action';
|
public const ROUTE_ACTION = 'mt3s_smart_links_action';
|
||||||
|
|
||||||
protected function getModelName(): string
|
protected function getModelName(): string
|
||||||
{
|
{
|
||||||
return 'smartlinks.smart_link';
|
return 'mt3smarketingprogram.smart_link';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTemplateBase(): string
|
protected function getTemplateBase(): string
|
||||||
@@ -47,20 +47,22 @@ class SmartLinkController extends AbstractStandardFormController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core builds mautic_smartlinkssmartlink from the model name; the JS loader relies on this prefix.
|
* The OnLoad JS prefix: core dispatches Mautic[getJsLoadMethodPrefix() + "OnLoad"]()
|
||||||
|
* (Mautic.mt3sMpSmartLinkOnLoad in Assets/js/mt3s-mp-smartlinks.js). Without this
|
||||||
|
* override, core falls back to the model name, which nothing listens to.
|
||||||
*/
|
*/
|
||||||
protected function getJsLoadMethodPrefix(): string
|
protected function getJsLoadMethodPrefix(): string
|
||||||
{
|
{
|
||||||
return 'smartlinksSmartLink';
|
return 'mt3sMpSmartLink';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core builds mautic.<model name> (singular smart_link); every key of the feature lives
|
* Core builds mautic.<model name> (singular smart_link); every key of the feature lives
|
||||||
* under mautic.smartlinks.smart_links.
|
* under mt3s.smart_links.smart_links.
|
||||||
*/
|
*/
|
||||||
protected function getTranslationBase(): string
|
protected function getTranslationBase(): string
|
||||||
{
|
{
|
||||||
return 'mautic.smartlinks.smart_links';
|
return 'mt3s.smart_links.smart_links';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,13 +103,18 @@ class SmartLinkController extends AbstractStandardFormController
|
|||||||
/**
|
/**
|
||||||
* Never save the slug of an existing link: it is immutable once created. The field is
|
* Never save the slug of an existing link: it is immutable once created. The field is
|
||||||
* disabled in the form, so nothing is submitted for it, this is a safety net.
|
* disabled in the form, so nothing is submitted for it, this is a safety net.
|
||||||
|
*
|
||||||
|
* @param SmartLink $entity
|
||||||
|
* @param string $action
|
||||||
|
* @param int|null $objectId
|
||||||
|
* @param bool $isClone
|
||||||
*/
|
*/
|
||||||
protected function beforeEntitySave($entity, Form $form, $action, $objectId = null, $isClone = false): bool
|
protected function beforeEntitySave($entity, Form $form, $action, $objectId = null, $isClone = false): bool
|
||||||
{
|
{
|
||||||
if ($entity instanceof SmartLink && null !== $entity->getId()) {
|
if ($entity instanceof SmartLink && null !== $entity->getId()) {
|
||||||
$formSlug = $form->has('slug') ? (string) $form->get('slug')->getData() : '';
|
$formSlug = $form->has('slug') ? (string) $form->get('slug')->getData() : '';
|
||||||
if ('' !== $formSlug && $formSlug !== (string) $entity->getSlug()) {
|
if ('' !== $formSlug && $formSlug !== (string) $entity->getSlug()) {
|
||||||
$this->addFlashMessage('mautic.smartlinks.smart_links.error.slug_immutable', ['%slug%' => $formSlug], \Mautic\CoreBundle\FlashBag::LEVEL_ERROR);
|
$this->addFlashMessage('mt3s.smart_links.smart_links.error.slug_immutable', ['%slug%' => $formSlug], \Mautic\CoreBundle\Service\FlashBag::LEVEL_ERROR);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -121,6 +128,7 @@ class SmartLinkController extends AbstractStandardFormController
|
|||||||
* also displayed above the form of a link), and the number of hits of each link.
|
* also displayed above the form of a link), and the number of hits of each link.
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $args
|
* @param array<string, mixed> $args
|
||||||
|
* @param string $action
|
||||||
*
|
*
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
@@ -132,7 +140,7 @@ class SmartLinkController extends AbstractStandardFormController
|
|||||||
$model = $this->getModel($this->getModelName());
|
$model = $this->getModel($this->getModelName());
|
||||||
\assert($model instanceof SmartLinkModel);
|
\assert($model instanceof SmartLinkModel);
|
||||||
|
|
||||||
$args['viewParameters']['shortLinkDomain'] = $model->getShortLinkDomain();
|
$args['viewParameters']['shortLinkDomain'] = $model->getShortLinkDomain();
|
||||||
$args['viewParameters']['hitCounts'] = $model->getHitCounts();
|
$args['viewParameters']['hitCounts'] = $model->getHitCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,6 +157,8 @@ class SmartLinkController extends AbstractStandardFormController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Smart Links don't have a detail page; after Save or Cancel go back to the list.
|
* Smart Links don't have a detail page; after Save or Cancel go back to the list.
|
||||||
|
*
|
||||||
|
* @param string $action
|
||||||
*/
|
*/
|
||||||
protected function getPostActionControllerAction($action): string
|
protected function getPostActionControllerAction($action): string
|
||||||
{
|
{
|
||||||
@@ -157,9 +167,11 @@ class SmartLinkController extends AbstractStandardFormController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A saved Smart Link is never cloned: its slug is immutable, and a clone would need a new one.
|
* A saved Smart Link is never cloned: its slug is immutable, and a clone would need a new one.
|
||||||
|
*
|
||||||
|
* @param int|null $objectId
|
||||||
*/
|
*/
|
||||||
public function cloneAction(Request $request, $objectId): Response
|
public function cloneAction(Request $request, $objectId): Response
|
||||||
{
|
{
|
||||||
$this->accessDenied();
|
$this->throwAccessDenied();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
* core's standard CRUD flow. Stakeholders are independent of programs; programs link to them from their
|
* core's standard CRUD flow. Stakeholders are independent of programs; programs link to them from their
|
||||||
* Stakeholders tab.
|
* Stakeholders tab.
|
||||||
*
|
*
|
||||||
* Model mt3smp.stakeholder (mt3s.marketing_program.model.stakeholder), permission base mt3smarketingprogram:stakeholders,
|
* Model mt3smarketingprogram.stakeholder (mautic.mt3smarketingprogram.model.stakeholder), permission base mt3smarketingprogram:stakeholders,
|
||||||
* translation base mt3s.marketing_program.stakeholder.
|
* translation base mt3s.marketing_program.stakeholder.
|
||||||
*/
|
*/
|
||||||
class StakeholderController extends AbstractStandardFormController
|
class StakeholderController extends AbstractStandardFormController
|
||||||
@@ -23,7 +23,7 @@ class StakeholderController extends AbstractStandardFormController
|
|||||||
|
|
||||||
protected function getModelName(): string
|
protected function getModelName(): string
|
||||||
{
|
{
|
||||||
return 'mt3smp.stakeholder';
|
return 'mt3smarketingprogram.stakeholder';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTemplateBase(): string
|
protected function getTemplateBase(): string
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
/**
|
/**
|
||||||
* List, create, edit and delete tasks (Programs > Tasks), using core's standard CRUD flow.
|
* List, create, edit and delete tasks (Programs > Tasks), using core's standard CRUD flow.
|
||||||
*
|
*
|
||||||
* Model mt3smp.task (mt3s.marketing_program.model.task), permission base mt3smarketingprogram:tasks, translation base mt3s.marketing_program.task.
|
* Model mt3smarketingprogram.task (mautic.mt3smarketingprogram.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:
|
* 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 Programs > Tasks: back to the task list (core's default);
|
||||||
@@ -51,7 +51,7 @@ class TaskController extends AbstractStandardFormController
|
|||||||
|
|
||||||
protected function getModelName(): string
|
protected function getModelName(): string
|
||||||
{
|
{
|
||||||
return 'mt3smp.task';
|
return 'mt3smarketingprogram.task';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTemplateBase(): string
|
protected function getTemplateBase(): string
|
||||||
@@ -97,7 +97,7 @@ class TaskController extends AbstractStandardFormController
|
|||||||
*/
|
*/
|
||||||
public function editAction(Request $request, $objectId, $ignorePost = false): Response
|
public function editAction(Request $request, $objectId, $ignorePost = false): Response
|
||||||
{
|
{
|
||||||
$task = $this->getModel($this->getModelName())->getEntity((int) $objectId);
|
$task = $this->getModel($this->getModelName())->getEntity((int) $objectId);
|
||||||
$programId = $task instanceof Task ? $task->getProgram()?->getId() : null;
|
$programId = $task instanceof Task ? $task->getProgram()?->getId() : null;
|
||||||
$this->returnProgramId = $this->resolveReturnProgram($request, (string) (int) $objectId, $programId);
|
$this->returnProgramId = $this->resolveReturnProgram($request, (string) (int) $objectId, $programId);
|
||||||
|
|
||||||
@@ -137,6 +137,10 @@ class TaskController extends AbstractStandardFormController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param string $action
|
||||||
|
* @param int|null $objectId
|
||||||
|
* @param bool $isClone
|
||||||
|
*
|
||||||
* @return object|null
|
* @return object|null
|
||||||
*/
|
*/
|
||||||
protected function getFormEntity($action, &$objectId = null, &$isClone = false)
|
protected function getFormEntity($action, &$objectId = null, &$isClone = false)
|
||||||
@@ -144,7 +148,7 @@ class TaskController extends AbstractStandardFormController
|
|||||||
$entity = parent::getFormEntity($action, $objectId, $isClone);
|
$entity = parent::getFormEntity($action, $objectId, $isClone);
|
||||||
|
|
||||||
if ('new' === $action && $entity instanceof Task && null === $entity->getProgram() && null !== $this->preselectedProgramId) {
|
if ('new' === $action && $entity instanceof Task && null === $entity->getProgram() && null !== $this->preselectedProgramId) {
|
||||||
$program = $this->getModel('mt3smp.program')->getEntity($this->preselectedProgramId);
|
$program = $this->getModel('mt3smarketingprogram.program')->getEntity($this->preselectedProgramId);
|
||||||
if ($program instanceof Program) {
|
if ($program instanceof Program) {
|
||||||
$entity->setProgram($program);
|
$entity->setProgram($program);
|
||||||
}
|
}
|
||||||
@@ -153,6 +157,13 @@ class TaskController extends AbstractStandardFormController
|
|||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Task $entity
|
||||||
|
* @param string $action
|
||||||
|
* @param mixed $pass
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
protected function afterEntitySave($entity, Form $form, $action, $pass = null)
|
protected function afterEntitySave($entity, Form $form, $action, $pass = null)
|
||||||
{
|
{
|
||||||
if ($entity instanceof Task) {
|
if ($entity instanceof Task) {
|
||||||
@@ -167,6 +178,7 @@ class TaskController extends AbstractStandardFormController
|
|||||||
* was moved to another program, go to its new program. Otherwise keep core's default: the task list.
|
* was moved to another program, go to its new program. Otherwise keep core's default: the task list.
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $args
|
* @param array<string, mixed> $args
|
||||||
|
* @param string $action
|
||||||
*
|
*
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,20 +12,20 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
* Create, edit and delete UTM Taxonomies (Smart Links > UTM Taxonomies), using core's standard
|
* Create, edit and delete UTM Taxonomies (Smart Links > UTM Taxonomies), using core's standard
|
||||||
* CRUD flow.
|
* CRUD flow.
|
||||||
*
|
*
|
||||||
* Model smartlinks.utm_taxonomy (mautic.smartlinks.model.utm_taxonomy), permission base
|
* Model mt3smarketingprogram.utm_taxonomy (mautic.mt3smarketingprogram.model.utm_taxonomy), permission base
|
||||||
* smartlinks:taxonomies, translation base mautic.smartlinks.taxonomies.
|
* mt3smarketingprogram:taxonomies, translation base mt3s.smart_links.taxonomies.
|
||||||
*
|
*
|
||||||
* A taxonomy is never cloned: its name is unique, and a clone would collide immediately. A new
|
* A taxonomy is never cloned: its name is unique, and a clone would collide immediately. A new
|
||||||
* taxonomy is created from scratch.
|
* taxonomy is created from scratch.
|
||||||
*/
|
*/
|
||||||
class UtmTaxonomyController extends AbstractStandardFormController
|
class UtmTaxonomyController extends AbstractStandardFormController
|
||||||
{
|
{
|
||||||
public const ROUTE_INDEX = 'mautic_smartlinks_taxonomies';
|
public const ROUTE_INDEX = 'mt3s_smart_links_taxonomies';
|
||||||
public const ROUTE_ACTION = 'mautic_smartlinks_taxonomy_action';
|
public const ROUTE_ACTION = 'mt3s_smart_links_taxonomy_action';
|
||||||
|
|
||||||
protected function getModelName(): string
|
protected function getModelName(): string
|
||||||
{
|
{
|
||||||
return 'smartlinks.utm_taxonomy';
|
return 'mt3smarketingprogram.utm_taxonomy';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTemplateBase(): string
|
protected function getTemplateBase(): string
|
||||||
@@ -44,20 +44,20 @@ class UtmTaxonomyController extends AbstractStandardFormController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core derives the JS loader method from the model name; no Mautic.<prefix>OnLoad exists for
|
* The OnLoad JS prefix (no Mautic.mt3sMpUtmTaxonomyOnLoad exists: the form needs none),
|
||||||
* taxonomies (the form needs none), but the prefix stays deterministic for future use.
|
* deterministic for future use; core's fallback, the model name, would nothing listen to.
|
||||||
*/
|
*/
|
||||||
protected function getJsLoadMethodPrefix(): string
|
protected function getJsLoadMethodPrefix(): string
|
||||||
{
|
{
|
||||||
return 'smartlinksUtmTaxonomy';
|
return 'mt3sMpUtmTaxonomy';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core builds mautic.<model name>; every key of the feature lives under mautic.smartlinks.taxonomies.
|
* Core builds mautic.<model name>; every key of the feature lives under mt3s.smart_links.taxonomies.
|
||||||
*/
|
*/
|
||||||
protected function getTranslationBase(): string
|
protected function getTranslationBase(): string
|
||||||
{
|
{
|
||||||
return 'mautic.smartlinks.taxonomies';
|
return 'mt3s.smart_links.taxonomies';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,6 +97,8 @@ class UtmTaxonomyController extends AbstractStandardFormController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Taxonomies don't have a detail page; after Save or Cancel go back to the list.
|
* Taxonomies don't have a detail page; after Save or Cancel go back to the list.
|
||||||
|
*
|
||||||
|
* @param string $action
|
||||||
*/
|
*/
|
||||||
protected function getPostActionControllerAction($action): string
|
protected function getPostActionControllerAction($action): string
|
||||||
{
|
{
|
||||||
@@ -113,9 +115,11 @@ class UtmTaxonomyController extends AbstractStandardFormController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A saved taxonomy is never cloned: its name is unique, and a clone would collide on save.
|
* A saved taxonomy is never cloned: its name is unique, and a clone would collide on save.
|
||||||
|
*
|
||||||
|
* @param int|null $objectId
|
||||||
*/
|
*/
|
||||||
public function cloneAction(Request $request, $objectId): Response
|
public function cloneAction(Request $request, $objectId): Response
|
||||||
{
|
{
|
||||||
$this->accessDenied();
|
$this->throwAccessDenied();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+15
-15
@@ -141,16 +141,16 @@ class Audience extends FormEntity
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->stages = new ArrayCollection();
|
$this->stages = new ArrayCollection();
|
||||||
$this->segments = new ArrayCollection();
|
$this->segments = new ArrayCollection();
|
||||||
$this->programLinks = new ArrayCollection();
|
$this->programLinks = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
$this->id = null;
|
$this->id = null;
|
||||||
$this->stages = new ArrayCollection();
|
$this->stages = new ArrayCollection();
|
||||||
$this->segments = new ArrayCollection();
|
$this->segments = new ArrayCollection();
|
||||||
$this->programLinks = new ArrayCollection();
|
$this->programLinks = new ArrayCollection();
|
||||||
|
|
||||||
parent::__clone();
|
parent::__clone();
|
||||||
@@ -171,21 +171,21 @@ class Audience extends FormEntity
|
|||||||
|
|
||||||
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191).
|
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191).
|
||||||
$metadata->mapField([
|
$metadata->mapField([
|
||||||
'fieldName' => 'audienceType',
|
'fieldName' => 'audienceType',
|
||||||
'columnName' => 'audience_type',
|
'columnName' => 'audience_type',
|
||||||
'type' => Types::STRING,
|
'type' => Types::STRING,
|
||||||
'length' => 30,
|
'length' => 30,
|
||||||
'enumType' => AudienceType::class,
|
'enumType' => AudienceType::class,
|
||||||
'options' => ['default' => AudienceType::Persona->value],
|
'options' => ['default' => AudienceType::Persona->value],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
foreach ([
|
foreach ([
|
||||||
'tagline' => 'tagline',
|
'tagline' => 'tagline',
|
||||||
'profileCriteria' => 'profile_criteria',
|
'profileCriteria' => 'profile_criteria',
|
||||||
'motivations' => 'motivations',
|
'motivations' => 'motivations',
|
||||||
'barriers' => 'barriers',
|
'barriers' => 'barriers',
|
||||||
'frustrations' => 'frustrations',
|
'frustrations' => 'frustrations',
|
||||||
'triggers' => 'triggers',
|
'triggers' => 'triggers',
|
||||||
] as $field => $column) {
|
] as $field => $column) {
|
||||||
$metadata->mapField([
|
$metadata->mapField([
|
||||||
'fieldName' => $field,
|
'fieldName' => $field,
|
||||||
|
|||||||
@@ -0,0 +1,544 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||||
|
use Mautic\CategoryBundle\Entity\Category;
|
||||||
|
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||||
|
use Mautic\CoreBundle\Entity\FormEntity;
|
||||||
|
use Mautic\UserBundle\Entity\User;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\EndDateAfterStartDate;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\ValidCallingWindow;
|
||||||
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
|
use Symfony\Component\Validator\Constraints\Valid;
|
||||||
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A call script: an HTML script with dynamic tokens like {contact.first_name}, the outcomes an agent
|
||||||
|
* can record, its calling window and its retry policy.
|
||||||
|
*
|
||||||
|
* It is a Mautic component (like an email or a landing page): its pages are linked from the
|
||||||
|
* Components menu. The script itself is stored as typed; resolving the tokens for a contact is the
|
||||||
|
* job of the call execution, which is not part of this entity.
|
||||||
|
*/
|
||||||
|
class CallScript extends FormEntity implements DateRangeInterface
|
||||||
|
{
|
||||||
|
public const TABLE_NAME = 'mt3s_call_scripts';
|
||||||
|
|
||||||
|
public const NAME_MAX_LENGTH = 191;
|
||||||
|
|
||||||
|
public const TIMEZONE_MAX_LENGTH = 64;
|
||||||
|
|
||||||
|
public const RETRY_ATTEMPTS_MIN = 1;
|
||||||
|
|
||||||
|
public const RETRY_ATTEMPTS_MAX = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One week, in minutes.
|
||||||
|
*/
|
||||||
|
public const RETRY_DELAY_MAX = 10080;
|
||||||
|
|
||||||
|
public const RETRY_MAX_ATTEMPTS_DEFAULT = 3;
|
||||||
|
|
||||||
|
public const RETRY_DELAY_DEFAULT = 30;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The weekdays of the calling window, in display order.
|
||||||
|
*/
|
||||||
|
public const WEEKDAYS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
|
||||||
|
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, CallScriptOutcome>
|
||||||
|
*/
|
||||||
|
private Collection $outcomes;
|
||||||
|
|
||||||
|
private ?string $name = null;
|
||||||
|
|
||||||
|
private ?string $description = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The script's validity window: the "start" date and time.
|
||||||
|
*/
|
||||||
|
private ?\DateTime $publishUp = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The script's validity window: the "end" date and time.
|
||||||
|
*/
|
||||||
|
private ?\DateTime $publishDown = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required in the form. The column is nullable only so that deleting the user doesn't delete the
|
||||||
|
* script (ON DELETE SET NULL).
|
||||||
|
*/
|
||||||
|
private ?User $owner = null;
|
||||||
|
|
||||||
|
private ?Category $category = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTML with dynamic tokens like {contact.first_name}, kept as typed.
|
||||||
|
*/
|
||||||
|
private ?string $script = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The weekdays the calls may happen on, as ISO short names (mon..sun). Empty means every day.
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
private array $callingDays = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The calling window's hours, as times of day in the window's timezone.
|
||||||
|
*/
|
||||||
|
private ?\DateTime $callingFrom = null;
|
||||||
|
|
||||||
|
private ?\DateTime $callingTo = null;
|
||||||
|
|
||||||
|
private CallScriptTimezoneMode $callingTimezoneMode = CallScriptTimezoneMode::Contact;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The fixed timezone of the calling window, when its mode is "fixed".
|
||||||
|
*/
|
||||||
|
private ?string $callingTimezone = null;
|
||||||
|
|
||||||
|
private int $retryMaxAttempts = self::RETRY_MAX_ATTEMPTS_DEFAULT;
|
||||||
|
|
||||||
|
private int $retryDelayMinutes = self::RETRY_DELAY_DEFAULT;
|
||||||
|
|
||||||
|
private CallScriptRetryBackoff $retryBackoff = CallScriptRetryBackoff::None;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->outcomes = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||||
|
{
|
||||||
|
$builder = new ClassMetadataBuilder($metadata);
|
||||||
|
|
||||||
|
$builder->setTable(self::TABLE_NAME)
|
||||||
|
->setCustomRepositoryClass(CallScriptRepository::class);
|
||||||
|
|
||||||
|
$builder->addId();
|
||||||
|
|
||||||
|
$builder->createField('name', Types::STRING)
|
||||||
|
->length(self::NAME_MAX_LENGTH)
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->createField('description', Types::TEXT)
|
||||||
|
->nullable()
|
||||||
|
->build();
|
||||||
|
|
||||||
|
// The script's validity window: the "start" and "end" date and time in the form.
|
||||||
|
$builder->addPublishDates();
|
||||||
|
|
||||||
|
$builder->createManyToOne('owner', User::class)
|
||||||
|
->addJoinColumn('owner_id', 'id', true, false, 'SET NULL')
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->addCategory();
|
||||||
|
|
||||||
|
// Types::TEXT is LONGTEXT on MySQL: the script keeps all its HTML.
|
||||||
|
$builder->createField('script', Types::TEXT)
|
||||||
|
->nullable()
|
||||||
|
->build();
|
||||||
|
|
||||||
|
// Mapped on the raw metadata, like the Smart Links arrays: ClassMetadataBuilder forces
|
||||||
|
// VARCHAR(191) on strings and doesn't accept JSON or enum types.
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'callingDays',
|
||||||
|
'columnName' => 'calling_days',
|
||||||
|
'type' => Types::JSON,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'callingFrom',
|
||||||
|
'columnName' => 'calling_from',
|
||||||
|
'type' => Types::TIME_MUTABLE,
|
||||||
|
'nullable' => true,
|
||||||
|
]);
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'callingTo',
|
||||||
|
'columnName' => 'calling_to',
|
||||||
|
'type' => Types::TIME_MUTABLE,
|
||||||
|
'nullable' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'callingTimezoneMode',
|
||||||
|
'columnName' => 'calling_timezone_mode',
|
||||||
|
'type' => Types::STRING,
|
||||||
|
'length' => 10,
|
||||||
|
'enumType' => CallScriptTimezoneMode::class,
|
||||||
|
'options' => ['default' => CallScriptTimezoneMode::Contact->value],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->createField('callingTimezone', Types::STRING)
|
||||||
|
->columnName('calling_timezone')
|
||||||
|
->length(self::TIMEZONE_MAX_LENGTH)
|
||||||
|
->nullable()
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->createField('retryMaxAttempts', Types::INTEGER)
|
||||||
|
->columnName('retry_max_attempts')
|
||||||
|
->option('default', self::RETRY_MAX_ATTEMPTS_DEFAULT)
|
||||||
|
->option('unsigned', true)
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->createField('retryDelayMinutes', Types::INTEGER)
|
||||||
|
->columnName('retry_delay_minutes')
|
||||||
|
->option('default', self::RETRY_DELAY_DEFAULT)
|
||||||
|
->option('unsigned', true)
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'retryBackoff',
|
||||||
|
'columnName' => 'retry_backoff',
|
||||||
|
'type' => Types::STRING,
|
||||||
|
'length' => 20,
|
||||||
|
'enumType' => CallScriptRetryBackoff::class,
|
||||||
|
'options' => ['default' => CallScriptRetryBackoff::None->value],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->createOneToMany('outcomes', CallScriptOutcome::class)
|
||||||
|
->mappedBy('callScript')
|
||||||
|
->setOrderBy(['position' => 'ASC'])
|
||||||
|
->cascadePersist()
|
||||||
|
->cascadeRemove()
|
||||||
|
->orphanRemoval()
|
||||||
|
->build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||||
|
{
|
||||||
|
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required'));
|
||||||
|
$metadata->addPropertyConstraint('name', new Length(max: self::NAME_MAX_LENGTH));
|
||||||
|
$metadata->addPropertyConstraint('owner', new NotBlank(message: 'mt3s.marketing_program.owner.required'));
|
||||||
|
$metadata->addPropertyConstraint('outcomes', new Valid());
|
||||||
|
$metadata->addPropertyConstraint('retryMaxAttempts', new Range(
|
||||||
|
notInRangeMessage: 'mt3s.call_script.retry_attempts.range',
|
||||||
|
min: self::RETRY_ATTEMPTS_MIN,
|
||||||
|
max: self::RETRY_ATTEMPTS_MAX,
|
||||||
|
));
|
||||||
|
$metadata->addPropertyConstraint('retryDelayMinutes', new Range(
|
||||||
|
notInRangeMessage: 'mt3s.call_script.retry_delay.range',
|
||||||
|
min: 0,
|
||||||
|
max: self::RETRY_DELAY_MAX,
|
||||||
|
));
|
||||||
|
// The validity window: the end must be on or after the start (the form's "end" field is publishDown).
|
||||||
|
$metadata->addConstraint(new EndDateAfterStartDate(atPath: 'publishDown'));
|
||||||
|
$metadata->addConstraint(new ValidCallingWindow());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The outcomes sorted by position, as a new collection (see Program::getObjectives()).
|
||||||
|
*
|
||||||
|
* @return Collection<int, CallScriptOutcome>
|
||||||
|
*/
|
||||||
|
public function getOutcomes(): Collection
|
||||||
|
{
|
||||||
|
$rows = $this->outcomes->toArray();
|
||||||
|
usort($rows, fn (CallScriptOutcome $a, CallScriptOutcome $b): int => $a->getPosition() <=> $b->getPosition());
|
||||||
|
|
||||||
|
return new ArrayCollection($rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addOutcome(CallScriptOutcome $outcome): static
|
||||||
|
{
|
||||||
|
if (!$this->outcomes->contains($outcome)) {
|
||||||
|
$outcome->setCallScript($this);
|
||||||
|
$this->outcomes->add($outcome);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeOutcome(CallScriptOutcome $outcome): static
|
||||||
|
{
|
||||||
|
$this->outcomes->removeElement($outcome);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps the outcome positions contiguous (0..n-1) in their current order, before saving.
|
||||||
|
*/
|
||||||
|
public function normalizePositions(): void
|
||||||
|
{
|
||||||
|
$rows = $this->outcomes->toArray();
|
||||||
|
usort($rows, fn (CallScriptOutcome $a, CallScriptOutcome $b): int => $a->getPosition() <=> $b->getPosition());
|
||||||
|
|
||||||
|
foreach ($rows as $index => $row) {
|
||||||
|
$row->setPosition($index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(?string $name): static
|
||||||
|
{
|
||||||
|
$this->isChanged('name', $name);
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription(): ?string
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDescription(?string $description): static
|
||||||
|
{
|
||||||
|
$this->isChanged('description', $description);
|
||||||
|
$this->description = $description;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPublishUp(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->publishUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPublishUp(?\DateTime $publishUp): static
|
||||||
|
{
|
||||||
|
$this->isChanged('publishUp', $publishUp);
|
||||||
|
$this->publishUp = $publishUp;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPublishDown(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->publishDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPublishDown(?\DateTime $publishDown): static
|
||||||
|
{
|
||||||
|
$this->isChanged('publishDown', $publishDown);
|
||||||
|
$this->publishDown = $publishDown;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DateRangeInterface: the script's validity window, for EndDateAfterStartDate.
|
||||||
|
*/
|
||||||
|
public function getStartDate(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->publishUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEndDate(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->publishDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOwner(): ?User
|
||||||
|
{
|
||||||
|
return $this->owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOwner(?User $owner): static
|
||||||
|
{
|
||||||
|
$this->isChanged('owner', $owner);
|
||||||
|
$this->owner = $owner;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCategory(): ?Category
|
||||||
|
{
|
||||||
|
return $this->category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCategory(?Category $category): static
|
||||||
|
{
|
||||||
|
$this->isChanged('category', $category);
|
||||||
|
$this->category = $category;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getScript(): ?string
|
||||||
|
{
|
||||||
|
return $this->script;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setScript(?string $script): static
|
||||||
|
{
|
||||||
|
$this->isChanged('script', $script);
|
||||||
|
$this->script = $script;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function getCallingDays(): array
|
||||||
|
{
|
||||||
|
return $this->callingDays;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string>|null $callingDays
|
||||||
|
*/
|
||||||
|
public function setCallingDays(?array $callingDays): static
|
||||||
|
{
|
||||||
|
$days = [];
|
||||||
|
foreach ($callingDays ?? [] as $day) {
|
||||||
|
$day = (string) $day;
|
||||||
|
if (in_array($day, self::WEEKDAYS, true) && !in_array($day, $days, true)) {
|
||||||
|
$days[] = $day;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->isChanged('callingDays', $days);
|
||||||
|
$this->callingDays = $days;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCallingFrom(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->callingFrom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCallingFrom(?\DateTime $callingFrom): static
|
||||||
|
{
|
||||||
|
$this->isChanged('callingFrom', $callingFrom);
|
||||||
|
$this->callingFrom = $callingFrom;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCallingTo(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->callingTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCallingTo(?\DateTime $callingTo): static
|
||||||
|
{
|
||||||
|
$this->isChanged('callingTo', $callingTo);
|
||||||
|
$this->callingTo = $callingTo;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCallingTimezoneMode(): CallScriptTimezoneMode
|
||||||
|
{
|
||||||
|
return $this->callingTimezoneMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null (a mode field missing from the submitted form) keeps the current mode, like the task kind.
|
||||||
|
*/
|
||||||
|
public function setCallingTimezoneMode(?CallScriptTimezoneMode $callingTimezoneMode): static
|
||||||
|
{
|
||||||
|
if (null === $callingTimezoneMode || $callingTimezoneMode === $this->callingTimezoneMode) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// isChanged() can't log enums (they aren't stringable), so log the backing values.
|
||||||
|
$this->addChange('callingTimezoneMode', [$this->callingTimezoneMode->value, $callingTimezoneMode->value]);
|
||||||
|
$this->callingTimezoneMode = $callingTimezoneMode;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCallingTimezone(): ?string
|
||||||
|
{
|
||||||
|
return $this->callingTimezone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCallingTimezone(?string $callingTimezone): static
|
||||||
|
{
|
||||||
|
if (null !== $callingTimezone && '' === trim($callingTimezone)) {
|
||||||
|
$callingTimezone = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->isChanged('callingTimezone', $callingTimezone);
|
||||||
|
$this->callingTimezone = $callingTimezone;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRetryMaxAttempts(): int
|
||||||
|
{
|
||||||
|
return $this->retryMaxAttempts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null (an attempts field missing from the submitted form) keeps the current value.
|
||||||
|
*/
|
||||||
|
public function setRetryMaxAttempts(?int $retryMaxAttempts): static
|
||||||
|
{
|
||||||
|
if (null === $retryMaxAttempts || $retryMaxAttempts === $this->retryMaxAttempts) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->isChanged('retryMaxAttempts', $retryMaxAttempts);
|
||||||
|
$this->retryMaxAttempts = $retryMaxAttempts;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRetryDelayMinutes(): int
|
||||||
|
{
|
||||||
|
return $this->retryDelayMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null (a delay field missing from the submitted form) keeps the current value.
|
||||||
|
*/
|
||||||
|
public function setRetryDelayMinutes(?int $retryDelayMinutes): static
|
||||||
|
{
|
||||||
|
if (null === $retryDelayMinutes || $retryDelayMinutes === $this->retryDelayMinutes) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->isChanged('retryDelayMinutes', $retryDelayMinutes);
|
||||||
|
$this->retryDelayMinutes = $retryDelayMinutes;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRetryBackoff(): CallScriptRetryBackoff
|
||||||
|
{
|
||||||
|
return $this->retryBackoff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null (a backoff field missing from the submitted form) keeps the current policy.
|
||||||
|
*/
|
||||||
|
public function setRetryBackoff(?CallScriptRetryBackoff $retryBackoff): static
|
||||||
|
{
|
||||||
|
if (null === $retryBackoff || $retryBackoff === $this->retryBackoff) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// isChanged() can't log enums (they aren't stringable), so log the backing values.
|
||||||
|
$this->addChange('retryBackoff', [$this->retryBackoff->value, $retryBackoff->value]);
|
||||||
|
$this->retryBackoff = $retryBackoff;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||||
|
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\ValidCallScriptOutcomeOptions;
|
||||||
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One outcome of a call script: what the agent records after the call.
|
||||||
|
*
|
||||||
|
* CallScript::$outcomes owns the lifecycle: outcomes are saved and deleted with their script, and are
|
||||||
|
* ordered by position. The options are stored as a list of {value, label} rows; they are required for
|
||||||
|
* the checkbox, radio and dropdown types, and forbidden for free text.
|
||||||
|
*/
|
||||||
|
class CallScriptOutcome
|
||||||
|
{
|
||||||
|
public const TABLE_NAME = 'mt3s_call_script_outcomes';
|
||||||
|
|
||||||
|
public const LABEL_MAX_LENGTH = 191;
|
||||||
|
|
||||||
|
public const VALUE_MAX_LENGTH = 191;
|
||||||
|
|
||||||
|
public const OPTIONS_MAX = 100;
|
||||||
|
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
private ?CallScript $callScript = null;
|
||||||
|
|
||||||
|
private ?string $label = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defaults to free text: a new outcome is valid without options.
|
||||||
|
*/
|
||||||
|
private CallScriptOutcomeInputType $inputType = CallScriptOutcomeInputType::FreeText;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The choices of a checkbox, radio or dropdown outcome, as a list of {value, label} rows.
|
||||||
|
*
|
||||||
|
* @var list<array{value: string, label: string}>
|
||||||
|
*/
|
||||||
|
private array $options = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display order within the script, from 0. Set by drag and drop in the form.
|
||||||
|
*/
|
||||||
|
private int $position = 0;
|
||||||
|
|
||||||
|
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||||
|
{
|
||||||
|
$builder = new ClassMetadataBuilder($metadata);
|
||||||
|
|
||||||
|
$builder->setTable(self::TABLE_NAME);
|
||||||
|
|
||||||
|
$builder->addId();
|
||||||
|
|
||||||
|
$builder->createManyToOne('callScript', CallScript::class)
|
||||||
|
->inversedBy('outcomes')
|
||||||
|
->addJoinColumn('call_script_id', 'id', false, false, 'CASCADE')
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->createField('label', Types::STRING)
|
||||||
|
->length(self::LABEL_MAX_LENGTH)
|
||||||
|
->build();
|
||||||
|
|
||||||
|
// Mapped on the raw metadata: ClassMetadataBuilder forces VARCHAR(191) on strings and
|
||||||
|
// doesn't accept enum or JSON types.
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'inputType',
|
||||||
|
'columnName' => 'input_type',
|
||||||
|
'type' => Types::STRING,
|
||||||
|
'length' => 20,
|
||||||
|
'enumType' => CallScriptOutcomeInputType::class,
|
||||||
|
'options' => ['default' => CallScriptOutcomeInputType::FreeText->value],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'options',
|
||||||
|
'columnName' => 'options',
|
||||||
|
'type' => Types::JSON,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->createField('position', Types::INTEGER)
|
||||||
|
->option('default', 0)
|
||||||
|
->build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||||
|
{
|
||||||
|
$metadata->addPropertyConstraint('label', new NotBlank(message: 'mt3s.call_script.outcome.label.required'));
|
||||||
|
$metadata->addPropertyConstraint('label', new Length(max: self::LABEL_MAX_LENGTH));
|
||||||
|
$metadata->addConstraint(new ValidCallScriptOutcomeOptions());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCallScript(): ?CallScript
|
||||||
|
{
|
||||||
|
return $this->callScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCallScript(?CallScript $callScript): static
|
||||||
|
{
|
||||||
|
$this->callScript = $callScript;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLabel(): ?string
|
||||||
|
{
|
||||||
|
return $this->label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setLabel(?string $label): static
|
||||||
|
{
|
||||||
|
$this->label = $label;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInputType(): CallScriptOutcomeInputType
|
||||||
|
{
|
||||||
|
return $this->inputType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null (a type field missing from the submitted form) keeps the current type.
|
||||||
|
*/
|
||||||
|
public function setInputType(?CallScriptOutcomeInputType $inputType): static
|
||||||
|
{
|
||||||
|
if (null !== $inputType) {
|
||||||
|
$this->inputType = $inputType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasOptions(): bool
|
||||||
|
{
|
||||||
|
return $this->inputType->hasOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{value: string, label: string}>
|
||||||
|
*/
|
||||||
|
public function getOptions(): array
|
||||||
|
{
|
||||||
|
return $this->options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps the {value, label} rows of the submitted options, dropping the empty ones and
|
||||||
|
* defaulting an empty label to the value.
|
||||||
|
*
|
||||||
|
* @param list<array{value?: string, label?: string}>|array<int, mixed>|null $options
|
||||||
|
*/
|
||||||
|
public function setOptions(?array $options): static
|
||||||
|
{
|
||||||
|
$clean = [];
|
||||||
|
foreach (array_slice($options ?? [], 0, self::OPTIONS_MAX) as $option) {
|
||||||
|
if (!is_array($option)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = trim((string) ($option['value'] ?? ''));
|
||||||
|
$label = trim((string) ($option['label'] ?? ''));
|
||||||
|
|
||||||
|
if ('' === $value && '' === $label) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$clean[] = ['value' => $value, 'label' => '' !== $label ? $label : $value];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->options = $clean;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPosition(): int
|
||||||
|
{
|
||||||
|
return $this->position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPosition(?int $position): static
|
||||||
|
{
|
||||||
|
$this->position = $position ?? 0;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The data type of a call script outcome: the agent records it with checkboxes, radio buttons,
|
||||||
|
* free text or a drop-down.
|
||||||
|
*/
|
||||||
|
enum CallScriptOutcomeInputType: string
|
||||||
|
{
|
||||||
|
case Checkbox = 'checkbox';
|
||||||
|
case Radio = 'radio';
|
||||||
|
case FreeText = 'free_text';
|
||||||
|
case Dropdown = 'dropdown';
|
||||||
|
|
||||||
|
public function getLabelKey(): string
|
||||||
|
{
|
||||||
|
return 'mt3s.call_script.outcome_type.'.$this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True when the user records the outcome by choosing among configured options.
|
||||||
|
*/
|
||||||
|
public function hasOptions(): bool
|
||||||
|
{
|
||||||
|
return self::FreeText !== $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends CommonRepository<CallScript>
|
||||||
|
*/
|
||||||
|
class CallScriptRepository extends CommonRepository
|
||||||
|
{
|
||||||
|
public function getTableAlias(): string
|
||||||
|
{
|
||||||
|
return 'cs';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the owner and category with the scripts, so that the list doesn't query them one by one.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $args
|
||||||
|
*/
|
||||||
|
public function getEntities(array $args = [])
|
||||||
|
{
|
||||||
|
$alias = $this->getTableAlias();
|
||||||
|
|
||||||
|
$args['qb'] = $this->createQueryBuilder($alias)
|
||||||
|
->select($alias, 'o', 'c')
|
||||||
|
->leftJoin($alias.'.owner', 'o')
|
||||||
|
->leftJoin($alias.'.category', 'c');
|
||||||
|
|
||||||
|
return parent::getEntities($args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list's search box matches the name.
|
||||||
|
*
|
||||||
|
* @return array<int, mixed>
|
||||||
|
*/
|
||||||
|
protected function addCatchAllWhereClause($q, $filter): array
|
||||||
|
{
|
||||||
|
return $this->addStandardCatchAllWhereClause($q, $filter, [
|
||||||
|
$this->getTableAlias().'.name',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<array{0: string, 1: string}>
|
||||||
|
*/
|
||||||
|
protected function getDefaultOrder(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[$this->getTableAlias().'.name', 'ASC'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How the delay between two call attempts grows: not at all, by a constant step, or exponentially.
|
||||||
|
*
|
||||||
|
* - none: every retry waits the same delay.
|
||||||
|
* - linear: attempt n waits delay * n.
|
||||||
|
* - exponential: attempt n waits delay * 2^(n-1).
|
||||||
|
*/
|
||||||
|
enum CallScriptRetryBackoff: string
|
||||||
|
{
|
||||||
|
case None = 'none';
|
||||||
|
case Linear = 'linear';
|
||||||
|
case Exponential = 'exponential';
|
||||||
|
|
||||||
|
public function getLabelKey(): string
|
||||||
|
{
|
||||||
|
return 'mt3s.call_script.retry_backoff.'.$this->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How the calling window's hours are read: in the contact's timezone, or in one fixed timezone.
|
||||||
|
*/
|
||||||
|
enum CallScriptTimezoneMode: string
|
||||||
|
{
|
||||||
|
case Contact = 'contact';
|
||||||
|
case Fixed = 'fixed';
|
||||||
|
|
||||||
|
public function getLabelKey(): string
|
||||||
|
{
|
||||||
|
return 'mt3s.call_script.timezone_mode.'.$this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isFixed(): bool
|
||||||
|
{
|
||||||
|
return self::Fixed === $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-8
@@ -105,12 +105,12 @@ class Program extends FormEntity implements DateRangeInterface
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->objectives = new ArrayCollection();
|
$this->objectives = new ArrayCollection();
|
||||||
$this->descriptionItems = new ArrayCollection();
|
$this->descriptionItems = new ArrayCollection();
|
||||||
$this->allocationItems = new ArrayCollection();
|
$this->allocationItems = new ArrayCollection();
|
||||||
$this->audiences = new ArrayCollection();
|
$this->audiences = new ArrayCollection();
|
||||||
$this->stakeholders = new ArrayCollection();
|
$this->stakeholders = new ArrayCollection();
|
||||||
$this->tasks = new ArrayCollection();
|
$this->tasks = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
@@ -163,8 +163,10 @@ class Program extends FormEntity implements DateRangeInterface
|
|||||||
->setCustomRepositoryClass(ProgramRepository::class)
|
->setCustomRepositoryClass(ProgramRepository::class)
|
||||||
->addIndex(['status'], 'program_status');
|
->addIndex(['status'], 'program_status');
|
||||||
|
|
||||||
// id and name; no description column (replaced by description items).
|
// id and name; no description column (replaced by description items). The false is
|
||||||
$builder->addIdColumns('name', false);
|
// core's own way to skip the column (addIdColumns checks it for truthiness); core's
|
||||||
|
// @param string docblock just doesn't mention it.
|
||||||
|
$builder->addIdColumns('name', false); // @phpstan-ignore argument.type (false is core's own way to skip the column; its @param string docblock doesn't mention it)
|
||||||
|
|
||||||
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191).
|
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191).
|
||||||
$metadata->mapField([
|
$metadata->mapField([
|
||||||
@@ -468,7 +470,7 @@ class Program extends FormEntity implements DateRangeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T of ProgramObjective|ProgramDescriptionItem|ProgramAllocationItem|Audience|ProgramStakeholder
|
* @template T of ProgramObjective|ProgramDescriptionItem|ProgramAllocationItem|ProgramAudience|ProgramStakeholder
|
||||||
*
|
*
|
||||||
* @param Collection<int, T> $collection
|
* @param Collection<int, T> $collection
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class ProgramAllocationItem
|
|||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
$this->id = null;
|
$this->id = null;
|
||||||
$this->program = null;
|
$this->program = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class ProgramAudience
|
|||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
$this->id = null;
|
$this->id = null;
|
||||||
$this->program = null;
|
$this->program = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ class ProgramAudienceRepository extends CommonRepository
|
|||||||
{
|
{
|
||||||
return 'pa';
|
return 'pa';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ class ProgramDescriptionItem
|
|||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
$this->id = null;
|
$this->id = null;
|
||||||
$this->program = null;
|
$this->program = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class ProgramObjective
|
|||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
$this->id = null;
|
$this->id = null;
|
||||||
$this->program = null;
|
$this->program = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class ProgramStakeholder
|
|||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
$this->id = null;
|
$this->id = null;
|
||||||
$this->program = null;
|
$this->program = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ enum ProgramStatus: string
|
|||||||
public function getLabelClass(): string
|
public function getLabelClass(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Active => 'label-success',
|
self::Active => 'label-success',
|
||||||
self::Completed => 'label-info',
|
self::Completed => 'label-info',
|
||||||
self::Paused => 'label-warning',
|
self::Paused => 'label-warning',
|
||||||
self::Archived => 'label-default',
|
self::Archived => 'label-default',
|
||||||
self::Draft, self::Planned => 'label-primary',
|
self::Draft, self::Planned => 'label-primary',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,10 +126,10 @@ class SmartLink extends FormEntity
|
|||||||
|
|
||||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||||
{
|
{
|
||||||
$metadata->addPropertyConstraint('slug', new NotBlank(message: 'mautic.smartlinks.smart_links.error.slug_required'));
|
$metadata->addPropertyConstraint('slug', new NotBlank(message: 'mt3s.smart_links.smart_links.error.slug_required'));
|
||||||
$metadata->addPropertyConstraint('slug', new Length(
|
$metadata->addPropertyConstraint('slug', new Length(
|
||||||
max: self::SLUG_MAX_LENGTH,
|
max: self::SLUG_MAX_LENGTH,
|
||||||
maxMessage: 'mautic.smartlinks.smart_links.error.slug_length',
|
maxMessage: 'mt3s.smart_links.smart_links.error.slug_length',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,10 +71,13 @@ class SmartLinkRepository extends CommonRepository
|
|||||||
$this->getTableAlias().'.destinationUrl',
|
$this->getTableAlias().'.destinationUrl',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Hits column of the list sorts by the number of hits of each link: the virtual
|
* The Hits column of the list sorts by the number of hits of each link: the virtual
|
||||||
* "hitCount" order by maps to the HIDDEN hitCount scalar of the list query. Everything
|
* "hitCount" order by maps to the HIDDEN hitCount scalar of the list query. Everything
|
||||||
* else falls back to core's column handling.
|
* else falls back to core's column handling.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $args
|
||||||
*/
|
*/
|
||||||
protected function buildOrderByClause($q, array $args): void
|
protected function buildOrderByClause($q, array $args): void
|
||||||
{
|
{
|
||||||
@@ -92,6 +95,7 @@ class SmartLinkRepository extends CommonRepository
|
|||||||
|
|
||||||
parent::buildOrderByClause($q, $args);
|
parent::buildOrderByClause($q, $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<array{0: string, 1: string}>
|
* @return array<array{0: string, 1: string}>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,9 +19,10 @@ class StakeholderRepository extends CommonRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list's search box matches the name, email, role and type.
|
* The list's search box matches the name, email, role and type. Core passes the filter
|
||||||
|
* as an object with ->string and ->strict (its own docblock), not an array.
|
||||||
*
|
*
|
||||||
* @param array<int, mixed> $filter
|
* @param \stdClass $filter
|
||||||
*
|
*
|
||||||
* @return array<int, mixed>
|
* @return array<int, mixed>
|
||||||
*/
|
*/
|
||||||
|
|||||||
+27
-14
@@ -66,7 +66,12 @@ class Task extends FormEntity implements DateRangeInterface
|
|||||||
|
|
||||||
private TaskStatus $status = TaskStatus::New;
|
private TaskStatus $status = TaskStatus::New;
|
||||||
|
|
||||||
private ?TaskKind $taskKind = null;
|
/**
|
||||||
|
* Defaults to a regular task, like $status: Doctrine writes every column explicitly, so
|
||||||
|
* the database column's own default never applies. A save whose form field didn't map
|
||||||
|
* (a POST missing the kind) must never hit the NOT NULL column with null.
|
||||||
|
*/
|
||||||
|
private TaskKind $taskKind = TaskKind::Task;
|
||||||
|
|
||||||
private ?string $definitionOfDone = null;
|
private ?string $definitionOfDone = null;
|
||||||
|
|
||||||
@@ -291,32 +296,40 @@ class Task extends FormEntity implements DateRangeInterface
|
|||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setStatus(TaskStatus $status): static
|
public function setStatus(?TaskStatus $status): static
|
||||||
{
|
{
|
||||||
if ($status !== $this->status) {
|
// Null (a status field missing from the submitted form) never wipes the status: like
|
||||||
// isChanged() can't log enums (they aren't stringable), so log the backing values.
|
// the kind, it keeps its default (New) or whatever the task already has.
|
||||||
$this->addChange('status', [$this->status->value, $status->value]);
|
if (null === $status || $status === $this->status) {
|
||||||
$this->status = $status;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isChanged() can't log enums (they aren't stringable), so log the backing values.
|
||||||
|
$this->addChange('status', [$this->status->value, $status->value]);
|
||||||
|
$this->status = $status;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTaskKind(): TaskKind
|
public function getTaskKind(): TaskKind
|
||||||
{
|
{
|
||||||
// Never null once stored (the column defaults to 'task'); a new entity reads as a plain task.
|
// Never null: the property starts as a regular task and the column is NOT NULL.
|
||||||
return $this->taskKind ?? TaskKind::Task;
|
return $this->taskKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTaskKind(TaskKind $taskKind): static
|
public function setTaskKind(?TaskKind $taskKind): static
|
||||||
{
|
{
|
||||||
if ($taskKind !== $this->taskKind) {
|
// Null (a kind field missing from the submitted form) never wipes the kind: a new
|
||||||
// isChanged() can't log enums (they aren't stringable), so log the backing values.
|
// task keeps its regular-task default, an existing task keeps whatever it already has.
|
||||||
$this->addChange('taskKind', [$this->taskKind?->value, $taskKind->value]);
|
if (null === $taskKind || $taskKind === $this->taskKind) {
|
||||||
$taskKind->enslaveDates($this);
|
return $this;
|
||||||
$this->taskKind = $taskKind;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isChanged() can't log enums (they aren't stringable), so log the backing values.
|
||||||
|
$this->addChange('taskKind', [$this->taskKind->value, $taskKind->value]);
|
||||||
|
$taskKind->enslaveDates($this);
|
||||||
|
$this->taskKind = $taskKind;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,12 +51,12 @@ class TaskDependency
|
|||||||
->build();
|
->build();
|
||||||
|
|
||||||
$metadata->mapField([
|
$metadata->mapField([
|
||||||
'fieldName' => 'dependencyType',
|
'fieldName' => 'dependencyType',
|
||||||
'columnName' => 'dependency_type',
|
'columnName' => 'dependency_type',
|
||||||
'type' => Types::STRING,
|
'type' => Types::STRING,
|
||||||
'length' => 20,
|
'length' => 20,
|
||||||
'enumType' => DependencyType::class,
|
'enumType' => DependencyType::class,
|
||||||
'options' => ['default' => DependencyType::EndToStart->value],
|
'options' => ['default' => DependencyType::EndToStart->value],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->createField('position', Types::INTEGER)
|
$builder->createField('position', Types::INTEGER)
|
||||||
|
|||||||
+1
-1
@@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\DBAL\Types\Types;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||||
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class UtmTaxonomy extends FormEntity
|
|||||||
|
|
||||||
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces VARCHAR(191) on strings.
|
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces VARCHAR(191) on strings.
|
||||||
$metadata->mapField([
|
$metadata->mapField([
|
||||||
'fieldName' => 'parameters',
|
'fieldName' => 'parameters',
|
||||||
'columnName' => 'parameters',
|
'columnName' => 'parameters',
|
||||||
'type' => Types::JSON,
|
'type' => Types::JSON,
|
||||||
]);
|
]);
|
||||||
@@ -140,4 +140,4 @@ class UtmTaxonomy extends FormEntity
|
|||||||
{
|
{
|
||||||
return array_keys($this->parameters);
|
return array_keys($this->parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,4 +60,4 @@ class UtmTaxonomyRepository extends CommonRepository
|
|||||||
[$this->getTableAlias().'.name', 'ASC'],
|
[$this->getTableAlias().'.name', 'ASC'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,4 +29,4 @@ final class MT3SMarketingProgramEvents
|
|||||||
|
|
||||||
/** After a program was removed from the database. */
|
/** After a program was removed from the database. */
|
||||||
public const PROGRAM_DELETED = 'mt3s.marketing_program.deleted';
|
public const PROGRAM_DELETED = 'mt3s.marketing_program.deleted';
|
||||||
}
|
}
|
||||||
@@ -27,4 +27,4 @@ final class ProgramEvent extends Event
|
|||||||
{
|
{
|
||||||
return $this->isNew;
|
return $this->isNew;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,4 +33,4 @@ final class SmartLinksConfigSubscriber implements EventSubscriberInterface
|
|||||||
'parameters' => $event->getParametersFromConfig('MT3SMarketingProgramBundle'),
|
'parameters' => $event->getParametersFromConfig('MT3SMarketingProgramBundle'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ use Symfony\Component\Form\DataTransformerInterface;
|
|||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts between the stored `smartlinks_utm_config` array (parameters keyed by their key)
|
* Converts between the stored `mt3s_smart_links_utm_config` array (parameters keyed by their key)
|
||||||
* and the form structure (catalog parameters + a collection of custom parameters).
|
* and the form structure (catalog parameters + a collection of custom parameters).
|
||||||
*
|
*
|
||||||
* @implements DataTransformerInterface<mixed, array<string, mixed>>
|
* @implements DataTransformerInterface<mixed, array<string, mixed>>
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
* the Email form (EmailType) and the Focus Item form (FocusType), so this covers both.
|
* the Email form (EmailType) and the Focus Item form (FocusType), so this covers both.
|
||||||
*
|
*
|
||||||
* Registered as `form.type_extension` by autoconfiguration (Config/services.php).
|
* Registered as `form.type_extension` by autoconfiguration (Config/services.php).
|
||||||
*
|
|
||||||
* @extends AbstractTypeExtension<mixed>
|
|
||||||
*/
|
*/
|
||||||
final class UtmTagsTypeExtension extends AbstractTypeExtension
|
final class UtmTagsTypeExtension extends AbstractTypeExtension
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
* fixed type (persona, ICP, …), the segments (purely informational), then the persona attributes
|
* fixed type (persona, ICP, …), the segments (purely informational), then the persona attributes
|
||||||
* the admin switched on in Settings > Configuration > Program Settings (AudienceAttributes): one
|
* the admin switched on in Settings > Configuration > Program Settings (AudienceAttributes): one
|
||||||
* toggle per attribute, so a b2b install and a b2c install define their personas differently.
|
* toggle per attribute, so a b2b install and a b2c install define their personas differently.
|
||||||
*
|
|
||||||
* @extends AbstractType<Audience>
|
|
||||||
*/
|
*/
|
||||||
class AudienceType extends AbstractType
|
class AudienceType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -167,7 +165,7 @@ class AudienceType extends AbstractType
|
|||||||
|
|
||||||
if (in_array('stages', $enabled, true)) {
|
if (in_array('stages', $enabled, true)) {
|
||||||
$builder->add('stages', EntityType::class, [
|
$builder->add('stages', EntityType::class, [
|
||||||
'label' => 'mt3s.marketing_program.audience.field.stages',
|
'label' => 'mt3s.marketing_program.audience.field.stages',
|
||||||
'label_attr' => ['class' => 'control-label'],
|
'label_attr' => ['class' => 'control-label'],
|
||||||
'attr' => ['class' => 'form-control'],
|
'attr' => ['class' => 'form-control'],
|
||||||
'class' => Stage::class,
|
'class' => Stage::class,
|
||||||
@@ -210,4 +208,4 @@ class AudienceType extends AbstractType
|
|||||||
{
|
{
|
||||||
return 'mt3s_marketing_program_audience';
|
return 'mt3s_marketing_program_audience';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One {value, label} row of a call script outcome's options. The rows are stored as a JSON list on
|
||||||
|
* CallScriptOutcome::$options.
|
||||||
|
*/
|
||||||
|
class CallScriptOutcomeOptionType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$builder->add('value', TextType::class, [
|
||||||
|
'label' => 'mt3s.call_script.outcome_option.field.value',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'maxlength' => 191],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('label', TextType::class, [
|
||||||
|
'label' => 'mt3s.call_script.outcome_option.field.label',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'maxlength' => 191],
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlockPrefix(): string
|
||||||
|
{
|
||||||
|
return 'mt3s_call_script_outcome_option';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
|
||||||
|
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptOutcome;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptOutcomeInputType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One row of the outcomes collection in CallScriptType: the outcome's label, the data type the agent
|
||||||
|
* records it with (checkbox, radio, free text or dropdown), and the options of the choice types.
|
||||||
|
* Adding, removing and reordering is handled by Assets/js/mt3s-mp-program.js.
|
||||||
|
*/
|
||||||
|
class CallScriptOutcomeType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$builder->add('label', TextType::class, [
|
||||||
|
'label' => 'mt3s.call_script.outcome.field.label',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'maxlength' => CallScriptOutcome::LABEL_MAX_LENGTH],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('inputType', EnumType::class, [
|
||||||
|
'label' => 'mt3s.call_script.outcome.field.type',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control program-outcome-type'],
|
||||||
|
'class' => CallScriptOutcomeInputType::class,
|
||||||
|
'choice_label' => fn (CallScriptOutcomeInputType $type): string => $type->getLabelKey(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// The choices of a checkbox, radio or dropdown outcome; hidden by the JS for free text.
|
||||||
|
$builder->add('options', CollectionType::class, [
|
||||||
|
'label' => false,
|
||||||
|
'entry_type' => CallScriptOutcomeOptionType::class,
|
||||||
|
'allow_add' => true,
|
||||||
|
'allow_delete' => true,
|
||||||
|
'by_reference' => false,
|
||||||
|
'prototype' => true,
|
||||||
|
'prototype_name' => '__option__',
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// The row's order in the collection, rewritten by mt3s-mp-program.js after each change.
|
||||||
|
$builder->add('position', HiddenType::class, [
|
||||||
|
'attr' => ['class' => 'program-row-position'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => CallScriptOutcome::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlockPrefix(): string
|
||||||
|
{
|
||||||
|
return 'mt3s_call_script_outcome';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,229 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Mautic\CategoryBundle\Form\Type\CategoryListType;
|
||||||
|
use Mautic\CoreBundle\Form\DataTransformer\IdToEntityModelTransformer;
|
||||||
|
use Mautic\CoreBundle\Form\EventListener\CleanFormSubscriber;
|
||||||
|
use Mautic\CoreBundle\Form\Type\FormButtonsType;
|
||||||
|
use Mautic\CoreBundle\Form\Type\PublishDownDateType;
|
||||||
|
use Mautic\CoreBundle\Form\Type\PublishUpDateType;
|
||||||
|
use Mautic\CoreBundle\Form\Type\TimezoneType;
|
||||||
|
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
|
||||||
|
use Mautic\UserBundle\Entity\User;
|
||||||
|
use Mautic\UserBundle\Form\Type\UserListType;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScript;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptRetryBackoff;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptTimezoneMode;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TimeType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The create and edit form of a call script (Components > Call Scripts).
|
||||||
|
*
|
||||||
|
* The script keeps the HTML typed in it (the "html" cleaning mask), including the dynamic tokens like
|
||||||
|
* {contact.first_name}. The outcomes are edited as a sortable collection (see Assets/js/mt3s-mp-program.js);
|
||||||
|
* the options of an outcome are shown only for the checkbox, radio and dropdown types.
|
||||||
|
*/
|
||||||
|
class CallScriptType extends AbstractType
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private EntityManagerInterface $em,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
// Pass a mask array, never nothing: without one, core applies its "clean" mask (HTML-encodes &, <, >,
|
||||||
|
// quotes). "html" keeps the script markup; "clean" strips the rest of the fields.
|
||||||
|
$builder->addEventSubscriber(new CleanFormSubscriber([
|
||||||
|
'name' => 'clean',
|
||||||
|
'description' => 'clean',
|
||||||
|
'script' => 'html',
|
||||||
|
]));
|
||||||
|
|
||||||
|
$builder->add('name', TextType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.name',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'maxlength' => CallScript::NAME_MAX_LENGTH],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('description', TextareaType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.description',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'rows' => 2],
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('script', TextareaType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.script',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => [
|
||||||
|
'class' => 'form-control',
|
||||||
|
'rows' => 14,
|
||||||
|
'style' => 'font-family: monospace;',
|
||||||
|
'tooltip' => 'mt3s.call_script.field.script.help',
|
||||||
|
],
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Required here; the column is nullable only because of onDelete SET NULL.
|
||||||
|
$builder->add(
|
||||||
|
$builder->create('owner', UserListType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.owner',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'required' => true,
|
||||||
|
'multiple' => false,
|
||||||
|
])->addModelTransformer(new IdToEntityModelTransformer($this->em, User::class))
|
||||||
|
);
|
||||||
|
|
||||||
|
$builder->add('category', CategoryListType::class, [
|
||||||
|
'bundle' => 'call_script',
|
||||||
|
'label' => 'mt3s.call_script.field.category',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('isPublished', YesNoButtonGroupType::class, [
|
||||||
|
'label' => 'mautic.core.form.available',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// The validity window: "start" and "end" date and time.
|
||||||
|
$builder->add('publishUp', PublishUpDateType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.start',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('publishDown', PublishDownDateType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.end',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Calling window: the weekdays, the hours and the timezone the hours are read in.
|
||||||
|
$builder->add('callingDays', ChoiceType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.calling_days',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'choices' => $this->weekdayChoices(),
|
||||||
|
'choice_translation_domain' => true,
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true,
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('callingFrom', TimeType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.calling_from',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'widget' => 'single_text',
|
||||||
|
'with_seconds' => false,
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('callingTo', TimeType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.calling_to',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'widget' => 'single_text',
|
||||||
|
'with_seconds' => false,
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('callingTimezoneMode', EnumType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.calling_timezone_mode',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'class' => CallScriptTimezoneMode::class,
|
||||||
|
'choice_label' => fn (CallScriptTimezoneMode $mode): string => $mode->getLabelKey(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('callingTimezone', TimezoneType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.calling_timezone',
|
||||||
|
'placeholder' => '',
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Retry policy: how many times, how long between attempts, and how the delay grows.
|
||||||
|
$builder->add('retryMaxAttempts', IntegerType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.retry_max_attempts',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => [
|
||||||
|
'class' => 'form-control',
|
||||||
|
'min' => CallScript::RETRY_ATTEMPTS_MIN,
|
||||||
|
'max' => CallScript::RETRY_ATTEMPTS_MAX,
|
||||||
|
'step' => 1,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('retryDelayMinutes', IntegerType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.retry_delay_minutes',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => [
|
||||||
|
'class' => 'form-control',
|
||||||
|
'min' => 0,
|
||||||
|
'max' => CallScript::RETRY_DELAY_MAX,
|
||||||
|
'step' => 1,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('retryBackoff', EnumType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.retry_backoff',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'class' => CallScriptRetryBackoff::class,
|
||||||
|
'choice_label' => fn (CallScriptRetryBackoff $backoff): string => $backoff->getLabelKey(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Outcomes: the list of things the agent can record, each with its data type and options.
|
||||||
|
$builder->add('outcomes', CollectionType::class, [
|
||||||
|
'label' => false,
|
||||||
|
'entry_type' => CallScriptOutcomeType::class,
|
||||||
|
'allow_add' => true,
|
||||||
|
'allow_delete' => true,
|
||||||
|
'by_reference' => false,
|
||||||
|
'prototype' => true,
|
||||||
|
'prototype_name' => '__outcome__',
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('buttons', FormButtonsType::class);
|
||||||
|
|
||||||
|
if (!empty($options['action'])) {
|
||||||
|
$builder->setAction($options['action']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The weekdays of the calling window: translation key => ISO short name.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private function weekdayChoices(): array
|
||||||
|
{
|
||||||
|
$choices = [];
|
||||||
|
foreach (CallScript::WEEKDAYS as $day) {
|
||||||
|
$choices['mt3s.call_script.day.'.$day] = $day;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $choices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => CallScript::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlockPrefix(): string
|
||||||
|
{
|
||||||
|
return 'mt3s_call_script';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,13 +4,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
|
||||||
|
|
||||||
|
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel;
|
use MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
|
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Service\AudienceAttributes;
|
use MauticPlugin\MT3SMarketingProgramBundle\Service\AudienceAttributes;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
|
||||||
@@ -24,8 +24,6 @@ use Symfony\Component\Validator\Constraints\NotBlank;
|
|||||||
*
|
*
|
||||||
* The item type lists moved to their own page under Programs (ItemTypesController, Programs >
|
* The item type lists moved to their own page under Programs (ItemTypesController, Programs >
|
||||||
* Item types).
|
* Item types).
|
||||||
*
|
|
||||||
* @extends AbstractType<array<string, mixed>>
|
|
||||||
*/
|
*/
|
||||||
class ConfigType extends AbstractType
|
class ConfigType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ use Symfony\Component\Validator\Constraints\NotBlank;
|
|||||||
*
|
*
|
||||||
* The key is hidden. It is generated when the type is created and never changes, so that renaming a
|
* The key is hidden. It is generated when the type is created and never changes, so that renaming a
|
||||||
* type doesn't affect the items that use it.
|
* type doesn't affect the items that use it.
|
||||||
*
|
|
||||||
* @extends AbstractType<array<string, mixed>>
|
|
||||||
*/
|
*/
|
||||||
class ItemTypeConfigType extends AbstractType
|
class ItemTypeConfigType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
* an audience's decision roles and tones. Each child is one of ItemTypeProvider::PARAMETERS,
|
* an audience's decision roles and tones. Each child is one of ItemTypeProvider::PARAMETERS,
|
||||||
* keyed exactly by the local.php parameter that stores the list, so saving is a straight merge
|
* keyed exactly by the local.php parameter that stores the list, so saving is a straight merge
|
||||||
* into the local configuration.
|
* into the local configuration.
|
||||||
*
|
|
||||||
* @extends AbstractType<array<string, mixed>>
|
|
||||||
*/
|
*/
|
||||||
class ItemTypesType extends AbstractType
|
class ItemTypesType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -29,15 +27,15 @@ class ItemTypesType extends AbstractType
|
|||||||
$withIcon = !in_array($kind, [ItemTypeProvider::KIND_AUDIENCE_DECISION_ROLE, ItemTypeProvider::KIND_AUDIENCE_TONE], true);
|
$withIcon = !in_array($kind, [ItemTypeProvider::KIND_AUDIENCE_DECISION_ROLE, ItemTypeProvider::KIND_AUDIENCE_TONE], true);
|
||||||
|
|
||||||
$builder->add($parameter, CollectionType::class, [
|
$builder->add($parameter, CollectionType::class, [
|
||||||
'label' => false,
|
'label' => false,
|
||||||
'entry_type' => ItemTypeConfigType::class,
|
'entry_type' => ItemTypeConfigType::class,
|
||||||
'entry_options' => ['label' => false, 'with_icon' => $withIcon],
|
'entry_options' => ['label' => false, 'with_icon' => $withIcon],
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
'allow_delete' => true,
|
'allow_delete' => true,
|
||||||
'prototype' => true,
|
'prototype' => true,
|
||||||
'prototype_name' => '__type__',
|
'prototype_name' => '__type__',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'error_bubbling' => false,
|
'error_bubbling' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Stored as a clean list (0..n-1, empty texts dropped), in the order shown on the page.
|
// Stored as a clean list (0..n-1, empty texts dropped), in the order shown on the page.
|
||||||
@@ -55,4 +53,4 @@ class ItemTypesType extends AbstractType
|
|||||||
// The POST data keys: mt3s_marketing_program_item_types[<parameter>][<index>][…].
|
// The POST data keys: mt3s_marketing_program_item_types[<parameter>][<index>][…].
|
||||||
return 'mt3s_marketing_program_item_types';
|
return 'mt3s_marketing_program_item_types';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,8 +21,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
* real cost (both in the general currency). Works like ProgramDescriptionItemType (type description shown
|
* real cost (both in the general currency). Works like ProgramDescriptionItemType (type description shown
|
||||||
* under the dropdown and its pictogram next to it, hidden position kept in display order by
|
* under the dropdown and its pictogram next to it, hidden position kept in display order by
|
||||||
* Assets/js/mt3s-mp-program.js).
|
* Assets/js/mt3s-mp-program.js).
|
||||||
*
|
|
||||||
* @extends AbstractType<ProgramAllocationItem>
|
|
||||||
*/
|
*/
|
||||||
class ProgramAllocationItemType extends AbstractType
|
class ProgramAllocationItemType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
* One row of the audiences collection in ProgramType: an audience of the global directory (only the
|
* One row of the audiences collection in ProgramType: an audience of the global directory (only the
|
||||||
* active ones are offered), the audience's priority in this plan, and possibly a program-specific
|
* active ones are offered), the audience's priority in this plan, and possibly a program-specific
|
||||||
* message. The position field is hidden and kept in display order by Assets/js/mt3s-mp-program.js.
|
* message. The position field is hidden and kept in display order by Assets/js/mt3s-mp-program.js.
|
||||||
*
|
|
||||||
* @extends AbstractType<ProgramAudience>
|
|
||||||
*/
|
*/
|
||||||
class ProgramAudienceType extends AbstractType
|
class ProgramAudienceType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -73,4 +71,4 @@ class ProgramAudienceType extends AbstractType
|
|||||||
{
|
{
|
||||||
return 'mt3s_marketing_program_program_audience';
|
return 'mt3s_marketing_program_program_audience';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,8 +18,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
* types set up in Settings > Configuration > Program; each option carries the type's description, which
|
* types set up in Settings > Configuration > Program; each option carries the type's description, which
|
||||||
* Assets/js/mt3s-mp-program.js shows under the dropdown. The position field is hidden and kept in display order by
|
* Assets/js/mt3s-mp-program.js shows under the dropdown. The position field is hidden and kept in display order by
|
||||||
* mt3s-mp-program.js.
|
* mt3s-mp-program.js.
|
||||||
*
|
|
||||||
* @extends AbstractType<ProgramDescriptionItem>
|
|
||||||
*/
|
*/
|
||||||
class ProgramDescriptionItemType extends AbstractType
|
class ProgramDescriptionItemType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
* One row of the objectives collection in ProgramType: type, title, priority, description and the achieved
|
* One row of the objectives collection in ProgramType: type, title, priority, description and the achieved
|
||||||
* flag. Works like ProgramDescriptionItemType (type description shown under the dropdown and its pictogram
|
* flag. Works like ProgramDescriptionItemType (type description shown under the dropdown and its pictogram
|
||||||
* next to it, hidden position kept in display order by Assets/js/mt3s-mp-program.js).
|
* next to it, hidden position kept in display order by Assets/js/mt3s-mp-program.js).
|
||||||
*
|
|
||||||
* @extends AbstractType<ProgramObjective>
|
|
||||||
*/
|
*/
|
||||||
class ProgramObjectiveType extends AbstractType
|
class ProgramObjectiveType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -58,7 +56,7 @@ class ProgramObjectiveType extends AbstractType
|
|||||||
'label' => 'mt3s.marketing_program.objective.field.priority',
|
'label' => 'mt3s.marketing_program.objective.field.priority',
|
||||||
'label_attr' => ['class' => 'control-label'],
|
'label_attr' => ['class' => 'control-label'],
|
||||||
'invalid_message' => 'mt3s.marketing_program.objective.priority.range',
|
'invalid_message' => 'mt3s.marketing_program.objective.priority.range',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control',
|
'class' => 'form-control',
|
||||||
'min' => ProgramObjective::PRIORITY_MIN,
|
'min' => ProgramObjective::PRIORITY_MIN,
|
||||||
'max' => ProgramObjective::PRIORITY_MAX,
|
'max' => ProgramObjective::PRIORITY_MAX,
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
* One row of the stakeholders collection in ProgramType: a stakeholder of the global directory (only the
|
* One row of the stakeholders collection in ProgramType: a stakeholder of the global directory (only the
|
||||||
* active ones are offered) and the stakeholder's role in this plan. The position field is hidden and
|
* active ones are offered) and the stakeholder's role in this plan. The position field is hidden and
|
||||||
* kept in display order by Assets/js/mt3s-mp-program.js.
|
* kept in display order by Assets/js/mt3s-mp-program.js.
|
||||||
*
|
|
||||||
* @extends AbstractType<ProgramStakeholder>
|
|
||||||
*/
|
*/
|
||||||
class ProgramStakeholderType extends AbstractType
|
class ProgramStakeholderType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ use Mautic\UserBundle\Form\Type\UserListType;
|
|||||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramStatus;
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramStatus;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
|
use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\ProgramAudienceType;
|
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\ProgramStakeholderType;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||||
@@ -27,9 +25,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
|
||||||
* @extends AbstractType<Program>
|
|
||||||
*/
|
|
||||||
class ProgramType extends AbstractType
|
class ProgramType extends AbstractType
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@@ -81,15 +76,15 @@ class ProgramType extends AbstractType
|
|||||||
// The Audiences tab's links to the global directory. by_reference false: Symfony calls
|
// The Audiences tab's links to the global directory. by_reference false: Symfony calls
|
||||||
// Program::addAudience()/removeAudience().
|
// Program::addAudience()/removeAudience().
|
||||||
$builder->add('audiences', CollectionType::class, [
|
$builder->add('audiences', CollectionType::class, [
|
||||||
'label' => 'mt3s.marketing_program.field.audiences',
|
'label' => 'mt3s.marketing_program.field.audiences',
|
||||||
'entry_type' => ProgramAudienceType::class,
|
'entry_type' => ProgramAudienceType::class,
|
||||||
'entry_options' => ['label' => false],
|
'entry_options' => ['label' => false],
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
'allow_delete' => true,
|
'allow_delete' => true,
|
||||||
'by_reference' => false,
|
'by_reference' => false,
|
||||||
'prototype' => true,
|
'prototype' => true,
|
||||||
'prototype_name' => '__audience__',
|
'prototype_name' => '__audience__',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// The Stakeholders tab's links to the global directory. by_reference false: Symfony calls
|
// The Stakeholders tab's links to the global directory. by_reference false: Symfony calls
|
||||||
@@ -110,7 +105,7 @@ class ProgramType extends AbstractType
|
|||||||
'label' => 'mt3s.marketing_program.field.version',
|
'label' => 'mt3s.marketing_program.field.version',
|
||||||
'label_attr' => ['class' => 'control-label'],
|
'label_attr' => ['class' => 'control-label'],
|
||||||
'invalid_message' => 'mt3s.marketing_program.version.range',
|
'invalid_message' => 'mt3s.marketing_program.version.range',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control',
|
'class' => 'form-control',
|
||||||
'min' => Program::VERSION_MIN,
|
'min' => Program::VERSION_MIN,
|
||||||
'max' => Program::VERSION_MAX,
|
'max' => Program::VERSION_MAX,
|
||||||
|
|||||||
+28
-31
@@ -48,8 +48,6 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||||||
* data-show-on switcher shows the fieldset of the chosen taxonomy; the values posted for
|
* data-show-on switcher shows the fieldset of the chosen taxonomy; the values posted for
|
||||||
* the others are dropped on submit. A stored value outside the list stays selectable,
|
* the others are dropped on submit. A stored value outside the list stays selectable,
|
||||||
* labelled "(not in taxonomy)", so an old link is still editable.
|
* labelled "(not in taxonomy)", so an old link is still editable.
|
||||||
*
|
|
||||||
* @extends AbstractType<SmartLink>
|
|
||||||
*/
|
*/
|
||||||
final class SmartLinkType extends AbstractType
|
final class SmartLinkType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -84,22 +82,22 @@ final class SmartLinkType extends AbstractType
|
|||||||
// on save, exactly like the live preview does. The constraints only guard the raw input;
|
// on save, exactly like the live preview does. The constraints only guard the raw input;
|
||||||
// spaces are allowed here because they are turned into the separator on save.
|
// spaces are allowed here because they are turned into the separator on save.
|
||||||
$builder->add('slug', TextType::class, [
|
$builder->add('slug', TextType::class, [
|
||||||
'label' => 'mautic.smartlinks.smart_links.slug',
|
'label' => 'mt3s.smart_links.smart_links.slug',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'disabled' => $isSaved,
|
'disabled' => $isSaved,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control smart-link-slug',
|
'class' => 'form-control smart-link-slug',
|
||||||
'maxlength' => SmartLink::SLUG_MAX_LENGTH,
|
'maxlength' => SmartLink::SLUG_MAX_LENGTH,
|
||||||
'tooltip' => 'mautic.smartlinks.smart_links.slug.tooltip',
|
'tooltip' => 'mt3s.smart_links.smart_links.slug.tooltip',
|
||||||
// Live preview of the short link: the JS fills the span next to the field.
|
// Live preview of the short link: the JS fills the span next to the field.
|
||||||
'data-preview' => 'smart-link-preview',
|
'data-preview' => 'smart-link-preview',
|
||||||
],
|
],
|
||||||
'constraints' => $isSaved ? [] : [
|
'constraints' => $isSaved ? [] : [
|
||||||
new NotBlank(message: 'mautic.smartlinks.smart_links.error.slug_required'),
|
new NotBlank(message: 'mt3s.smart_links.smart_links.error.slug_required'),
|
||||||
new Length(max: SmartLink::SLUG_MAX_LENGTH, maxMessage: 'mautic.smartlinks.smart_links.error.slug_length'),
|
new Length(max: SmartLink::SLUG_MAX_LENGTH, maxMessage: 'mt3s.smart_links.smart_links.error.slug_length'),
|
||||||
new Regex(
|
new Regex(
|
||||||
pattern: '/^[\p{L}0-9\-_. ]*$/u',
|
pattern: '/^[\p{L}0-9\-_. ]*$/u',
|
||||||
message: 'mautic.smartlinks.smart_links.error.slug_characters'
|
message: 'mt3s.smart_links.smart_links.error.slug_characters'
|
||||||
),
|
),
|
||||||
new Callback(callback: $this->validateSlug(...)),
|
new Callback(callback: $this->validateSlug(...)),
|
||||||
],
|
],
|
||||||
@@ -107,40 +105,40 @@ final class SmartLinkType extends AbstractType
|
|||||||
|
|
||||||
// -- Redirect ------------------------------------------------------------
|
// -- Redirect ------------------------------------------------------------
|
||||||
$builder->add('redirectType', EnumType::class, [
|
$builder->add('redirectType', EnumType::class, [
|
||||||
'label' => 'mautic.smartlinks.smart_links.redirect_type',
|
'label' => 'mt3s.smart_links.smart_links.redirect_type',
|
||||||
'class' => SmartLinkRedirectType::class,
|
'class' => SmartLinkRedirectType::class,
|
||||||
'choice_label' => fn (SmartLinkRedirectType $type): string => $this->translator->trans($type->getLabelKey()),
|
'choice_label' => fn (SmartLinkRedirectType $type): string => $this->translator->trans($type->getLabelKey()),
|
||||||
'attr' => ['class' => 'form-control smart-link-redirect-type'],
|
'attr' => ['class' => 'form-control smart-link-redirect-type'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('redirectCode', EnumType::class, [
|
$builder->add('redirectCode', EnumType::class, [
|
||||||
'label' => 'mautic.smartlinks.smart_links.redirect_code',
|
'label' => 'mt3s.smart_links.smart_links.redirect_code',
|
||||||
'class' => SmartLinkRedirectCode::class,
|
'class' => SmartLinkRedirectCode::class,
|
||||||
'choice_label' => fn (SmartLinkRedirectCode $code): string => $code->getTranslatedLabel($this->translator),
|
'choice_label' => fn (SmartLinkRedirectCode $code): string => $code->getTranslatedLabel($this->translator),
|
||||||
'attr' => ['class' => 'form-control smart-link-redirect-code'],
|
'attr' => ['class' => 'form-control smart-link-redirect-code'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('destinationUrl', UrlType::class, [
|
$builder->add('destinationUrl', UrlType::class, [
|
||||||
'label' => 'mautic.smartlinks.smart_links.destination_url',
|
'label' => 'mt3s.smart_links.smart_links.destination_url',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control smart-link-destination',
|
'class' => 'form-control smart-link-destination',
|
||||||
'tooltip' => 'mautic.smartlinks.smart_links.destination_url.tooltip',
|
'tooltip' => 'mt3s.smart_links.smart_links.destination_url.tooltip',
|
||||||
],
|
],
|
||||||
'constraints' => [new Callback(callback: $this->validateDestination(...))],
|
'constraints' => [new Callback(callback: $this->validateDestination(...))],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// -- Mautic destination: a landing page or a standalone form -------------------------
|
// -- Mautic destination: a landing page or a standalone form -------------------------
|
||||||
$builder->add('destination', ChoiceType::class, [
|
$builder->add('destination', ChoiceType::class, [
|
||||||
'label' => 'mautic.smartlinks.smart_links.destination',
|
'label' => 'mt3s.smart_links.smart_links.destination',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'mapped' => false,
|
'mapped' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control smart-link-mautic-destination',
|
'class' => 'form-control smart-link-mautic-destination',
|
||||||
'tooltip' => 'mautic.smartlinks.smart_links.destination.tooltip',
|
'tooltip' => 'mt3s.smart_links.smart_links.destination.tooltip',
|
||||||
],
|
],
|
||||||
'choices' => $this->buildMauticDestinationChoices($smartLink),
|
'choices' => $this->buildMauticDestinationChoices($smartLink),
|
||||||
'placeholder' => 'mautic.smartlinks.form.choose',
|
'placeholder' => 'mt3s.smart_links.form.choose',
|
||||||
'data' => $this->currentMauticDestination($smartLink),
|
'data' => $this->currentMauticDestination($smartLink),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -150,16 +148,16 @@ final class SmartLinkType extends AbstractType
|
|||||||
// taxonomy that is no longer published stays selectable, so an old link is still
|
// taxonomy that is no longer published stays selectable, so an old link is still
|
||||||
// editable (a new one can always be chosen instead).
|
// editable (a new one can always be chosen instead).
|
||||||
$builder->add('taxonomy', ChoiceType::class, [
|
$builder->add('taxonomy', ChoiceType::class, [
|
||||||
'label' => 'mautic.smartlinks.smart_links.taxonomy',
|
'label' => 'mt3s.smart_links.smart_links.taxonomy',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'placeholder' => 'mautic.smartlinks.form.choose',
|
'placeholder' => 'mt3s.smart_links.form.choose',
|
||||||
'choices' => $this->buildTaxonomyChoices($smartLink),
|
'choices' => $this->buildTaxonomyChoices($smartLink),
|
||||||
'choice_value' => fn (?UtmTaxonomy $taxonomy): string => (string) ($taxonomy?->getId() ?? ''),
|
'choice_value' => fn (?UtmTaxonomy $taxonomy): string => (string) ($taxonomy?->getId() ?? ''),
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control smart-link-taxonomy',
|
'class' => 'form-control smart-link-taxonomy',
|
||||||
'tooltip' => 'mautic.smartlinks.smart_links.taxonomy.tooltip',
|
'tooltip' => 'mt3s.smart_links.smart_links.taxonomy.tooltip',
|
||||||
],
|
],
|
||||||
'constraints' => [new NotBlank(message: 'mautic.smartlinks.smart_links.error.taxonomy_required')],
|
'constraints' => [new NotBlank(message: 'mt3s.smart_links.smart_links.error.taxonomy_required')],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// -- UTM parameters ------------------------------------------------------------
|
// -- UTM parameters ------------------------------------------------------------
|
||||||
@@ -183,7 +181,6 @@ final class SmartLinkType extends AbstractType
|
|||||||
$this->buildTaxonomyFieldOptions($taxonomy, $key, $smartLink)
|
$this->buildTaxonomyFieldOptions($taxonomy, $key, $smartLink)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The stored values (parameter key => value) feed the fieldset children
|
// The stored values (parameter key => value) feed the fieldset children
|
||||||
@@ -322,7 +319,7 @@ final class SmartLinkType extends AbstractType
|
|||||||
foreach ($this->getFormTaxonomies($smartLink) as $taxonomy) {
|
foreach ($this->getFormTaxonomies($smartLink) as $taxonomy) {
|
||||||
$label = (string) $taxonomy->getName();
|
$label = (string) $taxonomy->getName();
|
||||||
if (!$taxonomy->isPublished()) {
|
if (!$taxonomy->isPublished()) {
|
||||||
$label = $this->translator->trans('mautic.smartlinks.taxonomies.unpublished_choice', ['%name%' => $label]);
|
$label = $this->translator->trans('mt3s.smart_links.taxonomies.unpublished_choice', ['%name%' => $label]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$choices[$label] = $taxonomy;
|
$choices[$label] = $taxonomy;
|
||||||
@@ -348,7 +345,7 @@ final class SmartLinkType extends AbstractType
|
|||||||
$stored = (string) ($smartLink->getUtmParameters()[$key] ?? '');
|
$stored = (string) ($smartLink->getUtmParameters()[$key] ?? '');
|
||||||
if ('' !== $stored && !\in_array($stored, $choices, true)) {
|
if ('' !== $stored && !\in_array($stored, $choices, true)) {
|
||||||
$choices = [
|
$choices = [
|
||||||
$this->translator->trans('mautic.smartlinks.form.legacy_choice', ['%value%' => $stored]) => $stored,
|
$this->translator->trans('mt3s.smart_links.form.legacy_choice', ['%value%' => $stored]) => $stored,
|
||||||
] + $choices;
|
] + $choices;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +355,7 @@ final class SmartLinkType extends AbstractType
|
|||||||
'label' => (string) ($parameter['label'] ?? $key),
|
'label' => (string) ($parameter['label'] ?? $key),
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'choices' => $choices,
|
'choices' => $choices,
|
||||||
'placeholder' => 'mautic.smartlinks.form.choose',
|
'placeholder' => 'mt3s.smart_links.form.choose',
|
||||||
'attr' => ['class' => 'form-control smart-link-utm'],
|
'attr' => ['class' => 'form-control smart-link-utm'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -506,20 +503,20 @@ final class SmartLinkType extends AbstractType
|
|||||||
private function buildMauticDestinationChoices(SmartLink $smartLink): array
|
private function buildMauticDestinationChoices(SmartLink $smartLink): array
|
||||||
{
|
{
|
||||||
$choices = [];
|
$choices = [];
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
$pages = $this->getPageRepository()->findBy(['isPublished' => true], ['title' => 'ASC']);
|
$pages = $this->getPageRepository()->findBy(['isPublished' => true], ['title' => 'ASC']);
|
||||||
foreach ($pages as $page) {
|
foreach ($pages as $page) {
|
||||||
$value = 'page:'.$page->getId();
|
$value = 'page:'.$page->getId();
|
||||||
$choices['mautic.smartlinks.smart_links.destination.pages'][$page->getTitle()] = $value;
|
$choices['mt3s.smart_links.smart_links.destination.pages'][$page->getTitle()] = $value;
|
||||||
$values[] = $value;
|
$values[] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$forms = $this->getFormRepository()->findBy(['isPublished' => true], ['name' => 'ASC']);
|
$forms = $this->getFormRepository()->findBy(['isPublished' => true], ['name' => 'ASC']);
|
||||||
foreach ($forms as $form) {
|
foreach ($forms as $form) {
|
||||||
$value = 'form:'.$form->getId();
|
$value = 'form:'.$form->getId();
|
||||||
$choices['mautic.smartlinks.smart_links.destination.forms'][$form->getName()] = $value;
|
$choices['mt3s.smart_links.smart_links.destination.forms'][$form->getName()] = $value;
|
||||||
$values[] = $value;
|
$values[] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A stored destination that is no longer published stays selectable, so an old link
|
// A stored destination that is no longer published stays selectable, so an old link
|
||||||
@@ -528,8 +525,8 @@ final class SmartLinkType extends AbstractType
|
|||||||
// back to index-based values for every option.
|
// back to index-based values for every option.
|
||||||
$current = $this->currentMauticDestination($smartLink);
|
$current = $this->currentMauticDestination($smartLink);
|
||||||
if (null !== $current && !in_array($current, $values, true)) {
|
if (null !== $current && !in_array($current, $values, true)) {
|
||||||
$label = $smartLink->getPage()?->getTitle() ?? $smartLink->getForm()?->getName() ?? '';
|
$label = $smartLink->getPage()?->getTitle() ?? $smartLink->getForm()?->getName() ?? '';
|
||||||
$choices['mautic.smartlinks.smart_links.destination.unpublished'][$label] = $current;
|
$choices['mt3s.smart_links.smart_links.destination.unpublished'][$label] = $current;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $choices;
|
return $choices;
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
* The single "Smart Links Settings" tab of Settings > Configuration: the general UTM rules and
|
* The single "Smart Links Settings" tab of Settings > Configuration: the general UTM rules and
|
||||||
* the short link domain (section "UTM Settings"), the catalog and custom parameters (section
|
* the short link domain (section "UTM Settings"), the catalog and custom parameters (section
|
||||||
* "Parameters"). Each child is a local.php parameter.
|
* "Parameters"). Each child is a local.php parameter.
|
||||||
*
|
|
||||||
* @extends AbstractType<array<string, mixed>>
|
|
||||||
*/
|
*/
|
||||||
final class SmartLinksConfigType extends AbstractType
|
final class SmartLinksConfigType extends AbstractType
|
||||||
{
|
{
|
||||||
/** Stored in local.php under this key (an array: short_link_domain => domain). */
|
/** Stored in local.php under this key (an array: short_link_domain => domain). */
|
||||||
public const CONFIG_PARAMETER = 'smartlinks_config';
|
public const CONFIG_PARAMETER = 'mt3s_smart_links_config';
|
||||||
|
|
||||||
|
/** Key of the standalone SmartlinksBundle era (0.1.0–0.18.0); still honored until the domain is saved again. */
|
||||||
|
public const LEGACY_SMARTLINKS_PARAMETER = 'smartlinks_config';
|
||||||
|
|
||||||
/** Key of the UtmManagerBundle era (< 0.5.0); still honored until the domain is saved again. */
|
/** Key of the UtmManagerBundle era (< 0.5.0); still honored until the domain is saved again. */
|
||||||
public const LEGACY_CONFIG_PARAMETER = 'utm_manager_smart_links';
|
public const LEGACY_CONFIG_PARAMETER = 'utm_manager_smart_links';
|
||||||
@@ -33,11 +34,11 @@ final class SmartLinksConfigType extends AbstractType
|
|||||||
$builder->add(self::CONFIG_PARAMETER, FormType::class, ['label' => false]);
|
$builder->add(self::CONFIG_PARAMETER, FormType::class, ['label' => false]);
|
||||||
|
|
||||||
$builder->get(self::CONFIG_PARAMETER)->add('short_link_domain', TextType::class, [
|
$builder->get(self::CONFIG_PARAMETER)->add('short_link_domain', TextType::class, [
|
||||||
'label' => 'mautic.smartlinks.settings.short_link_domain',
|
'label' => 'mt3s.smart_links.settings.short_link_domain',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control',
|
'class' => 'form-control',
|
||||||
'tooltip' => 'mautic.smartlinks.settings.short_link_domain.tooltip',
|
'tooltip' => 'mt3s.smart_links.settings.short_link_domain.tooltip',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -47,4 +48,4 @@ final class SmartLinksConfigType extends AbstractType
|
|||||||
// The Configuration tab title key: mautic.config.tab.smartlinksconfig.
|
// The Configuration tab title key: mautic.config.tab.smartlinksconfig.
|
||||||
return 'smartlinksconfig';
|
return 'smartlinksconfig';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,9 +16,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `smartlinks_utm_config` parameter: general settings, catalog parameters and custom parameters.
|
* The `mt3s_smart_links_utm_config` parameter: general settings, catalog parameters and custom parameters.
|
||||||
*
|
|
||||||
* @extends AbstractType<array<string, mixed>>
|
|
||||||
*/
|
*/
|
||||||
final class SmartlinksSettingsType extends AbstractType
|
final class SmartlinksSettingsType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -31,23 +29,23 @@ final class SmartlinksSettingsType extends AbstractType
|
|||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
$builder->add('enforce_lowercase', YesNoButtonGroupType::class, [
|
$builder->add('enforce_lowercase', YesNoButtonGroupType::class, [
|
||||||
'label' => 'mautic.smartlinks.config.enforce_lowercase',
|
'label' => 'mt3s.smart_links.config.enforce_lowercase',
|
||||||
'attr' => ['tooltip' => 'mautic.smartlinks.config.enforce_lowercase.tooltip'],
|
'attr' => ['tooltip' => 'mt3s.smart_links.config.enforce_lowercase.tooltip'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('separator_replacement', ChoiceType::class, [
|
$builder->add('separator_replacement', ChoiceType::class, [
|
||||||
'label' => 'mautic.smartlinks.config.separator_replacement',
|
'label' => 'mt3s.smart_links.config.separator_replacement',
|
||||||
'choices' => [
|
'choices' => [
|
||||||
'mautic.smartlinks.config.separator.hyphen' => '-',
|
'mt3s.smart_links.config.separator.hyphen' => '-',
|
||||||
'mautic.smartlinks.config.separator.underscore' => '_',
|
'mt3s.smart_links.config.separator.underscore' => '_',
|
||||||
'mautic.smartlinks.config.separator.dot' => '.',
|
'mt3s.smart_links.config.separator.dot' => '.',
|
||||||
],
|
],
|
||||||
'placeholder' => false,
|
'placeholder' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control',
|
'class' => 'form-control',
|
||||||
'tooltip' => 'mautic.smartlinks.config.separator_replacement.tooltip',
|
'tooltip' => 'mt3s.smart_links.config.separator_replacement.tooltip',
|
||||||
],
|
],
|
||||||
'invalid_message' => 'mautic.smartlinks.config.error.separator_invalid',
|
'invalid_message' => 'mt3s.smart_links.config.error.separator_invalid',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$parameters = $builder->create('parameters', FormType::class, ['label' => false]);
|
$parameters = $builder->create('parameters', FormType::class, ['label' => false]);
|
||||||
@@ -85,6 +83,6 @@ final class SmartlinksSettingsType extends AbstractType
|
|||||||
|
|
||||||
public function getBlockPrefix(): string
|
public function getBlockPrefix(): string
|
||||||
{
|
{
|
||||||
return 'smartlinks_utm_settings';
|
return 'mt3s_smart_links_utm_settings';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
|
||||||
|
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Stakeholder;
|
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
|
|
||||||
use Mautic\CoreBundle\Form\Type\FormButtonsType;
|
use Mautic\CoreBundle\Form\Type\FormButtonsType;
|
||||||
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
|
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Stakeholder;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||||
@@ -18,8 +18,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The create and edit form of a stakeholder of the global directory (Programs > Stakeholders).
|
* The create and edit form of a stakeholder of the global directory (Programs > Stakeholders).
|
||||||
*
|
|
||||||
* @extends AbstractType<Stakeholder>
|
|
||||||
*/
|
*/
|
||||||
class StakeholderType extends AbstractType
|
class StakeholderType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
* One row of the dependencies collection in TaskType: the task this one depends on, and the type of
|
* One row of the dependencies collection in TaskType: the task this one depends on, and the type of
|
||||||
* the relation. Only the tasks of the same program are offered; cycles and self-edges are refused by
|
* the relation. Only the tasks of the same program are offered; cycles and self-edges are refused by
|
||||||
* ValidTaskDependency.
|
* ValidTaskDependency.
|
||||||
*
|
|
||||||
* @extends AbstractType<TaskDependency>
|
|
||||||
*/
|
*/
|
||||||
class TaskDependencyType extends AbstractType
|
class TaskDependencyType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
/**
|
/**
|
||||||
* One row of the RACI collection in TaskType: a role (R/A/C/I) and the stakeholders carrying it.
|
* One row of the RACI collection in TaskType: a role (R/A/C/I) and the stakeholders carrying it.
|
||||||
* The stakeholders are picked from the program's assigned stakeholders; several may share a role.
|
* The stakeholders are picked from the program's assigned stakeholders; several may share a role.
|
||||||
*
|
|
||||||
* @extends AbstractType<TaskRaci>
|
|
||||||
*/
|
*/
|
||||||
class TaskRaciType extends AbstractType
|
class TaskRaciType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|||||||
+19
-3
@@ -22,6 +22,8 @@ use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
|||||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\Form\FormEvent;
|
||||||
|
use Symfony\Component\Form\FormEvents;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,8 +32,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
* Kind rules: a milestone's end date is enslaved to its start date (the entity's setTaskKind copies
|
* Kind rules: a milestone's end date is enslaved to its start date (the entity's setTaskKind copies
|
||||||
* the start onto the end, and the TaskDates validator keeps it in step); a phase has no status
|
* the start onto the end, and the TaskDates validator keeps it in step); a phase has no status
|
||||||
* field — its state comes from its tasks.
|
* field — its state comes from its tasks.
|
||||||
*
|
|
||||||
* @extends AbstractType<Task>
|
|
||||||
*/
|
*/
|
||||||
class TaskType extends AbstractType
|
class TaskType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ class TaskType extends AbstractType
|
|||||||
$builder->addEventSubscriber(new CleanFormSubscriber(['description' => 'strict_html']));
|
$builder->addEventSubscriber(new CleanFormSubscriber(['description' => 'strict_html']));
|
||||||
|
|
||||||
/** @var Task $task */
|
/** @var Task $task */
|
||||||
$task = $options['data'];
|
$task = $options['data'];
|
||||||
$program = $task->getProgram();
|
$program = $task->getProgram();
|
||||||
|
|
||||||
$kind = ItemTypeProvider::KIND_TASK;
|
$kind = ItemTypeProvider::KIND_TASK;
|
||||||
@@ -61,6 +61,22 @@ class TaskType extends AbstractType
|
|||||||
'choice_label' => fn (TaskKind $k): string => $k->getLabelKey(),
|
'choice_label' => fn (TaskKind $k): string => $k->getLabelKey(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// A submitted form always carries a kind: an absent or empty taskKind (a browser
|
||||||
|
// POST that lost the select, or an ajax save) defaults to a regular task, so the
|
||||||
|
// NOT NULL column can never receive null (see Task::$taskKind).
|
||||||
|
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event): void {
|
||||||
|
$data = $event->getData();
|
||||||
|
|
||||||
|
if (!is_array($data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($data['taskKind']) || '' === $data['taskKind']) {
|
||||||
|
$data['taskKind'] = TaskKind::Task->value;
|
||||||
|
$event->setData($data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$builder->add('type', ChoiceType::class, [
|
$builder->add('type', ChoiceType::class, [
|
||||||
'label' => 'mt3s.marketing_program.task.field.type',
|
'label' => 'mt3s.marketing_program.task.field.type',
|
||||||
'label_attr' => ['class' => 'control-label'],
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* One parameter row: a catalog entry (option `definition`) or a custom parameter (`definition` = null).
|
* One parameter row: a catalog entry (option `definition`) or a custom parameter (`definition` = null).
|
||||||
*
|
|
||||||
* @extends AbstractType<array<string, mixed>>
|
|
||||||
*/
|
*/
|
||||||
final class UtmParameterType extends AbstractType
|
final class UtmParameterType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -48,9 +46,9 @@ final class UtmParameterType extends AbstractType
|
|||||||
public static function labelConstraints(): array
|
public static function labelConstraints(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new NotBlank(message: 'mautic.smartlinks.config.error.label_required'),
|
new NotBlank(message: 'mt3s.smart_links.config.error.label_required'),
|
||||||
new Length(max: UtmSettingsValidator::MAX_LENGTH, maxMessage: 'mautic.smartlinks.config.error.label_length'),
|
new Length(max: UtmSettingsValidator::MAX_LENGTH, maxMessage: 'mt3s.smart_links.config.error.label_length'),
|
||||||
new Regex(pattern: '/%/', match: false, message: 'mautic.smartlinks.config.error.label_invalid'),
|
new Regex(pattern: '/%/', match: false, message: 'mt3s.smart_links.config.error.label_invalid'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,44 +60,44 @@ final class UtmParameterType extends AbstractType
|
|||||||
|
|
||||||
if (null === $definition) {
|
if (null === $definition) {
|
||||||
$builder->add('key', TextType::class, [
|
$builder->add('key', TextType::class, [
|
||||||
'label' => 'mautic.smartlinks.config.parameter.key',
|
'label' => 'mt3s.smart_links.config.parameter.key',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control utm-custom-key',
|
'class' => 'form-control utm-custom-key',
|
||||||
'tooltip' => 'mautic.smartlinks.config.parameter.key.tooltip',
|
'tooltip' => 'mt3s.smart_links.config.parameter.key.tooltip',
|
||||||
'maxlength' => 41,
|
'maxlength' => 41,
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(message: 'mautic.smartlinks.config.error.key_required'),
|
new NotBlank(message: 'mt3s.smart_links.config.error.key_required'),
|
||||||
new Callback(callback: $this->validateCustomKey(...)),
|
new Callback(callback: $this->validateCustomKey(...)),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->add('enabled', YesNoButtonGroupType::class, [
|
$builder->add('enabled', YesNoButtonGroupType::class, [
|
||||||
'label' => 'mautic.smartlinks.config.parameter.enabled',
|
'label' => 'mt3s.smart_links.config.parameter.enabled',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('label', TextType::class, [
|
$builder->add('label', TextType::class, [
|
||||||
'label' => 'mautic.smartlinks.config.parameter.label',
|
'label' => 'mt3s.smart_links.config.parameter.label',
|
||||||
'attr' => ['class' => 'form-control', 'maxlength' => UtmSettingsValidator::MAX_LENGTH],
|
'attr' => ['class' => 'form-control', 'maxlength' => UtmSettingsValidator::MAX_LENGTH],
|
||||||
'constraints' => self::labelConstraints(),
|
'constraints' => self::labelConstraints(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$modeAttr = ['class' => 'form-control utm-mode'];
|
$modeAttr = ['class' => 'form-control utm-mode'];
|
||||||
if ($definition?->autoGenerated) {
|
if ($definition?->autoGenerated) {
|
||||||
$modeAttr['tooltip'] = 'mautic.smartlinks.config.auto_generated.tooltip';
|
$modeAttr['tooltip'] = 'mt3s.smart_links.config.auto_generated.tooltip';
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->add('mode', ChoiceType::class, [
|
$builder->add('mode', ChoiceType::class, [
|
||||||
'label' => 'mautic.smartlinks.config.parameter.mode',
|
'label' => 'mt3s.smart_links.config.parameter.mode',
|
||||||
'choices' => array_combine(
|
'choices' => array_combine(
|
||||||
array_map(fn (string $mode): string => 'mautic.smartlinks.config.mode.'.$mode, $allowedModes),
|
array_map(fn (string $mode): string => 'mt3s.smart_links.config.mode.'.$mode, $allowedModes),
|
||||||
$allowedModes
|
$allowedModes
|
||||||
),
|
),
|
||||||
'placeholder' => false,
|
'placeholder' => false,
|
||||||
'attr' => $modeAttr,
|
'attr' => $modeAttr,
|
||||||
'invalid_message' => 'mautic.smartlinks.config.error.mode_invalid',
|
'invalid_message' => 'mt3s.smart_links.config.error.mode_invalid',
|
||||||
'constraints' => [new NotBlank(message: 'mautic.smartlinks.config.error.mode_invalid')],
|
'constraints' => [new NotBlank(message: 'mt3s.smart_links.config.error.mode_invalid')],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Values only exist in dropdown mode: drop anything submitted for other modes (or for parameters
|
// Values only exist in dropdown mode: drop anything submitted for other modes (or for parameters
|
||||||
@@ -137,15 +135,15 @@ final class UtmParameterType extends AbstractType
|
|||||||
|
|
||||||
$view->vars['utm_custom'] = null === $definition;
|
$view->vars['utm_custom'] = null === $definition;
|
||||||
$view->vars['utm_key'] = $definition?->key;
|
$view->vars['utm_key'] = $definition?->key;
|
||||||
$view->vars['utm_group'] = $definition?->group ?? UtmParameterCatalog::GROUP_CUSTOM;
|
$view->vars['utm_group'] = $definition->group ?? UtmParameterCatalog::GROUP_CUSTOM;
|
||||||
$view->vars['utm_description_key'] = $definition?->getDescriptionKey();
|
$view->vars['utm_description_key'] = $definition?->getDescriptionKey();
|
||||||
$view->vars['utm_auto_generated'] = $definition?->autoGenerated ?? false;
|
$view->vars['utm_auto_generated'] = $definition->autoGenerated ?? false;
|
||||||
$view->vars['utm_suggestions'] = array_map(
|
$view->vars['utm_suggestions'] = array_map(
|
||||||
fn (string $value): array => [
|
fn (string $value): array => [
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
'label' => $this->translator->trans(UtmParameterDefinition::getSuggestionLabelKey($value)),
|
'label' => $this->translator->trans(UtmParameterDefinition::getSuggestionLabelKey($value)),
|
||||||
],
|
],
|
||||||
$definition?->suggestions ?? []
|
$definition->suggestions ?? []
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
|
|||||||
use Mautic\CoreBundle\Form\Type\FormButtonsType;
|
use Mautic\CoreBundle\Form\Type\FormButtonsType;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
|
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy;
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Form\Validator\UtmSettingsValidator;
|
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Form\Validator\UtmTaxonomyValidator;
|
use MauticPlugin\MT3SMarketingProgramBundle\Form\Validator\UtmTaxonomyValidator;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider;
|
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
@@ -35,8 +34,6 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||||||
* selection -- nothing can be typed), and a `free` parameter gets its own editable value
|
* selection -- nothing can be typed), and a `free` parameter gets its own editable value
|
||||||
* list here (one `value` or `value;Label` per line): a Smart Link using this taxonomy picks
|
* list here (one `value` or `value;Label` per line): a Smart Link using this taxonomy picks
|
||||||
* a value from it instead of typing freely.
|
* a value from it instead of typing freely.
|
||||||
*
|
|
||||||
* @extends AbstractType<UtmTaxonomy>
|
|
||||||
*/
|
*/
|
||||||
final class UtmTaxonomyType extends AbstractType
|
final class UtmTaxonomyType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -49,26 +46,26 @@ final class UtmTaxonomyType extends AbstractType
|
|||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
$builder->add('name', TextType::class, [
|
$builder->add('name', TextType::class, [
|
||||||
'label' => 'mautic.smartlinks.taxonomies.name',
|
'label' => 'mt3s.smart_links.taxonomies.name',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control',
|
'class' => 'form-control',
|
||||||
'maxlength' => UtmTaxonomy::NAME_MAX_LENGTH,
|
'maxlength' => UtmTaxonomy::NAME_MAX_LENGTH,
|
||||||
'tooltip' => 'mautic.smartlinks.taxonomies.name.tooltip',
|
'tooltip' => 'mt3s.smart_links.taxonomies.name.tooltip',
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(message: 'mautic.smartlinks.taxonomies.error.name_required'),
|
new NotBlank(message: 'mt3s.smart_links.taxonomies.error.name_required'),
|
||||||
new Length(max: UtmTaxonomy::NAME_MAX_LENGTH, maxMessage: 'mautic.smartlinks.taxonomies.error.name_length'),
|
new Length(max: UtmTaxonomy::NAME_MAX_LENGTH, maxMessage: 'mt3s.smart_links.taxonomies.error.name_length'),
|
||||||
new Callback(callback: $this->validateName(...)),
|
new Callback(callback: $this->validateName(...)),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('description', TextareaType::class, [
|
$builder->add('description', TextareaType::class, [
|
||||||
'label' => 'mautic.smartlinks.taxonomies.description',
|
'label' => 'mt3s.smart_links.taxonomies.description',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control',
|
'class' => 'form-control',
|
||||||
'tooltip' => 'mautic.smartlinks.taxonomies.description.tooltip',
|
'tooltip' => 'mt3s.smart_links.taxonomies.description.tooltip',
|
||||||
'rows' => 3,
|
'rows' => 3,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
@@ -114,7 +111,7 @@ final class UtmTaxonomyType extends AbstractType
|
|||||||
if (isset($dropdowns[$key])) {
|
if (isset($dropdowns[$key])) {
|
||||||
$attr = ['class' => 'utm-taxonomy-values'];
|
$attr = ['class' => 'utm-taxonomy-values'];
|
||||||
if ([] === $dropdowns[$key]) {
|
if ([] === $dropdowns[$key]) {
|
||||||
$attr['tooltip'] = 'mautic.smartlinks.taxonomies.no_values.tooltip';
|
$attr['tooltip'] = 'mt3s.smart_links.taxonomies.no_values.tooltip';
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->get('parameters')->add($key, ChoiceType::class, [
|
$builder->get('parameters')->add($key, ChoiceType::class, [
|
||||||
@@ -136,8 +133,8 @@ final class UtmTaxonomyType extends AbstractType
|
|||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control utm-taxonomy-free-values',
|
'class' => 'form-control utm-taxonomy-free-values',
|
||||||
'rows' => 2,
|
'rows' => 2,
|
||||||
'tooltip' => 'mautic.smartlinks.taxonomies.free_values.tooltip',
|
'tooltip' => 'mt3s.smart_links.taxonomies.free_values.tooltip',
|
||||||
'placeholder' => 'mautic.smartlinks.taxonomies.free_values.placeholder',
|
'placeholder' => 'mt3s.smart_links.taxonomies.free_values.placeholder',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -211,7 +208,7 @@ final class UtmTaxonomyType extends AbstractType
|
|||||||
* free ones (a `value;Label` line when the label differs from the value).
|
* free ones (a `value;Label` line when the label differs from the value).
|
||||||
*
|
*
|
||||||
* @param array<string, array<string, string>> $dropdowns
|
* @param array<string, array<string, string>> $dropdowns
|
||||||
* @param list<string> $frees
|
* @param list<string> $frees
|
||||||
*
|
*
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
@@ -268,7 +265,7 @@ final class UtmTaxonomyType extends AbstractType
|
|||||||
* textarea lines become rows (labels default to the value); empty lists drop the key.
|
* textarea lines become rows (labels default to the value); empty lists drop the key.
|
||||||
*
|
*
|
||||||
* @param array<string, array<string, string>> $dropdowns
|
* @param array<string, array<string, string>> $dropdowns
|
||||||
* @param list<string> $frees
|
* @param list<string> $frees
|
||||||
*
|
*
|
||||||
* @return array<string, list<array{value: string, label: string}>>
|
* @return array<string, list<array{value: string, label: string}>>
|
||||||
*/
|
*/
|
||||||
@@ -356,7 +353,7 @@ final class UtmTaxonomyType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param FormInterface|FormBuilderInterface $form
|
* @param FormInterface|FormBuilderInterface $form
|
||||||
* @param list<array{0: string, 1: array<string, string>}> $errors
|
* @param list<array{0: string, 1: array<string, string>}> $errors
|
||||||
*/
|
*/
|
||||||
private function addErrorsOn(object $form, array $errors): void
|
private function addErrorsOn(object $form, array $errors): void
|
||||||
@@ -365,4 +362,4 @@ final class UtmTaxonomyType extends AbstractType
|
|||||||
$form->addError(new FormError($message, null, $parameters));
|
$form->addError(new FormError($message, null, $parameters));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,39 +16,37 @@ use Symfony\Component\Validator\Constraints\Regex;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* One allowed value of a `dropdown` parameter.
|
* One allowed value of a `dropdown` parameter.
|
||||||
*
|
|
||||||
* @extends AbstractType<array<string, mixed>>
|
|
||||||
*/
|
*/
|
||||||
final class UtmValueType extends AbstractType
|
final class UtmValueType extends AbstractType
|
||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
$builder->add('value', TextType::class, [
|
$builder->add('value', TextType::class, [
|
||||||
'label' => 'mautic.smartlinks.config.values.value',
|
'label' => 'mt3s.smart_links.config.values.value',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control utm-value-input',
|
'class' => 'form-control utm-value-input',
|
||||||
'placeholder' => 'mautic.smartlinks.config.values.value',
|
'placeholder' => 'mt3s.smart_links.config.values.value',
|
||||||
'maxlength' => UtmSettingsValidator::MAX_LENGTH,
|
'maxlength' => UtmSettingsValidator::MAX_LENGTH,
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(message: 'mautic.smartlinks.config.error.value_required'),
|
new NotBlank(message: 'mt3s.smart_links.config.error.value_required'),
|
||||||
new Length(max: UtmSettingsValidator::MAX_LENGTH, maxMessage: 'mautic.smartlinks.config.error.value_length'),
|
new Length(max: UtmSettingsValidator::MAX_LENGTH, maxMessage: 'mt3s.smart_links.config.error.value_length'),
|
||||||
new Regex(pattern: UtmSettingsValidator::VALUE_PATTERN, message: 'mautic.smartlinks.config.error.value_invalid'),
|
new Regex(pattern: UtmSettingsValidator::VALUE_PATTERN, message: 'mt3s.smart_links.config.error.value_invalid'),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('label', TextType::class, [
|
$builder->add('label', TextType::class, [
|
||||||
'label' => 'mautic.smartlinks.config.values.label',
|
'label' => 'mt3s.smart_links.config.values.label',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control utm-label-input',
|
'class' => 'form-control utm-label-input',
|
||||||
'placeholder' => 'mautic.smartlinks.config.values.label',
|
'placeholder' => 'mt3s.smart_links.config.values.label',
|
||||||
'maxlength' => UtmSettingsValidator::MAX_LENGTH,
|
'maxlength' => UtmSettingsValidator::MAX_LENGTH,
|
||||||
],
|
],
|
||||||
'constraints' => UtmParameterType::labelConstraints(),
|
'constraints' => UtmParameterType::labelConstraints(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('is_default', CheckboxType::class, [
|
$builder->add('is_default', CheckboxType::class, [
|
||||||
'label' => 'mautic.smartlinks.config.values.default',
|
'label' => 'mt3s.smart_links.config.values.default',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'attr' => ['class' => 'utm-value-default'],
|
'attr' => ['class' => 'utm-value-default'],
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -144,11 +144,11 @@ final class UtmFieldsApplicator
|
|||||||
$storedValue = null === $stored ? '' : (string) $stored;
|
$storedValue = null === $stored ? '' : (string) $stored;
|
||||||
if ('' !== $storedValue && !array_key_exists($storedValue, $labels)) {
|
if ('' !== $storedValue && !array_key_exists($storedValue, $labels)) {
|
||||||
// Legacy value: kept as the last choice so it displays and re-saves without data loss.
|
// Legacy value: kept as the last choice so it displays and re-saves without data loss.
|
||||||
$labels[$storedValue] = $this->translator->trans('mautic.smartlinks.form.legacy_choice', ['%value%' => $storedValue]);
|
$labels[$storedValue] = $this->translator->trans('mt3s.smart_links.form.legacy_choice', ['%value%' => $storedValue]);
|
||||||
$options['help'] = 'mautic.smartlinks.form.legacy_warning';
|
$options['help'] = 'mt3s.smart_links.form.legacy_warning';
|
||||||
$options['help_attr'] = ['class' => 'text-warning'];
|
$options['help_attr'] = ['class' => 'text-warning'];
|
||||||
} elseif ([] === $labels) {
|
} elseif ([] === $labels) {
|
||||||
$options['help'] = 'mautic.smartlinks.form.no_values';
|
$options['help'] = 'mt3s.smart_links.form.no_values';
|
||||||
$options['help_attr'] = ['class' => 'text-warning'];
|
$options['help_attr'] = ['class' => 'text-warning'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,12 +157,12 @@ final class UtmFieldsApplicator
|
|||||||
'choice_label' => static fn (string $value): string => $labels[$value],
|
'choice_label' => static fn (string $value): string => $labels[$value],
|
||||||
// Configured labels are shown as typed. The placeholder is translated here for the same reason.
|
// Configured labels are shown as typed. The placeholder is translated here for the same reason.
|
||||||
'choice_translation_domain' => false,
|
'choice_translation_domain' => false,
|
||||||
'placeholder' => $this->translator->trans('mautic.smartlinks.form.choose'),
|
'placeholder' => $this->translator->trans('mt3s.smart_links.form.choose'),
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'attr' => ['class' => 'form-control'],
|
'attr' => ['class' => 'form-control'],
|
||||||
'invalid_message' => 'mautic.smartlinks.form.error.not_in_taxonomy',
|
'invalid_message' => 'mt3s.smart_links.form.error.not_in_taxonomy',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (null !== $label) {
|
if (null !== $label) {
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ use Mautic\PageBundle\Entity\Page;
|
|||||||
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\SmartLinkRedirectType;
|
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\SmartLinkRedirectType;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
|
use MauticPlugin\MT3SMarketingProgramBundle\Catalog\UtmParameterMode;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy;
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider;
|
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel;
|
use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Service\UtmConfigurationProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Business rules of the Smart Link form. The form type calls these methods from Callback
|
* Business rules of the Smart Link form. The form type calls these methods from Callback
|
||||||
@@ -18,15 +18,15 @@ use MauticPlugin\MT3SMarketingProgramBundle\Model\SmartLinkModel;
|
|||||||
*/
|
*/
|
||||||
final class SmartLinkValidator
|
final class SmartLinkValidator
|
||||||
{
|
{
|
||||||
public const ERROR_SLUG_TAKEN = 'mautic.smartlinks.smart_links.error.slug_taken';
|
public const ERROR_SLUG_TAKEN = 'mt3s.smart_links.smart_links.error.slug_taken';
|
||||||
public const ERROR_SLUG_REQUIRED = 'mautic.smartlinks.smart_links.error.slug_required';
|
public const ERROR_SLUG_REQUIRED = 'mt3s.smart_links.smart_links.error.slug_required';
|
||||||
public const ERROR_SLUG_LENGTH = 'mautic.smartlinks.smart_links.error.slug_length';
|
public const ERROR_SLUG_LENGTH = 'mt3s.smart_links.smart_links.error.slug_length';
|
||||||
public const ERROR_DESTINATION_REQUIRED = 'mautic.smartlinks.smart_links.error.destination_required';
|
public const ERROR_DESTINATION_REQUIRED = 'mt3s.smart_links.smart_links.error.destination_required';
|
||||||
public const ERROR_DESTINATION_REQUIRED_MAUTIC = 'mautic.smartlinks.smart_links.error.destination_required_mautic';
|
public const ERROR_DESTINATION_REQUIRED_MAUTIC = 'mt3s.smart_links.smart_links.error.destination_required_mautic';
|
||||||
public const ERROR_DESTINATION_INVALID = 'mautic.smartlinks.smart_links.error.destination_invalid';
|
public const ERROR_DESTINATION_INVALID = 'mt3s.smart_links.smart_links.error.destination_invalid';
|
||||||
public const ERROR_UTM_VALUE_INVALID = 'mautic.smartlinks.smart_links.error.utm_value_invalid';
|
public const ERROR_UTM_VALUE_INVALID = 'mt3s.smart_links.smart_links.error.utm_value_invalid';
|
||||||
public const ERROR_UTM_VALUE_NOT_ALLOWED = 'mautic.smartlinks.smart_links.error.utm_value_not_allowed';
|
public const ERROR_UTM_VALUE_NOT_ALLOWED = 'mt3s.smart_links.smart_links.error.utm_value_not_allowed';
|
||||||
public const ERROR_TAXONOMY_PARAMETER_UNKNOWN = 'mautic.smartlinks.smart_links.error.taxonomy_parameter_unknown';
|
public const ERROR_TAXONOMY_PARAMETER_UNKNOWN = 'mt3s.smart_links.smart_links.error.taxonomy_parameter_unknown';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly SmartLinkModel $smartLinkModel,
|
private readonly SmartLinkModel $smartLinkModel,
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ final class UtmSettingsValidator
|
|||||||
|
|
||||||
public const MAX_LENGTH = 100;
|
public const MAX_LENGTH = 100;
|
||||||
|
|
||||||
public const ERROR_KEY_INVALID = 'mautic.smartlinks.config.error.key_invalid';
|
public const ERROR_KEY_INVALID = 'mt3s.smart_links.config.error.key_invalid';
|
||||||
public const ERROR_KEY_RESERVED = 'mautic.smartlinks.config.error.key_reserved';
|
public const ERROR_KEY_RESERVED = 'mt3s.smart_links.config.error.key_reserved';
|
||||||
public const ERROR_KEY_DUPLICATE = 'mautic.smartlinks.config.error.key_duplicate';
|
public const ERROR_KEY_DUPLICATE = 'mt3s.smart_links.config.error.key_duplicate';
|
||||||
public const ERROR_VALUES_REQUIRED = 'mautic.smartlinks.config.error.values_required';
|
public const ERROR_VALUES_REQUIRED = 'mt3s.smart_links.config.error.values_required';
|
||||||
public const ERROR_VALUE_DUPLICATE = 'mautic.smartlinks.config.error.value_duplicate';
|
public const ERROR_VALUE_DUPLICATE = 'mt3s.smart_links.config.error.value_duplicate';
|
||||||
public const ERROR_DEFAULT_MULTIPLE = 'mautic.smartlinks.config.error.default_multiple';
|
public const ERROR_DEFAULT_MULTIPLE = 'mt3s.smart_links.config.error.default_multiple';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly UtmParameterCatalog $catalog,
|
private readonly UtmParameterCatalog $catalog,
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ use MauticPlugin\MT3SMarketingProgramBundle\Model\UtmTaxonomyModel;
|
|||||||
*/
|
*/
|
||||||
final class UtmTaxonomyValidator
|
final class UtmTaxonomyValidator
|
||||||
{
|
{
|
||||||
public const ERROR_NAME_TAKEN = 'mautic.smartlinks.taxonomies.error.name_taken';
|
public const ERROR_NAME_TAKEN = 'mt3s.smart_links.taxonomies.error.name_taken';
|
||||||
public const ERROR_NAME_CHARACTERS = 'mautic.smartlinks.taxonomies.error.name_characters';
|
public const ERROR_NAME_CHARACTERS = 'mt3s.smart_links.taxonomies.error.name_characters';
|
||||||
public const ERROR_VALUE_INVALID = 'mautic.smartlinks.taxonomies.error.value_invalid';
|
public const ERROR_VALUE_INVALID = 'mt3s.smart_links.taxonomies.error.value_invalid';
|
||||||
public const ERROR_VALUE_DUPLICATE = 'mautic.smartlinks.config.error.value_duplicate';
|
public const ERROR_VALUE_DUPLICATE = 'mt3s.smart_links.config.error.value_duplicate';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly UtmTaxonomyModel $taxonomyModel,
|
private readonly UtmTaxonomyModel $taxonomyModel,
|
||||||
@@ -70,4 +70,4 @@ final class UtmTaxonomyValidator
|
|||||||
|
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ class MT3SMarketingProgramIntegration extends BasicIntegration implements BasicI
|
|||||||
use ConfigurationTrait;
|
use ConfigurationTrait;
|
||||||
|
|
||||||
public const NAME = 'MT3SMarketingProgram';
|
public const NAME = 'MT3SMarketingProgram';
|
||||||
public const DISPLAY_NAME = 'Marketing Programs';
|
public const DISPLAY_NAME = 'MT3S Marketing Program';
|
||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class SmartlinksIntegration extends BasicIntegration implements BasicInterface
|
|||||||
use ConfigurationTrait;
|
use ConfigurationTrait;
|
||||||
|
|
||||||
public const NAME = 'Smartlinks';
|
public const NAME = 'Smartlinks';
|
||||||
public const DISPLAY_NAME = 'Smartlinks';
|
public const DISPLAY_NAME = 'Smart Links';
|
||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ use Mautic\IntegrationsBundle\Integration\DefaultConfigFormTrait;
|
|||||||
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormInterface;
|
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormInterface;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Integration\SmartlinksIntegration;
|
use MauticPlugin\MT3SMarketingProgramBundle\Integration\SmartlinksIntegration;
|
||||||
|
|
||||||
class ConfigSupport extends SmartlinksIntegration implements ConfigFormInterface
|
class SmartlinksConfigSupport extends SmartlinksIntegration implements ConfigFormInterface
|
||||||
{
|
{
|
||||||
use DefaultConfigFormTrait;
|
use DefaultConfigFormTrait;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -1,200 +0,0 @@
|
|||||||
# Merge Smartlinks into MT3S Marketing Program
|
|
||||||
|
|
||||||
Instructions for merging the `SmartlinksBundle` plugin (`mautic-plugin-smartlinks`) into
|
|
||||||
`MT3SMarketingProgramBundle` (this repo) as one unique bundle.
|
|
||||||
|
|
||||||
- **Reversibility**: both repos are tagged `pre-merge-v1` (pushed to origin).
|
|
||||||
Roll back with `git reset --hard pre-merge-v1`.
|
|
||||||
- **Principles**:
|
|
||||||
1. One unique bundle: `MT3SMarketingProgramBundle` hosts everything.
|
|
||||||
2. Domains stay separate: the *Marketing Program* domain and the *Smart Links* domain keep
|
|
||||||
their own menu groups, routes, permission categories, configuration sections and
|
|
||||||
translation prefixes. They only share the bundle, the plugin row and the codebase.
|
|
||||||
3. Every entity is left intact: no table, column or JSON shape changes. Only the PHP
|
|
||||||
namespace of the Smart Links classes changes.
|
|
||||||
4. Mautic naming best practices, vendor **MT3 Solutions** (acronym **MT3S**): the host
|
|
||||||
bundle already follows them (`MauticPlugin\MT3SMarketingProgramBundle`,
|
|
||||||
`mt3s/mautic-marketing-program-bundle`, service ids `mt3s.*`, params
|
|
||||||
`mt3s_marketing_program_*`, tables `mt3s_mp_program_*`, permission base
|
|
||||||
`mt3smarketingprogram`).
|
|
||||||
|
|
||||||
## Inventory
|
|
||||||
|
|
||||||
### Coming in from `mautic-plugin-smartlinks` (Smart Links domain, version 0.6.0)
|
|
||||||
|
|
||||||
| Layer | Contents |
|
|
||||||
|---|---|
|
|
||||||
| Entities | `SmartLink` (`smart_links`), `SmartLinkHit` (`smart_link_hits`), `UtmTaxonomy` (`utm_taxonomies`) + repositories |
|
|
||||||
| Models | `SmartLinkModel` (`smartlinks.smart_link`), `UtmTaxonomyModel` (`smartlinks.utm_taxonomy`) |
|
|
||||||
| Controllers | `SmartLinkController`, `UtmTaxonomyController`, `PublicController` (public `/l/{slug}`) |
|
|
||||||
| Forms / validators | `SmartLinkType`, `UtmTaxonomyType`, `SmartLinkValidator`, `UtmTaxonomyValidator`, `UtmSettingsValidator`, `SmartlinksSettingsType`, `SmartLinksConfigType`, `ConfigType`-era classes, `UtmTagsTypeExtension`, `UtmFieldsApplicator`, `UtmSettingsTransformer`, catalog (`UtmParameterCatalog` …) |
|
|
||||||
| Services | `UtmConfigurationProvider`, `UtmConfigurationNormalizer`, `SmartLinkShortUrlBuilder` |
|
|
||||||
| Views | `Resources/views/SmartLink/*`, `Resources/views/UtmTaxonomy/*`, `Resources/views/FormTheme/Config/*` |
|
|
||||||
| Config tab | "Smart Links Settings" (`SmartlinksConfigSubscriber` + theme): section "UTM Settings" (enforce lowercase, separator, short link domain) + section "Parameters" |
|
|
||||||
| Menu | Group "Smart Links": children "UTM Taxonomies" (above) and "Smart Links" |
|
|
||||||
| Permissions | categories `smart_links`, `taxonomies` (base `smartlinks:`) |
|
|
||||||
| Params | `smartlinks_utm_config`, `smartlinks_config` (+ legacy keys `utm_manager_config`, `utm_manager_smart_links`) |
|
|
||||||
| Translations | `mautic.smartlinks.*` keys (en_US + fr_FR) |
|
|
||||||
| Migrations | `Version_0_2_0` … `Version_0_6_0` (all idempotent by schema checks) |
|
|
||||||
| Other | `Assets/js/smartlinks.js`, `Tests/Unit/*` (90 tests), `phpunit.xml.dist`, icon |
|
|
||||||
| Public | route `/l/{slug}` — short links keep working, no URL change |
|
|
||||||
|
|
||||||
### Already in the host (Marketing Program domain, version 0.17.0)
|
|
||||||
|
|
||||||
`mt3s_mp_program*` tables (programs, tasks, stakeholders, audiences, item types), menu group
|
|
||||||
"Programs" with 5 children, permission base `mt3smarketingprogram:` (categories `programs`,
|
|
||||||
`tasks`, `stakeholders`, `audiences`, `itemtypes`), config tab "Program Settings",
|
|
||||||
params `mt3s_marketing_program_*`, translations `mt3s.marketing_program.*`,
|
|
||||||
`Assets/js/mt3s-mp-program.js`, migrations `Version_0_2_0` … `Version_0_17_0`.
|
|
||||||
|
|
||||||
## Impact analysis
|
|
||||||
|
|
||||||
1. **Namespace** — every `MauticPlugin\SmartlinksBundle\` reference becomes
|
|
||||||
`MauticPlugin\MT3SMarketingProgramBundle\`. Pure textual remap; classes keep their names
|
|
||||||
(domains stay identifiable by their class-name prefixes: `SmartLink*`, `UtmTaxonomy*` vs
|
|
||||||
`Program*`, `Task*`, `Stakeholder*`, `Audience*` — flat Mautic directory convention).
|
|
||||||
2. **Database — zero schema/data impact**: `smart_links`, `smart_link_hits`, `utm_taxonomies`
|
|
||||||
keep their names and columns. No migration of data is required; existing rows keep working
|
|
||||||
(proven idempotent migrations).
|
|
||||||
3. **Migration class-name collision (critical)**: both repos define `Version_0_2_0.php` …
|
|
||||||
overlapping names. One `Migrations/` directory cannot contain both sets (the engine builds
|
|
||||||
`MauticPlugin\<Bundle>\Migrations\<Class>` per file; duplicate class names are fatal).
|
|
||||||
→ The incoming Smart Links migrations are renamed with a suffix, e.g.
|
|
||||||
`Version_0_2_0.php` → `Version_0_2_0_SmartLinks.php` (class renamed accordingly).
|
|
||||||
Their `shouldExecute()` schema checks are unchanged, so nothing re-runs.
|
|
||||||
4. **Plugin row**: the two rows (`SmartlinksBundle` 0.6.0, `MT3SMarketingProgramBundle` 0.17.0)
|
|
||||||
become ONE: keep this repo's row (version bumped to `0.18.0`), delete the `SmartlinksBundle`
|
|
||||||
row. The engine replays every migration through its schema checks on reload — all no-op.
|
|
||||||
5. **Permissions (role re-grant)**: the categories `smart_links` and `taxonomies` move under
|
|
||||||
the host permission class, so their base becomes `mt3smarketingprogram:smart_links:*` /
|
|
||||||
`mt3smarketingprogram:taxonomies:*`. Stored role grants referencing the old
|
|
||||||
`smartlinks:*` base must be re-granted once (dev DB: admin only, zero impact; production:
|
|
||||||
one-time re-grant, same as the 0.5.0 rename).
|
|
||||||
6. **Routes keep their names** (`mautic_smartlinks_*`) and paths (`/smart-links`, `/utm-taxonomies`,
|
|
||||||
`/l/{slug}`): no session, bookmark or saved-list breakage. (Optional later cosmetic pass to
|
|
||||||
`mt3s_smart_links_*` is noted but not required.)
|
|
||||||
7. **Menu**: the "Smart Links" group is added as a second top-level entry next to "Programs" —
|
|
||||||
domains remain separately visible, no icon/id collisions.
|
|
||||||
8. **Config**: the "Smart Links Settings" tab (`smartlinksconfig` alias) is added alongside
|
|
||||||
"Program Settings"; its params (`smartlinks_utm_config`, `smartlinks_config` + legacy keys)
|
|
||||||
move into `Config/config.php` verbatim — saved local.php values keep working, including the
|
|
||||||
legacy-key fallbacks.
|
|
||||||
9. **Translations**: the `mautic.smartlinks.*` keys are appended to this repo's
|
|
||||||
`Translations/{en_US,fr_FR}/messages.ini|validators.ini` (key prefixes are globally unique —
|
|
||||||
parse-check every file after each edit; a stray quote kills the whole catalog).
|
|
||||||
10. **Assets**: `smartlinks.js` becomes `Assets/js/mt3s-mp-smartlinks.js` (host file-naming
|
|
||||||
convention; the mauticContent/OnLoad prefixes it registers are unchanged).
|
|
||||||
11. **Integrations**: the host keeps `MT3SMarketingProgramIntegration`; the Smart Links
|
|
||||||
`SmartlinksIntegration` (+ its `ConfigSupport`) move in as additional
|
|
||||||
`mautic.integration` services — one plugin may register several.
|
|
||||||
12. **Dev environment**: `docker-compose.yml` drops the `PLUGIN_SMARTLINKS_PATH` mount; this
|
|
||||||
repo remains the single `MT3SMarketingProgramBundle` mount. `.env` updated accordingly.
|
|
||||||
13. **The `mautic-plugin-smartlinks` repo** becomes obsolete after the merge: archive it, don't
|
|
||||||
delete (it carries `pre-merge-v1` and the full history).
|
|
||||||
|
|
||||||
## Procedure (step by step)
|
|
||||||
|
|
||||||
All work happens on a branch `merge-smartlinks` of THIS repo. The `mautic-plugin-smartlinks`
|
|
||||||
repo is read-only source material (already tagged).
|
|
||||||
|
|
||||||
### Phase 1 — import the Smart Links code
|
|
||||||
|
|
||||||
1. From `mautic-plugin-smartlinks`, copy into this repo (paths unchanged):
|
|
||||||
`Catalog/`, `Controller/` (the 3 Smart Links controllers), `Entity/` (3 entities + 3
|
|
||||||
repositories), `EventListener/` (`SmartLinksConfigSubscriber`, `PluginInstallSubscriber`),
|
|
||||||
`Form/` (types, validators, transformer, applicator, extension), `Integration/`
|
|
||||||
(Smartlinks integration + ConfigSupport), `Model/` (2 models), `Resources/views/SmartLink/`,
|
|
||||||
`Resources/views/UtmTaxonomy/`, `Resources/views/FormTheme/Config/`, `Service/` (3 services),
|
|
||||||
`Assets/img/` (icon), `Tests/Unit/…` (the smartlinks tests).
|
|
||||||
2. Textual namespace remap in every copied file:
|
|
||||||
`MauticPlugin\SmartlinksBundle\` → `MauticPlugin\MT3SMarketingProgramBundle\`.
|
|
||||||
3. `Assets/js/smartlinks.js` → `Assets/js/mt3s-mp-smartlinks.js` (contents unchanged).
|
|
||||||
4. Migrations: copy `Version_0_2_0.php` … `Version_0_6_0.php` renamed to
|
|
||||||
`Version_0_2_0_SmartLinks.php` … `Version_0_6_0_SmartLinks.php` (class names likewise);
|
|
||||||
namespace remap; the `TABLE_NAME` constants they reference are unchanged.
|
|
||||||
5. Gate: `grep -rn "SmartlinksBundle" .` must return zero hits afterwards.
|
|
||||||
|
|
||||||
### Phase 2 — merge Config/config.php
|
|
||||||
|
|
||||||
Add to this repo's `Config/config.php` (keep every existing entry untouched):
|
|
||||||
- `routes.main`: the 4 Smart Links routes (`mautic_smartlinks_index`, `mautic_smartlinks_action`,
|
|
||||||
`mautic_smartlinks_taxonomies`, `mautic_smartlinks_taxonomy_action`), controllers re-pointed
|
|
||||||
at the new namespace; keep `routes.public` `mautic_smartlinks_go` (`/l/{slug}`).
|
|
||||||
- `menu.main`: the whole `mautic.smartlinks.menu.root` group (UTM Taxonomies above Smart Links),
|
|
||||||
access arrays re-based to `mt3smarketingprogram:smart_links:*` / `mt3smarketingprogram:taxonomies:*`.
|
|
||||||
- `services.integrations`: `mt3s.smart_links.integration` + `…integration.configuration`
|
|
||||||
(host `mt3s.*` id convention; class namespaces remapped).
|
|
||||||
- `parameters`: `smartlinks_utm_config`, `smartlinks_config`, legacy `utm_manager_config`,
|
|
||||||
`utm_manager_smart_links` — verbatim.
|
|
||||||
- Bump `'version'` to `'0.18.0'`; extend `'description'` to mention smart links.
|
|
||||||
|
|
||||||
### Phase 3 — fold permissions, services, config tab
|
|
||||||
|
|
||||||
- `Security/Permissions/MT3SMarketingProgramPermissions.php`: add
|
|
||||||
`$this->addExtendedPermissions('smart_links'); $this->addExtendedPermissions('taxonomies');`
|
|
||||||
and the matching `addExtendedFormFields('mt3smarketingprogram', 'smart_links'|'taxonomies', …)`
|
|
||||||
lines; do NOT copy `SmartlinksPermissions.php` into the bundle.
|
|
||||||
- `Config/services.php`: add the model aliases
|
|
||||||
`mautic.smartlinks.model.smart_link` / `mautic.smartlinks.model.utm_taxonomy`
|
|
||||||
(plus `mt3s.smart_links.model.*` aliases if wanted); nothing else — autoconfiguration
|
|
||||||
picks up the new classes.
|
|
||||||
- `SmartLinksConfigSubscriber`: verify the `'bundle' => 'MT3SMarketingProgramBundle'` entry and
|
|
||||||
the `@Smartlinks/FormTheme/Config/…` twig paths (the twig namespace follows the bundle name).
|
|
||||||
|
|
||||||
### Phase 4 — translations
|
|
||||||
|
|
||||||
Append the `mautic.smartlinks.*` keys from the source repo's 4 ini files into this repo's
|
|
||||||
4 ini files (same keys, no renames; the `SmartlinksConfigSubscriber` tab key
|
|
||||||
`mautic.config.tab.smartlinksconfig` comes along). **Parse-check all 4 files after every
|
|
||||||
edit** — `parse_ini_file()` must not return `false` (a single stray quote kills the whole
|
|
||||||
catalog, as happened in 0.6.0).
|
|
||||||
|
|
||||||
### Phase 5 — dev environment + database registration
|
|
||||||
|
|
||||||
1. `mautic-dev-env/docker-compose.yml`: remove the `PLUGIN_SMARTLINKS_PATH` mount line;
|
|
||||||
`.env` + `.env.example`: remove the variable.
|
|
||||||
2. `docker compose up -d` (recreates the containers with the single mount).
|
|
||||||
3. Database: `DELETE FROM plugins WHERE bundle='SmartlinksBundle';` and
|
|
||||||
`UPDATE plugins SET version='0.18.0' WHERE bundle='MT3SMarketingProgramBundle';`
|
|
||||||
4. Stop the background containers, then:
|
|
||||||
`./dev.sh cc && ./dev.sh console mautic:plugins:reload`
|
|
||||||
then restart them (they race the cache clear; the web container also needs a restart
|
|
||||||
afterwards when opcache validates timestamps off).
|
|
||||||
5. `./dev.sh console mautic:assets:generate`.
|
|
||||||
|
|
||||||
### Phase 6 — verification checklist
|
|
||||||
|
|
||||||
- [ ] `php -l` over every file; full ini parse-check (4 files)
|
|
||||||
- [ ] Plugin row: ONE `MT3SMarketingProgramBundle` 0.18.0; Plugins page shows "MT3S Marketing Program"
|
|
||||||
- [ ] Menu: "Programs" group (5 children) AND "Smart Links" group (UTM Taxonomies, Smart Links)
|
|
||||||
- [ ] Config: "Program Settings" tab AND "Smart Links Settings" tab (UTM Settings + Parameters)
|
|
||||||
- [ ] Smart Links: list/create/edit; taxonomy select + fieldsets; out-of-list value rejected
|
|
||||||
- [ ] UTM Taxonomies: list/create/edit (checkbox subsets + free-value lists)
|
|
||||||
- [ ] Public redirect: `curl -sI -H 'Host: <short_link_domain>' http://localhost:8080/l/<slug>`
|
|
||||||
→ 302 with UTM parameters on the Location; hits recorded in `smart_link_hits`
|
|
||||||
- [ ] Marketing Program pages: programs, tasks, stakeholders, audiences, item types all load
|
|
||||||
- [ ] Translations: no raw `mautic.*` keys anywhere (en + fr)
|
|
||||||
- [ ] Roles: re-grant `mt3smarketingprogram:smart_links:*` / `…:taxonomies:*` where needed
|
|
||||||
- [ ] Tests: `php /tmp/phpunit.phar --do-not-cache-result -c
|
|
||||||
docroot/plugins/MT3SMarketingProgramBundle/phpunit.xml.dist` (merged suites, both domains)
|
|
||||||
- [ ] Legacy data: `smart_links` / `utm_taxonomies` rows intact; `mt3s_mp_*` tables untouched
|
|
||||||
|
|
||||||
### Phase 7 — finalize
|
|
||||||
|
|
||||||
1. `readme.md`: add the Smart Links domain section (structure, short links, taxonomies,
|
|
||||||
public redirect, tests).
|
|
||||||
2. Commit `feat: merge Smartlinks into MT3S Marketing Program (smart links + UTM taxonomies)`;
|
|
||||||
push; tag `post-merge-v1`; archive `mautic-plugin-smartlinks`.
|
|
||||||
3. Rollback at any point: `git reset --hard pre-merge-v1` in this repo — the source repo is
|
|
||||||
untouched throughout the merge.
|
|
||||||
|
|
||||||
## Risk register
|
|
||||||
|
|
||||||
| Risk | Mitigation |
|
|
||||||
|---|---|
|
|
||||||
| Migration class-name collision → fatal reload | Phase 1.4 renames the incoming set; verify no duplicate class names in `Migrations/` |
|
|
||||||
| Broken translation catalog (stray quote) | Phase 4 parse-check after every edit |
|
|
||||||
| `cache:clear` races / opcache staleness | stop cron+worker, `dev.sh cc`, restart the web container |
|
|
||||||
| Permission base change breaks saved roles | Phase 6 re-grant checklist (documented, one-time) |
|
|
||||||
| Missed namespace reference | Phase 1.5 grep gate: zero `SmartlinksBundle` hits |
|
|
||||||
| Data loss | none by design: no schema/data migration; `pre-merge-v1` tags on both repos |
|
|
||||||
@@ -6,6 +6,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
|||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Since 0.10.0 objectives have a type, the key of an objective type set up in Settings >
|
* Since 0.10.0 objectives have a type, the key of an objective type set up in Settings >
|
||||||
* Configuration > Plan Settings (parameter plan_objective_types). Adds initiative_objectives.type for
|
* Configuration > Plan Settings (parameter plan_objective_types). Adds initiative_objectives.type for
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
|||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Since 0.10.1 objectives have a priority, a whole number from 1 (highest) to 99 (lowest). Adds
|
* Since 0.10.1 objectives have a priority, a whole number from 1 (highest) to 99 (lowest). Adds
|
||||||
* initiative_objectives.priority for installs created before 0.10.1: NOT NULL with the default 1, and the
|
* initiative_objectives.priority for installs created before 0.10.1: NOT NULL with the default 1, and the
|
||||||
@@ -29,7 +30,7 @@ class Version_0_10_1 extends AbstractMigration
|
|||||||
|
|
||||||
if (!$table->hasColumn('priority')) {
|
if (!$table->hasColumn('priority')) {
|
||||||
$this->addSql(sprintf(
|
$this->addSql(sprintf(
|
||||||
"ALTER TABLE %s ADD priority INT NOT NULL DEFAULT %d",
|
'ALTER TABLE %s ADD priority INT NOT NULL DEFAULT %d',
|
||||||
$objectives,
|
$objectives,
|
||||||
1
|
1
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use Doctrine\ORM\Tools\SchemaTool;
|
|||||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceType as AudienceTypeEnum;
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceType as AudienceTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Since 0.11.0 a plan has audiences (table initiative_audiences, initiative_audiences_stages before 0.15.0) with any
|
* Since 0.11.0 a plan has audiences (table initiative_audiences, initiative_audiences_stages before 0.15.0) with any
|
||||||
* number of Mautic stages (join table initiative_audiences_stages). Creates both tables for installs created
|
* number of Mautic stages (join table initiative_audiences_stages). Creates both tables for installs created
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
|||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Since 0.14.0 audiences are a global directory (Planning > Audiences, called Targets before 0.15.0),
|
* Since 0.14.0 audiences are a global directory (Planning > Audiences, called Targets before 0.15.0),
|
||||||
* like stakeholders:
|
* like stakeholders:
|
||||||
@@ -46,7 +47,7 @@ class Version_0_14_0 extends AbstractMigration
|
|||||||
}
|
}
|
||||||
|
|
||||||
[$directory, $links] = $names;
|
[$directory, $links] = $names;
|
||||||
$oldNaming = 'initiative_audiences' === $directory;
|
$oldNaming = 'initiative_audiences' === $directory;
|
||||||
|
|
||||||
$table = $schema->getTable($directory);
|
$table = $schema->getTable($directory);
|
||||||
$shared = fn (string $column): bool => $table->hasColumn($this->concatPrefix($column));
|
$shared = fn (string $column): bool => $table->hasColumn($this->concatPrefix($column));
|
||||||
@@ -201,4 +202,4 @@ class Version_0_14_0 extends AbstractMigration
|
|||||||
// mapping, foreign keys included — nothing to repair first.
|
// mapping, foreign keys included — nothing to repair first.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
|||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Historical migration (from 0.15.0, when the bundle was still PlanBundle): it renamed "targets"
|
* Historical migration (from 0.15.0, when the bundle was still PlanBundle): it renamed "targets"
|
||||||
* to "audiences" — plan_targets became plan_audiences (its target_type column audience_type),
|
* to "audiences" — plan_targets became plan_audiences (its target_type column audience_type),
|
||||||
|
|||||||
@@ -34,20 +34,20 @@ class Version_0_16_0 extends AbstractMigration
|
|||||||
* needed, but one rename per line keeps half-applied states recoverable).
|
* needed, but one rename per line keeps half-applied states recoverable).
|
||||||
*/
|
*/
|
||||||
private const TABLES = [
|
private const TABLES = [
|
||||||
'plans' => 'initiatives',
|
'plans' => 'initiatives',
|
||||||
'plan_objectives' => 'initiative_objectives',
|
'plan_objectives' => 'initiative_objectives',
|
||||||
'plan_description_items' => 'initiative_description_items',
|
'plan_description_items' => 'initiative_description_items',
|
||||||
'plan_allocation_items' => 'initiative_allocation_items',
|
'plan_allocation_items' => 'initiative_allocation_items',
|
||||||
'plan_tasks' => 'initiative_tasks',
|
'plan_tasks' => 'initiative_tasks',
|
||||||
'plan_task_dependencies' => 'initiative_task_dependencies',
|
'plan_task_dependencies' => 'initiative_task_dependencies',
|
||||||
'plan_task_raci' => 'initiative_task_raci',
|
'plan_task_raci' => 'initiative_task_raci',
|
||||||
'plan_task_raci_stakeholders' => 'initiative_task_raci_stakeholders',
|
'plan_task_raci_stakeholders' => 'initiative_task_raci_stakeholders',
|
||||||
'plan_stakeholders' => 'initiative_stakeholders',
|
'plan_stakeholders' => 'initiative_stakeholders',
|
||||||
'plan_stakeholders_plan' => 'initiative_stakeholders_initiative',
|
'plan_stakeholders_plan' => 'initiative_stakeholders_initiative',
|
||||||
'plan_audiences' => 'initiative_audiences',
|
'plan_audiences' => 'initiative_audiences',
|
||||||
'plan_audiences_plan' => 'initiative_audiences_initiative',
|
'plan_audiences_plan' => 'initiative_audiences_initiative',
|
||||||
'plan_audiences_segments' => 'initiative_audiences_segments',
|
'plan_audiences_segments' => 'initiative_audiences_segments',
|
||||||
'plan_audiences_stages' => 'initiative_audiences_stages',
|
'plan_audiences_stages' => 'initiative_audiences_stages',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,12 +43,12 @@ class Version_0_17_0 extends AbstractMigration
|
|||||||
'initiative_description_items' => 'mt3s_mp_program_description_items',
|
'initiative_description_items' => 'mt3s_mp_program_description_items',
|
||||||
'initiative_allocation_items' => 'mt3s_mp_program_allocation_items',
|
'initiative_allocation_items' => 'mt3s_mp_program_allocation_items',
|
||||||
'initiative_tasks' => 'mt3s_mp_program_tasks',
|
'initiative_tasks' => 'mt3s_mp_program_tasks',
|
||||||
'initiative_task_dependencies' => 'mt3s_mp_program_task_dependencies',
|
'initiative_task_dependencies' => 'mt3s_mp_program_task_dependencies',
|
||||||
'initiative_task_raci' => 'mt3s_mp_program_task_raci',
|
'initiative_task_raci' => 'mt3s_mp_program_task_raci',
|
||||||
'initiative_task_raci_stakeholders' => 'mt3s_mp_program_task_raci_stakeholders',
|
'initiative_task_raci_stakeholders' => 'mt3s_mp_program_task_raci_stakeholders',
|
||||||
'initiative_stakeholders' => 'mt3s_mp_program_stakeholders',
|
'initiative_stakeholders' => 'mt3s_mp_program_stakeholders',
|
||||||
'initiative_stakeholders_initiative' => 'mt3s_mp_program_stakeholders_program',
|
'initiative_stakeholders_initiative' => 'mt3s_mp_program_stakeholders_program',
|
||||||
'initiative_audiences' => 'mt3s_mp_program_audiences',
|
'initiative_audiences' => 'mt3s_mp_program_audiences',
|
||||||
'initiative_audiences_initiative' => 'mt3s_mp_program_audiences_program',
|
'initiative_audiences_initiative' => 'mt3s_mp_program_audiences_program',
|
||||||
'initiative_audiences_segments' => 'mt3s_mp_program_audiences_segments',
|
'initiative_audiences_segments' => 'mt3s_mp_program_audiences_segments',
|
||||||
'initiative_audiences_stages' => 'mt3s_mp_program_audiences_stages',
|
'initiative_audiences_stages' => 'mt3s_mp_program_audiences_stages',
|
||||||
@@ -215,4 +215,4 @@ class Version_0_17_0 extends AbstractMigration
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\ORM\Tools\SchemaTool;
|
||||||
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScript;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptOutcome;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the Call Script component's tables (mt3s_call_scripts and mt3s_call_script_outcomes) for
|
||||||
|
* installs created before 0.19.0.
|
||||||
|
*
|
||||||
|
* As in Version_0_2_0, the plugin installer drops the foreign keys that point to core tables
|
||||||
|
* (users, categories), so they are re-added here with ON DELETE SET NULL. The outcomes table gets
|
||||||
|
* its ON DELETE CASCADE key to the scripts. Every step runs only if needed.
|
||||||
|
*
|
||||||
|
* The statements run immediately through the connection instead of addSql(): the engine executes
|
||||||
|
* addSql() statements only after up() returns, and the schema must be re-read between steps.
|
||||||
|
*/
|
||||||
|
class Version_0_19_0 extends AbstractMigration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Local table (unprefixed) => local column, referenced table, ON DELETE clause.
|
||||||
|
*/
|
||||||
|
private const FOREIGN_KEYS = [
|
||||||
|
['mt3s_call_scripts', 'owner_id', 'users', 'ON DELETE SET NULL'],
|
||||||
|
['mt3s_call_scripts', 'category_id', 'categories', 'ON DELETE SET NULL'],
|
||||||
|
['mt3s_call_script_outcomes', 'call_script_id', 'mt3s_call_scripts', 'ON DELETE CASCADE'],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function isApplicable(Schema $schema): bool
|
||||||
|
{
|
||||||
|
return null !== $this->getCreateTableSql($schema)
|
||||||
|
|| [] !== $this->getMissingForeignKeys($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function up(): void
|
||||||
|
{
|
||||||
|
$connection = $this->entityManager->getConnection();
|
||||||
|
$schema = $this->introspectSchema();
|
||||||
|
|
||||||
|
if (!$schema->hasTable($this->concatPrefix(CallScript::TABLE_NAME))) {
|
||||||
|
$connection->executeStatement($this->buildCreateTableSql(CallScript::class, CallScript::TABLE_NAME));
|
||||||
|
$schema = $this->introspectSchema();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$schema->hasTable($this->concatPrefix(CallScriptOutcome::TABLE_NAME))) {
|
||||||
|
$connection->executeStatement($this->buildCreateTableSql(CallScriptOutcome::class, CallScriptOutcome::TABLE_NAME));
|
||||||
|
$schema = $this->introspectSchema();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->getMissingForeignKeys($schema) as [$table, $column, $referenceTable, $onDelete]) {
|
||||||
|
$connection->executeStatement($this->generateAlterTableForeignKeyStatement(
|
||||||
|
$table,
|
||||||
|
[$column],
|
||||||
|
$referenceTable,
|
||||||
|
['id'],
|
||||||
|
$onDelete
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The missing CREATE TABLE statement, or null when both tables already exist.
|
||||||
|
*/
|
||||||
|
private function getCreateTableSql(Schema $schema): ?string
|
||||||
|
{
|
||||||
|
if (!$schema->hasTable($this->concatPrefix(CallScript::TABLE_NAME))) {
|
||||||
|
return 'mt3s_call_scripts';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$schema->hasTable($this->concatPrefix(CallScriptOutcome::TABLE_NAME))) {
|
||||||
|
return 'mt3s_call_script_outcomes';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{0: string, 1: string, 2: string, 3: string}>
|
||||||
|
*/
|
||||||
|
private function getMissingForeignKeys(Schema $schema): array
|
||||||
|
{
|
||||||
|
$missing = [];
|
||||||
|
|
||||||
|
foreach (self::FOREIGN_KEYS as $foreignKey) {
|
||||||
|
[$table, $column] = $foreignKey;
|
||||||
|
$prefixed = $this->concatPrefix($table);
|
||||||
|
|
||||||
|
// The tables may not exist yet; up() adds their keys after creating them.
|
||||||
|
if (!$schema->hasTable($prefixed)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$found = false;
|
||||||
|
foreach ($schema->getTable($prefixed)->getForeignKeys() as $existing) {
|
||||||
|
if (in_array($column, $existing->getLocalColumns(), true)) {
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$found) {
|
||||||
|
$missing[] = $foreignKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $missing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param class-string $entityClass
|
||||||
|
*/
|
||||||
|
private function buildCreateTableSql(string $entityClass, string $table): string
|
||||||
|
{
|
||||||
|
$schemaTool = new SchemaTool($this->entityManager);
|
||||||
|
$prefix = 'CREATE TABLE '.$this->concatPrefix($table).' ';
|
||||||
|
|
||||||
|
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata($entityClass)]) as $sql) {
|
||||||
|
if (str_starts_with($sql, $prefix)) {
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.$table.'.');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function introspectSchema(): Schema
|
||||||
|
{
|
||||||
|
return $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
|||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Doctrine\DBAL\Schema\Table;
|
use Doctrine\DBAL\Schema\Table;
|
||||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Brings the plans table in line with the entity mapping.
|
* Brings the plans table in line with the entity mapping.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
|||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds plans.version and the initiative_objectives table to installs created before 0.3.0.
|
* Adds plans.version and the initiative_objectives table to installs created before 0.3.0.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Version_0_4_0 extends AbstractMigration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.'initiative_tasks'.'.');
|
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for initiative_tasks.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
|||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Doctrine\ORM\Tools\SchemaTool;
|
use Doctrine\ORM\Tools\SchemaTool;
|
||||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For installs created before 0.6.0:
|
* For installs created before 0.6.0:
|
||||||
* - creates initiative_description_items (and its foreign key to plans, ON DELETE CASCADE);
|
* - creates initiative_description_items (and its foreign key to plans, ON DELETE CASCADE);
|
||||||
@@ -80,6 +81,6 @@ class Version_0_6_0 extends AbstractMigration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.'initiative_description_items'.'.');
|
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for initiative_description_items.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,4 +97,4 @@ class Version_0_6_0_SmartLinks extends AbstractMigration
|
|||||||
|
|
||||||
return array_values($missing);
|
return array_values($missing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
|||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Doctrine\ORM\Tools\SchemaTool;
|
use Doctrine\ORM\Tools\SchemaTool;
|
||||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates initiative_allocation_items (and its foreign key to plans, ON DELETE CASCADE) for installs created
|
* Creates initiative_allocation_items (and its foreign key to plans, ON DELETE CASCADE) for installs created
|
||||||
* before 0.7.0. Each step runs only if needed. As in Version_0_4_0, only the CREATE TABLE statement for
|
* before 0.7.0. Each step runs only if needed. As in Version_0_4_0, only the CREATE TABLE statement for
|
||||||
@@ -71,6 +72,6 @@ class Version_0_7_0 extends AbstractMigration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.'initiative_allocation_items'.'.');
|
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for initiative_allocation_items.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
|||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Since 0.8.0 every amount is in one general currency (Settings > Configuration > Plan Settings, parameter
|
* Since 0.8.0 every amount is in one general currency (Settings > Configuration > Plan Settings, parameter
|
||||||
* program_currency), so the per-record currency columns are dropped: plans.currency,
|
* program_currency), so the per-record currency columns are dropped: plans.currency,
|
||||||
@@ -18,7 +19,7 @@ class Version_0_8_0 extends AbstractMigration
|
|||||||
* Table => columns to drop.
|
* Table => columns to drop.
|
||||||
*/
|
*/
|
||||||
private const COLUMNS = [
|
private const COLUMNS = [
|
||||||
'initiatives' => ['currency'],
|
'initiatives' => ['currency'],
|
||||||
'initiative_allocation_items' => ['planned_currency', 'real_currency'],
|
'initiative_allocation_items' => ['planned_currency', 'real_currency'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use Symfony\Component\Form\FormInterface;
|
|||||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Available as mt3s.marketing_program.model.audience, or getModel('mt3smp.audience').
|
* Available as mautic.mt3smarketingprogram.model.audience, or getModel('mt3smarketingprogram.audience').
|
||||||
*
|
*
|
||||||
* Audiences are a global directory (Programs > Audiences), independent of plans; plans link to
|
* Audiences are a global directory (Programs > Audiences), independent of plans; plans link to
|
||||||
* them from their Audiences tab through ProgramAudience (which carries the audience's priority in
|
* them from their Audiences tab through ProgramAudience (which carries the audience's priority in
|
||||||
@@ -60,4 +60,4 @@ class AudienceModel extends FormModel
|
|||||||
|
|
||||||
return $formFactory->create(AudienceType::class, $entity, $options);
|
return $formFactory->create(AudienceType::class, $entity, $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Model;
|
||||||
|
|
||||||
|
use Mautic\CoreBundle\Model\FormModel;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScript;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptRepository;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\CallScriptType;
|
||||||
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Available as mautic.mt3smarketingprogram.model.call_script, or
|
||||||
|
* getModel('mt3smarketingprogram.call_script').
|
||||||
|
*
|
||||||
|
* @extends FormModel<CallScript>
|
||||||
|
*/
|
||||||
|
class CallScriptModel extends FormModel
|
||||||
|
{
|
||||||
|
public function getRepository(): CallScriptRepository
|
||||||
|
{
|
||||||
|
$repository = $this->em->getRepository(CallScript::class);
|
||||||
|
\assert($repository instanceof CallScriptRepository);
|
||||||
|
|
||||||
|
return $repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPermissionBase(): string
|
||||||
|
{
|
||||||
|
return 'mt3smarketingprogram:call_scripts';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* With no ID, returns a new script with the current user as owner.
|
||||||
|
*/
|
||||||
|
public function getEntity($id = null): ?CallScript
|
||||||
|
{
|
||||||
|
if (null === $id) {
|
||||||
|
$callScript = new CallScript();
|
||||||
|
$callScript->setOwner($this->userHelper->getUser(true));
|
||||||
|
|
||||||
|
return $callScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
$callScript = parent::getEntity($id);
|
||||||
|
|
||||||
|
return $callScript instanceof CallScript ? $callScript : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps the outcome positions contiguous (0..n-1) before saving.
|
||||||
|
*/
|
||||||
|
public function saveEntity($entity, $unlock = true): void
|
||||||
|
{
|
||||||
|
if ($entity instanceof CallScript) {
|
||||||
|
$entity->normalizePositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::saveEntity($entity, $unlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $options
|
||||||
|
*/
|
||||||
|
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
|
||||||
|
{
|
||||||
|
if (!$entity instanceof CallScript) {
|
||||||
|
throw new MethodNotAllowedHttpException(['CallScript']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($action)) {
|
||||||
|
$options['action'] = $action;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $formFactory->create(CallScriptType::class, $entity, $options);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,8 @@ use Symfony\Component\Form\FormInterface;
|
|||||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Available as mautic.mt3smarketingprogram.model.program, or getModel('mt3smarketingprogram.program').
|
||||||
|
*
|
||||||
* @extends FormModel<Program>
|
* @extends FormModel<Program>
|
||||||
*/
|
*/
|
||||||
class ProgramModel extends FormModel
|
class ProgramModel extends FormModel
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
|||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Available as mautic.smartlinks.model.smart_link, or getModel('smartlinks.smart_link').
|
* Available as mautic.mt3smarketingprogram.model.smart_link, or getModel('mt3smarketingprogram.smart_link').
|
||||||
*
|
*
|
||||||
* @extends FormModel<SmartLink>
|
* @extends FormModel<SmartLink>
|
||||||
*/
|
*/
|
||||||
class SmartLinkModel extends FormModel
|
class SmartLinkModel extends FormModel
|
||||||
{
|
{
|
||||||
public const MODEL_NAME = 'smartlinks.smart_link';
|
public const MODEL_NAME = 'mt3smarketingprogram.smart_link';
|
||||||
|
|
||||||
/** Random slugs offered by the "Generate" button: 4 characters, letters and digits. */
|
/** Random slugs offered by the "Generate" button: 4 characters, letters and digits. */
|
||||||
public const GENERATED_SLUG_LENGTH = 4;
|
public const GENERATED_SLUG_LENGTH = 4;
|
||||||
@@ -129,7 +129,7 @@ class SmartLinkModel extends FormModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $utmParameters
|
* @param array<string, string|null> $utmParameters values may be null (an empty form field); they are dropped
|
||||||
*
|
*
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
*/
|
*/
|
||||||
@@ -181,12 +181,19 @@ class SmartLinkModel extends FormModel
|
|||||||
{
|
{
|
||||||
$stored = $this->coreParametersHelper->get(\MauticPlugin\MT3SMarketingProgramBundle\Form\Type\SmartLinksConfigType::CONFIG_PARAMETER, []);
|
$stored = $this->coreParametersHelper->get(\MauticPlugin\MT3SMarketingProgramBundle\Form\Type\SmartLinksConfigType::CONFIG_PARAMETER, []);
|
||||||
|
|
||||||
// Upgrades from < 0.5.0 keep the domain in local.php under the legacy key; serve it until
|
// Upgrades keep the domain in local.php under a legacy key (the standalone
|
||||||
// the Configuration page is saved again (which writes the new key).
|
// SmartlinksBundle wrote `smartlinks_config`, the UtmManagerBundle before it
|
||||||
if (!is_array($stored) || '' === trim((string) ($stored['short_link_domain'] ?? ''))) {
|
// `utm_manager_smart_links`); serve it until the Configuration page is saved again.
|
||||||
$legacy = $this->coreParametersHelper->get(\MauticPlugin\MT3SMarketingProgramBundle\Form\Type\SmartLinksConfigType::LEGACY_CONFIG_PARAMETER, []);
|
$legacyKeys = [
|
||||||
if (is_array($legacy) && '' !== trim((string) ($legacy['short_link_domain'] ?? ''))) {
|
\MauticPlugin\MT3SMarketingProgramBundle\Form\Type\SmartLinksConfigType::LEGACY_SMARTLINKS_PARAMETER,
|
||||||
$stored = $legacy;
|
\MauticPlugin\MT3SMarketingProgramBundle\Form\Type\SmartLinksConfigType::LEGACY_CONFIG_PARAMETER,
|
||||||
|
];
|
||||||
|
foreach ($legacyKeys as $legacyKey) {
|
||||||
|
if (!is_array($stored) || '' === trim((string) ($stored['short_link_domain'] ?? ''))) {
|
||||||
|
$legacy = $this->coreParametersHelper->get($legacyKey, []);
|
||||||
|
if (is_array($legacy) && '' !== trim((string) ($legacy['short_link_domain'] ?? ''))) {
|
||||||
|
$stored = $legacy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loaded 100 of 147 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user