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.
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 withgit reset --hard pre-merge-v1. - Principles:
- One unique bundle:
MT3SMarketingProgramBundlehosts everything. - 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.
- Every entity is left intact: no table, column or JSON shape changes. Only the PHP namespace of the Smart Links classes changes.
- Mautic naming best practices, vendor MT3 Solutions (acronym MT3S): the host
bundle already follows them (
MauticPlugin\MT3SMarketingProgramBundle,mt3s/mautic-marketing-program-bundle, service idsmt3s.*, paramsmt3s_marketing_program_*, tablesmt3s_mp_program_*, permission basemt3smarketingprogram).
- One unique bundle:
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
- Namespace — every
MauticPlugin\SmartlinksBundle\reference becomesMauticPlugin\MT3SMarketingProgramBundle\. Pure textual remap; classes keep their names (domains stay identifiable by their class-name prefixes:SmartLink*,UtmTaxonomy*vsProgram*,Task*,Stakeholder*,Audience*— flat Mautic directory convention). - Database — zero schema/data impact:
smart_links,smart_link_hits,utm_taxonomieskeep their names and columns. No migration of data is required; existing rows keep working (proven idempotent migrations). - Migration class-name collision (critical): both repos define
Version_0_2_0.php… overlapping names. OneMigrations/directory cannot contain both sets (the engine buildsMauticPlugin\<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). TheirshouldExecute()schema checks are unchanged, so nothing re-runs. - Plugin row: the two rows (
SmartlinksBundle0.6.0,MT3SMarketingProgramBundle0.17.0) become ONE: keep this repo's row (version bumped to0.18.0), delete theSmartlinksBundlerow. The engine replays every migration through its schema checks on reload — all no-op. - Permissions (role re-grant): the categories
smart_linksandtaxonomiesmove under the host permission class, so their base becomesmt3smarketingprogram:smart_links:*/mt3smarketingprogram:taxonomies:*. Stored role grants referencing the oldsmartlinks:*base must be re-granted once (dev DB: admin only, zero impact; production: one-time re-grant, same as the 0.5.0 rename). - 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 tomt3s_smart_links_*is noted but not required.) - Menu: the "Smart Links" group is added as a second top-level entry next to "Programs" — domains remain separately visible, no icon/id collisions.
- Config: the "Smart Links Settings" tab (
smartlinksconfigalias) is added alongside "Program Settings"; its params (smartlinks_utm_config,smartlinks_config+ legacy keys) move intoConfig/config.phpverbatim — saved local.php values keep working, including the legacy-key fallbacks. - Translations: the
mautic.smartlinks.*keys are appended to this repo'sTranslations/{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). - Assets:
smartlinks.jsbecomesAssets/js/mt3s-mp-smartlinks.js(host file-naming convention; the mauticContent/OnLoad prefixes it registers are unchanged). - Integrations: the host keeps
MT3SMarketingProgramIntegration; the Smart LinksSmartlinksIntegration(+ itsConfigSupport) move in as additionalmautic.integrationservices — one plugin may register several. - Dev environment:
docker-compose.ymldrops thePLUGIN_SMARTLINKS_PATHmount; this repo remains the singleMT3SMarketingProgramBundlemount..envupdated accordingly. - The
mautic-plugin-smartlinksrepo becomes obsolete after the merge: archive it, don't delete (it carriespre-merge-v1and 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
- 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). - Textual namespace remap in every copied file:
MauticPlugin\SmartlinksBundle\→MauticPlugin\MT3SMarketingProgramBundle\. Assets/js/smartlinks.js→Assets/js/mt3s-mp-smartlinks.js(contents unchanged).- Migrations: copy
Version_0_2_0.php…Version_0_6_0.phprenamed toVersion_0_2_0_SmartLinks.php…Version_0_6_0_SmartLinks.php(class names likewise); namespace remap; theTABLE_NAMEconstants they reference are unchanged. - 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; keeproutes.publicmautic_smartlinks_go(/l/{slug}).menu.main: the wholemautic.smartlinks.menu.rootgroup (UTM Taxonomies above Smart Links), access arrays re-based tomt3smarketingprogram:smart_links:*/mt3smarketingprogram:taxonomies:*.services.integrations:mt3s.smart_links.integration+…integration.configuration(hostmt3s.*id convention; class namespaces remapped).parameters:smartlinks_utm_config,smartlinks_config, legacyutm_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 matchingaddExtendedFormFields('mt3smarketingprogram', 'smart_links'|'taxonomies', …)lines; do NOT copySmartlinksPermissions.phpinto the bundle.Config/services.php: add the model aliasesmautic.smartlinks.model.smart_link/mautic.smartlinks.model.utm_taxonomy(plusmt3s.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
mautic-dev-env/docker-compose.yml: remove thePLUGIN_SMARTLINKS_PATHmount line;.env+.env.example: remove the variable.docker compose up -d(recreates the containers with the single mount).- Database:
DELETE FROM plugins WHERE bundle='SmartlinksBundle';andUPDATE plugins SET version='0.18.0' WHERE bundle='MT3SMarketingProgramBundle'; - Stop the background containers, then:
./dev.sh cc && ./dev.sh console mautic:plugins:reloadthen restart them (they race the cache clear; the web container also needs a restart afterwards when opcache validates timestamps off). ./dev.sh console mautic:assets:generate.
Phase 6 — verification checklist
php -lover every file; full ini parse-check (4 files)- Plugin row: ONE
MT3SMarketingProgramBundle0.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 insmart_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_taxonomiesrows intact;mt3s_mp_*tables untouched
Phase 7 — finalize
readme.md: add the Smart Links domain section (structure, short links, taxonomies, public redirect, tests).- Commit
feat: merge Smartlinks into MT3S Marketing Program (smart links + UTM taxonomies); push; tagpost-merge-v1; archivemautic-plugin-smartlinks. - Rollback at any point:
git reset --hard pre-merge-v1in 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 |