Files
mautic-marketing-program-bu…/MERGE-TO-MT3S-MARKETING.md
T
Alexandre Gain dce849610c 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.
2026-11-16 13:48:13 +01:00

13 KiB

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

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).

  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