Merge the Smartlinks plugin (SmartlinksBundle 0.6.0) into the bundle as the Smart Links domain (0.18.0)
Two domains, one MT3S bundle: Marketing Programs (unchanged) and the
imported Smart Links (smart links + UTM taxonomies), each keeping its
own menu, tables, routes and translations.
- Code moved from MauticPlugin\SmartlinksBundle\ to
MauticPlugin\MT3SMarketingProgramBundle\; template namespace
@Smartlinks/ -> @MT3SMarketingProgram/; smartlinks.js ->
Assets/js/mt3s-mp-smartlinks.js; icon -> Assets/img/smartlinks-icon.svg.
- Incoming migrations renamed Version_0_X_0_SmartLinks.php to avoid
the class-name collision; schema untouched, data intact.
- Permissions folded into MT3SMarketingProgramPermissions:
smart_links + taxonomies under the mt3smarketingprogram: base
(roles that had the old smartlinks: grants must be re-granted).
- config.php: Smart Links routes + menu group, public /l/{slug},
SmartlinksIntegration services, smartlinks_* parameters (legacy
utm_manager_* keys still readable), version 0.18.0. The 0.17.0
placeholder /s/marketing-program-utm-taxonomies is replaced by the
real /s/utm-taxonomies.
- Translations merged (en_US) and added (fr_FR); Tests/ + phpunit moved
in; readme documents both domains and the 0.18.0 merge history.
Verified live: menus, both config tabs, both lists + forms, program
pages, public redirect with taxonomy UTM values, host + unknown-slug
404s, 90/90 unit tests, full php -l, all ini catalogs parse.
This commit is contained in:
1 parent
debce4ba4a
commit
dce849610c
69 files changed
+8225
-43
No files matched your search
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Catalog;
|
||||
|
||||
/**
|
||||
* HTTP status used for the redirect. 301 and 308 are permanent, 302 and 307 temporary.
|
||||
*/
|
||||
enum SmartLinkRedirectCode: int
|
||||
{
|
||||
use SmartLinkRedirectEnumHelper;
|
||||
|
||||
public const ALLOWED = [301, 302, 307, 308];
|
||||
|
||||
public const MOVED_PERMANENTLY = 301;
|
||||
public const FOUND = 302;
|
||||
public const TEMPORARY_REDIRECT = 307;
|
||||
public const PERMANENT_REDIRECT = 308;
|
||||
|
||||
case MovedPermanently = self::MOVED_PERMANENTLY;
|
||||
case Found = self::FOUND;
|
||||
case TemporaryRedirect = self::TEMPORARY_REDIRECT;
|
||||
case PermanentRedirect = self::PERMANENT_REDIRECT;
|
||||
|
||||
public function getLabelKey(): string
|
||||
{
|
||||
return 'mautic.smartlinks.smart_links.redirect_code.'.$this->value;
|
||||
}
|
||||
|
||||
public function isPermanent(): bool
|
||||
{
|
||||
return in_array($this->value, [self::MOVED_PERMANENTLY, self::PERMANENT_REDIRECT], true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Catalog;
|
||||
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* Choice labels for Smart Link redirect enums: t("mautic.smartlinks.smart_links.redirect_<x>.<value>")
|
||||
* gives "301 - Moved permanently (permanent)" style labels shared by the form and the list view.
|
||||
*/
|
||||
trait SmartLinkRedirectEnumHelper
|
||||
{
|
||||
/**
|
||||
* @return array<int|string, string> value (as string) => label
|
||||
*/
|
||||
public static function getChoices(TranslatorInterface $translator): array
|
||||
{
|
||||
$choices = [];
|
||||
foreach (self::cases() as $case) {
|
||||
$choices[$translator->trans($case->getLabelKey())] = $case->value;
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
public function getTranslatedLabel(TranslatorInterface $translator): string
|
||||
{
|
||||
return $translator->trans($this->getLabelKey());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Catalog;
|
||||
|
||||
/**
|
||||
* Where a Smart Link sends the visitor. Mautic redirects are not processed yet.
|
||||
*/
|
||||
enum SmartLinkRedirectType: string
|
||||
{
|
||||
public const ALLOWED = [self::MAUTIC, self::EXTERNAL];
|
||||
|
||||
public const MAUTIC = 'mautic';
|
||||
public const EXTERNAL = 'external';
|
||||
|
||||
case Mautic = self::MAUTIC;
|
||||
case External = self::EXTERNAL;
|
||||
|
||||
public function getLabelKey(): string
|
||||
{
|
||||
return 'mautic.smartlinks.smart_links.redirect_type.'.($this->isMautic() ? self::MAUTIC : self::EXTERNAL);
|
||||
}
|
||||
|
||||
public function isMautic(): bool
|
||||
{
|
||||
return self::MAUTIC === $this->value;
|
||||
}
|
||||
|
||||
public function isExternal(): bool
|
||||
{
|
||||
return self::EXTERNAL === $this->value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Catalog;
|
||||
|
||||
/**
|
||||
* System catalog of the parameters offered by UTM Manager. Administrators can't edit it;
|
||||
* they can only configure each entry and add custom parameters next to it.
|
||||
*/
|
||||
final class UtmParameterCatalog
|
||||
{
|
||||
public const GROUP_STANDARD = 'standard';
|
||||
public const GROUP_PLATFORM = 'platform';
|
||||
public const GROUP_CUSTOM = 'custom';
|
||||
|
||||
public const CUSTOM_KEY_PATTERN = '/^[a-z][a-z0-9_]{1,40}$/';
|
||||
|
||||
/** Query keys used by Mautic itself (ct = click-through tracking). */
|
||||
private const RESERVED_KEYS = ['ct'];
|
||||
|
||||
/** "utm" is reserved for catalog entries, "mtc_" for Mautic tracking parameters. */
|
||||
private const RESERVED_PREFIXES = ['utm', 'mtc_'];
|
||||
|
||||
/**
|
||||
* Standard Google Analytics / GA4 parameters: key => [default mode, suggested values].
|
||||
*/
|
||||
private const STANDARD = [
|
||||
'utm_source' => [UtmParameterMode::DROPDOWN, ['newsletter', 'linkedin', 'facebook', 'instagram', 'google', 'youtube', 'x', 'tiktok', 'partner', 'direct']],
|
||||
'utm_medium' => [UtmParameterMode::DROPDOWN, ['email', 'cpc', 'social', 'social_paid', 'display', 'affiliate', 'referral', 'qr', 'sms', 'print', 'event']],
|
||||
'utm_campaign' => [UtmParameterMode::FREE, []],
|
||||
'utm_term' => [UtmParameterMode::FREE, []],
|
||||
'utm_content' => [UtmParameterMode::FREE, []],
|
||||
'utm_id' => [UtmParameterMode::FREE, []],
|
||||
'utm_source_platform' => [UtmParameterMode::DROPDOWN, ['google_ads', 'meta_ads', 'linkedin_ads', 'microsoft_ads', 'tiktok_ads']],
|
||||
'utm_creative_format' => [UtmParameterMode::DROPDOWN, ['banner', 'video', 'carousel', 'text', 'native']],
|
||||
'utm_marketing_tactic' => [UtmParameterMode::DROPDOWN, ['prospecting', 'remarketing', 'retargeting', 'brand', 'nurturing']],
|
||||
];
|
||||
|
||||
/**
|
||||
* Click IDs appended automatically by ad platforms. Disabled by default.
|
||||
*/
|
||||
private const PLATFORM = ['gclid', 'gbraid', 'wbraid', 'dclid', 'fbclid', 'msclkid', 'ttclid', 'li_fat_id', 'twclid', 'epik'];
|
||||
|
||||
/**
|
||||
* @var array<string, UtmParameterDefinition>
|
||||
*/
|
||||
private array $definitions = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
foreach (self::STANDARD as $key => [$mode, $suggestions]) {
|
||||
$this->definitions[$key] = new UtmParameterDefinition($key, self::GROUP_STANDARD, $mode, false, $suggestions);
|
||||
}
|
||||
|
||||
foreach (self::PLATFORM as $key) {
|
||||
$this->definitions[$key] = new UtmParameterDefinition($key, self::GROUP_PLATFORM, UtmParameterMode::DISABLED, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, UtmParameterDefinition> In display order
|
||||
*/
|
||||
public function all(): array
|
||||
{
|
||||
return $this->definitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, UtmParameterDefinition>
|
||||
*/
|
||||
public function getByGroup(string $group): array
|
||||
{
|
||||
return array_filter($this->definitions, fn (UtmParameterDefinition $definition): bool => $definition->group === $group);
|
||||
}
|
||||
|
||||
public function has(string $key): bool
|
||||
{
|
||||
return isset($this->definitions[$key]);
|
||||
}
|
||||
|
||||
public function get(string $key): ?UtmParameterDefinition
|
||||
{
|
||||
return $this->definitions[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keys that a custom parameter can't use: catalog keys, Mautic query keys and reserved prefixes.
|
||||
*/
|
||||
public function isReservedKey(string $key): bool
|
||||
{
|
||||
if ($this->has($key) || in_array($key, self::RESERVED_KEYS, true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (self::RESERVED_PREFIXES as $prefix) {
|
||||
if (str_starts_with($key, $prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isValidCustomKey(string $key): bool
|
||||
{
|
||||
return 1 === preg_match(self::CUSTOM_KEY_PATTERN, $key) && !$this->isReservedKey($key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Catalog;
|
||||
|
||||
/**
|
||||
* One entry of the system catalog of UTM / click-ID parameters.
|
||||
*/
|
||||
final class UtmParameterDefinition
|
||||
{
|
||||
private const TRANSLATION_PREFIX = 'mautic.smartlinks.config.parameter.';
|
||||
|
||||
/**
|
||||
* @param string[] $suggestions Suggested values offered by the "Load suggested values" button
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $key,
|
||||
public readonly string $group,
|
||||
public readonly string $defaultMode,
|
||||
public readonly bool $autoGenerated = false,
|
||||
public readonly array $suggestions = [],
|
||||
) {
|
||||
}
|
||||
|
||||
public function getLabelKey(): string
|
||||
{
|
||||
return self::TRANSLATION_PREFIX.$this->key.'.label';
|
||||
}
|
||||
|
||||
public function getDescriptionKey(): string
|
||||
{
|
||||
return self::TRANSLATION_PREFIX.$this->key.'.description';
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-generated click IDs can't be restricted to a list of values.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAllowedModes(): array
|
||||
{
|
||||
if ($this->autoGenerated) {
|
||||
return [UtmParameterMode::FREE, UtmParameterMode::DISABLED];
|
||||
}
|
||||
|
||||
return UtmParameterMode::ALL;
|
||||
}
|
||||
|
||||
public function isModeAllowed(string $mode): bool
|
||||
{
|
||||
return in_array($mode, $this->getAllowedModes(), true);
|
||||
}
|
||||
|
||||
public static function getSuggestionLabelKey(string $value): string
|
||||
{
|
||||
return 'mautic.smartlinks.config.suggestion.'.$value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Catalog;
|
||||
|
||||
/**
|
||||
* How a parameter is presented by the link builder.
|
||||
*/
|
||||
final class UtmParameterMode
|
||||
{
|
||||
/** The link builder shows a selector restricted to the configured values. */
|
||||
public const DROPDOWN = 'dropdown';
|
||||
|
||||
/** The link builder shows a free text input. No values are configured. */
|
||||
public const FREE = 'free';
|
||||
|
||||
/** The parameter is not used. */
|
||||
public const DISABLED = 'disabled';
|
||||
|
||||
public const ALL = [self::DROPDOWN, self::FREE, self::DISABLED];
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user