Files
mautic-marketing-program-bu…/readme.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

40 KiB
Raw Blame History

Mautic MT3S Marketing plugin

A custom Mautic 7 plugin (MT3SMarketingProgramBundle) by MT3 Solutions with two separate domains: Marketing Programs — programs with a name, status, owner, dates, budget and category, with their mt3s_mp_programs — and Smart Links — short links (/l/{slug}) that tag the click with the UTM parameters of a UTM taxonomy before redirecting. The two domains share one bundle, one permission base (mt3smarketingprogram:*), one Plugins page entry and one config page, but keep separate menus, tables and code.

This repository holds only the plugin source. The bundle files are at the repository root, and Mautic loads them from docroot/plugins/MT3SMarketingProgramBundle. The plugin was called PlanBundle before 0.16.0 and ProgramBundle (with programs) before 0.17.0, and the Smart Links used to be a separate SmartlinksBundle plugin before 0.18.0: see Rename history below.

Installation

  1. Copy or clone this repository into your Mautic installation as docroot/plugins/MT3SMarketingProgramBundle. The folder name must be MT3SMarketingProgramBundle.

  2. Clear the cache and register the plugin:

    php bin/console cache:clear
    php bin/console mautic:plugins:reload
    
  3. In Mautic, go to Settings > Plugins, open MT3S Marketing Program and publish it.

Programs are listed under Marketing Programs in the main menu (URL /s/marketing-programs), tasks under Marketing Programs > Tasks (URL /s/marketing-program-tasks), the stakeholder directory under Marketing Programs > Stakeholders (URL /s/marketing-program-stakeholders), and the audience directory under Marketing Programs > Audiences (URL /s/marketing-program-audiences). The item type lists are edited under Marketing Programs > Item types (URL /s/marketing-program-item-types). The Smart Links of the second domain are listed under Smart Links > Smart Links (URL /s/smart-links) and their UTM taxonomies under Smart Links > UTM Taxonomies (URL /s/utm-taxonomies). Users who aren't administrators need a role with the Marketing Program Permissions set in Settings > Roles (the Smart Links domain adds mt3smarketingprogram:smart_links:* and mt3smarketingprogram:taxonomies:*; the marketing program domain uses mt3smarketingprogram:programs:* and its other keys).

  • A smart link is a short link: a slug (like https://m.shrl.be/l/y32b), a destination URL, and an optional UTM taxonomy. When it is hit, the visitor is redirected to the destination with the taxonomy's UTM parameters appended, and the hit is recorded (smart_link_hits).
  • The UTM taxonomies (/s/utm-taxonomies) define, per UTM parameter (utm_source, utm_medium, utm_campaign, utm_content, utm_term), whether and how the taxonomy's values apply: as a fixed value, as a pick list on the link, or as a free text field. The Smart Link form then shows exactly the fields the taxonomy allows, and rejects values outside a pick list.
  • The short link domain is set under Settings > Configuration > Smart Links Settings, together with which UTM parameters to use and their modes. The public /l/{slug} route only answers on the configured domain (404 elsewhere), doesn't require authentication, and records one hit for the statistics; a statistics failure never blocks the redirect. The redirect status code (301, 302, …) is per link.
  • A link redirects to its external destination URL, or — redirect type mautic — to its Mautic landing page or standalone form. The redirect never happens for an unknown slug, an unpublished link, or a link without destination: 404.
  • The Smart Links domain was merged from the standalone SmartlinksBundle plugin (versions 0.1.0 to 0.6.0) in 0.18.0: routes, tables, URL format and translation keys are unchanged, so existing short links keep working. Roles must be re-granted (smartlinks:smart_links:* → mt3smarketingprogram:smart_links:*, smartlinks:taxonomies:* → mt3smarketingprogram:taxonomies:*).

Before using the items of a program's Insights, Objectives, Allocations and Tasks tabs, set up their types under Marketing Programs > Item types (mt3smarketingprogram:itemtypes:view to see the page, mt3smarketingprogram:itemtypes:edit to save it).

Development

Run the plugin in the shared Docker environment, mautic-dev-env. Clone both repositories side by side:

~/projects/
  mautic-plugin-plan/

In the dev environment's .env, point it at this plugin:

PLUGIN_PLAN_PATH=../mautic-plugin-plan

The dev environment mounts it as docroot/plugins/MT3SMarketingProgramBundle.

Run all commands from the mautic-dev-env folder:

cd ../mautic-dev-env
./dev.sh up        # start the stack
./dev.sh install   # first time only: install Mautic and register the plugin
./dev.sh reload    # after changing Config/config.php, services or entities

For the complete list of commands, see the dev environment's README.

Plugin structure

The plugin uses the IntegrationsBundle conventions:

  • MT3SMarketingProgramBundle.php: the bundle class
  • Config/config.php: metadata, routes, menu and integration service tags
  • Config/services.php: autowires and autoconfigures every class in the bundle
  • DependencyInjection/MT3SMarketingProgramExtension.php: loads Config/services.php
  • Event/MT3SMarketingProgramEvents.php and Event/ProgramEvent.php: the plugin's mt3s.marketing_program.* event names and their payload, dispatched by Model/ProgramModel.php on save and delete
  • Command/RefreshStatsCommand.php: mt3s:marketing-program:refresh-stats, recomputes and prints the per-program statistics
  • Integration/MT3SMarketingProgramIntegration.php: the integration that is listed on the Plugins page
  • Integration/Support/MT3SMarketingProgramConfigSupport.php: the configuration form for the integration
  • Translations/en_US/messages.ini and validators.ini: UI strings and validation messages

Pages and permissions

  • Controller/ProgramController.php: list, detail page, create, edit and delete (single and batch), built on core's AbstractStandardFormController
  • Resources/views/Program/list.html.twig: the list. A program's name opens its detail page.
  • Resources/views/Program/form.html.twig and details.html.twig: the create/edit form and the detail page. Both have the same seven tabs, from _tabs.html.twig: Details, Insights (description items), Objectives, Allocations (planned budget, currency and allocation items), Audiences, Stakeholders and Tasks.
  • Resources/views/Program/_task_table.html.twig: the program's tasks in the Tasks tab. It has the harmonized tab columns (pictogram, Type, Name with kind badge for milestones and phases, Description, Start date, End date, Status — no ID), one row per task, no tree: a phase's or milestone's badge marks it in the name column. On the detail page it has an Add task button, links to each task and the filter/sort of the other tabs. On the program form it is read-only (no links, no filter), so that following a link doesn't drop unsaved changes.
  • Controller/TaskController.php and Resources/views/Task/: the task list, and the create/edit form (Marketing Programs > Tasks). new?program=ID preselects the program. After Save or Cancel, the user goes back to where the form was opened from. Opened from Marketing Programs > Tasks, that's the task list. Opened from a program's Tasks tab, whose links carry returnTo=program, that's the program (its new program, if the task was moved). The origin is stored in the session when the form is opened, because the form posts without the query string.
  • Controller/SmartLinkController.php and Resources/views/SmartLink/: the Smart Links list and form (Smart Links > Smart Links, /s/smart-links), built on core's AbstractStandardFormController.
  • Controller/UtmTaxonomyController.php and Resources/views/UtmTaxonomy/: the UTM taxonomies list and form (Smart Links > UTM Taxonomies, /s/utm-taxonomies). Replaced the placeholder page of 0.17.0 in 0.18.0. Model/UtmTaxonomyModel.php, Model/SmartLinkModel.php, Entity/SmartLink.php, Entity/SmartLinkHit.php, Entity/UtmTaxonomy.php (tables smart_links, smart_link_hits, utm_taxonomies — unchanged from the standalone plugin), Catalog/ (redirect codes 301/302/307/308, redirect types external/mautic, the UTM parameter catalog and its modes), Form/ (the link and taxonomy forms, the per-taxonomy UTM fields via Form/UtmFieldsApplicator.php, the validators) and Controller/PublicController.php (the public /l/{slug}) make up the Smart Links domain.
  • EventListener/SmartLinksConfigSubscriber.php: adds the Smart Links Settings tab to Settings > Configuration (Form/Type/SmartLinksConfigType.php, Form/Type/SmartlinksSettingsType.php, Integration/Support/ConfigSupport.php), next to the plugin's Program Settings tab; Service/UtmConfigurationProvider.php and Service/UtmConfigurationNormalizer.php read those parameters, Service/SmartLinkShortUrlBuilder.php builds the redirect URLs.
  • Assets/js/mt3s-mp-smartlinks.js: the Smart Links form script (started by Mautic.smartlinksSmartLinkOnLoad() when a page's mauticContent is smartlinksSmartLink).
  • Tests/Unit/ and phpunit.xml.dist: the plugin's unit test suite (mostly covering the Smart Links domain: the catalog, the entities, the form type, the fields applicator, the validators, the models and the configuration provider).
  • Controller/ItemTypesController.php and Resources/views/ItemTypes/form.html.twig: the Item types page (Marketing Programs > Item types). The type lists that used to be sections of Settings > Configuration > Marketing Program Settings (insights, allocation, objective, task, stakeholder types and the audience decision roles and tones) are edited here. Form/Type/ItemTypesType.php builds the lists, Service/ItemTypeInUseGuard.php refuses to remove a type that items still use, and the page saves through core's Configurator exactly like the Settings pages do: merge into config/local.php, write, refresh the config cache. Settings > Configuration > Marketing Program Settings keeps only the plugin's general settings: the currency, the stakeholder phone region and the audience attribute toggles.
  • Assets/js/mt3s-mp-program.js: on the form, the objectives editor (add, remove, drag-and-drop ordering), and after a failed save, marking the tabs that contain errors with an icon and opening the first one. Started by Mautic.mt3sMpProgramOnLoad().

The program's tab panes deliberately have no Bootstrap fade class. Core reopens the last tab used on a page (12.tabs.js), and the plugin opens the tab with an error after a failed save. With fade, those two tab('show') calls overlapped within the 150 ms transition and left two panes visible at once, so the Tasks tab also showed the objectives.

Which tab opens on a program's detail page and form (Mautic.mt3sMpProgramInitTabs):

  • The tab last used for a program is remembered for the browser session (sessionStorage, key mt3s.marketing_program.tab.<program id>). The detail page and the form both reopen it, so Edit and Save keep the current tab. Cancel goes to the mt3s_mp_programs list, as in core.
  • After a failed save, the first tab with an error opens instead, and every tab with an error gets a warning icon.
  • Core reopens its own remembered tab on page load and after every Ajax request (Mautic.rememberActiveTabs), in an order that varies. mt3s-mp-program.js wraps that function, so the program's choice is applied right after core's restore, and only during the page load.
  • A tab counts as having an error only if it shows an error message (.help-block .alert-danger), not just because an element has the has-error class. Mautic's own checkbox_row theme adds has-error to every checkbox: it tests errors|length is not empty, and 0 isn't "empty" in Twig. Every objective's "Achieved" checkbox would otherwise put a warning icon on the Objectives tab, and opening that tab on load looked like a jump to Objectives.
  • Security/Permissions/MT3SMarketingProgramPermissions.php: the permissions shown in Settings > Roles

The main menu has a top-level Programs entry, with Programs, Tasks, Stakeholders, Audiences and Item types as its items. Add future pages as more children of mt3s.marketing_program.menu.root in Config/config.php.

The Audiences tab lists the program's audiences, harmonized like the other tabs: pictogram (fixed per audience type), Type, Name (a link to the audience's page in the directory), Priority in this program, Stages, Estimated size, Value proposition, Preferred channels.

Route URL Purpose
mt3s_marketing_program_index /s/marketing-programs/{page} Program list, with search on name
mt3s_marketing_program_action /s/marketing-programs/{objectAction}/{objectId} view, new, edit, delete, batchDelete
mt3s_marketing_program_task_index /s/marketing-program-tasks/{page} Task list, with search on name and description
mt3s_marketing_program_task_action /s/marketing-program-tasks/{objectAction}/{objectId} new (optional ?program=ID), edit, delete, batchDelete
mt3s_marketing_program_stakeholder_index /s/marketing-program-stakeholders/{page} Stakeholder directory, with search on name, email, role and type
mt3s_marketing_program_stakeholder_action /s/marketing-program-stakeholders/{objectAction}/{objectId} new, edit, delete, batchDelete
mt3s_marketing_program_audience_index /s/marketing-program-audiences/{page} Audience directory, with search on name
mt3s_marketing_program_audience_action /s/marketing-program-audiences/{objectAction}/{objectId} new, edit, view, delete, batchDelete
mt3s_marketing_program_utm_taxonomy_index /s/marketing-program-utm-taxonomies/{page} UTM Taxonomies (placeholder, off-menu)

The program templates don't pass routeBase to core's button helpers (page_actions, list_actions) when a "close" button is involved: from routeBase, core builds mautic_<routeBase>_* route names, which don't exist in this plugin. The other buttons use the actionRoute (mt3s_marketing_program_action) that the controller passes to the template.

Permission keys:

  • mt3smarketingprogram:programs:*, mt3smarketingprogram:tasks:*, mt3smarketingprogram:stakeholders:* and mt3smarketingprogram:audiences:*: viewown, viewother, editown, editother, create, deleteown, deleteother, publishown, publishother, full. "Own" means items the user created (createdBy), as in core objects.
  • mt3smarketingprogram:categories:*: managing the program category type.

The Program object

  • Entity/Program.php: the entity (table mt3s_mp_programs), with its Doctrine mapping and validation rules
  • Entity/ProgramStatus.php: the status enum (draft, planned, active, paused, completed, archived)
  • Entity/ProgramRepository.php: the repository
  • Entity/ProgramObjective.php and ProgramObjectiveRepository.php: a program's objectives (table mt3s_mp_program_objectives): type (with its pictogram), title, description, position and an "achieved" flag
  • Entity/Audience.php, AudienceType.php, AudiencePriority.php and AudienceRepository.php: the audiences of the global directory (table mt3s_mp_program_audiences, plan_targets before 0.15.0): name, a fixed type (persona, ICP, broad audience, lifecycle cohort, partner/influencer — each with its own pictogram), a tagline, the Mautic segments that hold this audience's contacts (see below), and the persona attributes the admin switched on (Settings > Configuration > Marketing Program Settings, one toggle per attribute, so a b2b install and a b2c install define their personas differently): profile criteria, motivations, barriers, frustrations (formerly pain points), triggers, a decision-making role (a value of the admin-edited list mt3s_marketing_program_audience_decision_roles), a preferred tone (checkboxes of the admin-edited list mt3s_marketing_program_audience_tones), preferred channels (checkboxes: email, SMS, web, social organic, paid social, paid search, events/webinar, outbound sales, partners), any number of Mautic stages (join table mt3s_mp_program_audiences_stages) and an estimated size. Service/AudienceAttributes.php reads the toggles.
  • Segments: each audience can have any number of Mautic segments (LeadBundle lists), purely informational — nothing requires one, and nothing in the program depends on them. They are stored in the join table mt3s_mp_program_audiences_segments (audience_id, leadlist_id), picked in the audience form (published segments only), shown in the directory's Segments column (each with its count of contacts, from lead_lists_leads where manually_removed = 0) and on the detail page. AudienceRepository::getSegmentContactCountsForAudiences() computes the counts for the whole page in one query.
  • Entity/ProgramAudience.php: the link between a program and an audience (table mt3s_mp_program_audiences_program), with the audience's priority in that program (primary, secondary, exclusion), a program-specific value proposition and a position. Deleting the program or the audience deletes the link (ON DELETE CASCADE both sides).
  • Model/AudienceModel.php: the model, available as mt3s.marketing_program.model.audience or with getModel('mt3smp.audience').
  • Controller/AudienceController.php and Resources/views/Audience/: the directory (Marketing Programs > Audiences), with the columns ID, Pictogram, Type, Name (with its tagline), Segments (each with its contact count), Estimated size, Active, and Assigned mt3s_mp_programs — the mt3s_mp_programs the audience is linked to, each with its priority in that program. The detail page lists the segments, the persona attributes that are filled in, and those mt3s_mp_programs.
  • Model/ProgramModel.php: the model, available as mt3s.marketing_program.model.program or with getModel('mt3smp.program'). A new program from getEntity() has the current user as owner.
  • Entity/ProgramDescriptionItem.php and ProgramDescriptionItemRepository.php: a program's description items (table mt3s_mp_program_description_items): type, description and position. They make up the Insights tab and replace the former description field.
  • Form/Type/ProgramType.php, ProgramObjectiveType.php and ProgramDescriptionItemType.php: the create and edit form, with the objectives and the description items as collections
  • Validator/Constraints/EndDateAfterStartDate.php: the end date must be on or after the start date, when both are set. Used by mt3s_mp_programs and tasks, through Entity/DateRangeInterface.php.

Behaviour to know about:

  • Setting the status to completed from another status sets completedAt to the current time. Moving a completed program to any other status clears completedAt.
  • owner is required by validation, but the column is nullable: if the user is deleted, the owner becomes NULL (ON DELETE SET NULL), and the program must be given a new owner before it can be saved again.
  • Categories use the core CategoryBundle with the program type (Settings > Categories), shown as "MT3S Marketing Program" (label mt3s.marketing_program.category.type).
  • There is one currency for every amount: program budgets, allocation costs and totals. It's a general setting, the Currency dropdown in Settings > Configuration > Marketing Program Settings (parameter mt3s_marketing_program_currency, EUR by default), offering 40 main world currencies (Service/CurrencyProvider.php). Users never choose a currency, and amount fields show it next to the input. Changing it doesn't convert existing amounts: they're simply shown with the new currency.
  • version is a whole number from 1 to 99, and new mt3s_mp_programs start at 1. It is edited by hand and isn't related to Doctrine's optimistic locking.
  • Objectives belong to their program: they are saved with it, deleted with it (ON DELETE CASCADE in the database too), and an objective removed from the form is deleted (orphanRemoval). They are always loaded ordered by position. On save, the model renumbers positions to 0, 1, 2… in their current order. Description items follow the same rules.
  • getObjectives() and getDescriptionItems() return the rows sorted by position, as a new collection. The mapping's orderBy isn't enough: after a reorder, the page shown right after saving uses the collection already loaded, in its old order.
  • Text typed in the program form, including in objectives and description items, is kept as typed: line breaks, & and quotes are preserved, and HTML tags are removed. This depends on ProgramType passing a mask array to CleanFormSubscriber. Without one, core HTML-encodes every value, again on each save.

Typed items: description items, allocation items and tasks

  • A description item (Insights tab, Entity/ProgramDescriptionItem.php) has a type and a description. More fields are planned.
  • An allocation item (Allocations tab, Entity/ProgramAllocationItem.php, table mt3s_mp_program_allocation_items) is a cost line: type (with its pictogram), name (optional), description, planned cost and real cost. Costs are DECIMAL(12,2), in the general currency.
  • An objective (Entity/ProgramObjective.php) has a type too (with its pictogram), a title, a priority (a whole number from 1, the most important, to 99), a description and the achieved flag. The program's Objectives tab lists them by priority; ties keep the manual order. The priority is required.
  • A task (Entity/Task.php) has a type too (with its pictogram): see The Task object below.
  • Description items, allocation items and objectives are edited inside the program form, like objectives: add, remove, drag to reorder. They're saved and deleted with the program. Tasks are edited on their own form, where the type's pictogram and description appear around the type dropdown.
  • Each kind's types are set up on the Item types page (Marketing Programs > Item types), in several sections. Each type has a name and a description for each language installed in Mautic, and the default language (the locale parameter) requires a name. Each type also has a pictogram (none for the audience decision roles and tones). Users see their own language, or the default language when theirs is empty. The order of the types is the order of the dropdown.
  • The types are stored in config/local.php, in the mt3s_marketing_program_description_item_types, mt3s_marketing_program_allocation_item_types, mt3s_marketing_program_objective_types, mt3s_marketing_program_task_types and mt3s_marketing_program_stakeholder_types parameters. Read them with Service/ItemTypeProvider.php, passing the kind (description, allocation, objective, task or stakeholder). In templates, use the Twig functions mt3s_marketing_program_item_type_name(kind, key), mt3s_marketing_program_item_type_description(kind, key) and mt3s_marketing_program_item_type_icon(kind, key), plus mt3s_marketing_program_currency() and mt3s_marketing_program_money(amount) (Twig/MT3SMarketingProgramExtension.php).
  • Every item type has a pictogram, chosen by the administrator from a list of Remix Icons that Mautic ships (Service/Pictograms.php, each checked against Mautic 7's icon stylesheet), with a live preview. It's stored as icon in the type. On the program form and the task form it appears next to the type dropdown when a type is chosen.
  • The four item tabs of a program's detail page are harmonized (Resources/views/Program/details.html.twig, _task_table.html.twig, _tab_table_filter.html.twig): every column starts with the pictogram (its header stays empty — no "Pictogram" label), then Type, Name, Description, and the kind's other fields; objectives show their Priority after Description, and tasks end with Status. The program's Tasks tab doesn't show task IDs (data-task-id still carries them). Each tab has one filter box that matches every column, and every column header sorts the rows asc/desc on click (Mautic.mt3sMpProgramInitTabTable in Assets/js/mt3s-mp-program.js, client-side). The objective's achieved flag is the Status column of its table.
  • A description item's long description is clamped to 10 lines in the Insights tab, with a Read more / Show less toggle (_description_read_more.html.twig, Mautic.mt3sMpProgramInitReadMore). The toggle appears only when the text really overflows: the pane is hidden on page load, so the measurement waits for the tab to be shown.
  • Each type has a hidden key, generated when it's created and never changed. Items store that key, so renaming a type renames it everywhere.
  • A type that items use can't be removed: the lists aren't saved, and the error lists the types and how many items use them (Service/ItemTypeInUseGuard.php, called by ItemTypesController before saving the page).
  • On the program form, the selected type's description is shown under the type dropdown. When no types are set up, the tab says where to set them up.
  • Files: Form/Type/ItemTypesType.php, ItemTypeConfigType.php, ProgramDescriptionItemType.php, ProgramAllocationItemType.php, Controller/ItemTypesController.php and Resources/views/ItemTypes/form.html.twig (the page), and Form/Type/ConfigType.php with Resources/views/FormTheme/Config/_config_mt3smarketingprogramconfig_widget.html.twig (the general settings that stayed in Settings > Configuration). Adding and removing types is handled in Assets/js/mt3s-mp-program.js.

Cost totals

  • Program::getAllocationTotals() adds up the allocation items' planned and real costs, in the general currency. The sums are done in cents, as integers.
  • The program detail page shows them under the title, after the program status, as on an email's page (publishStatus block): a "Planned" tag and a "Real" tag. A real total above the planned total is red, otherwise green.
  • The Allocations tab of the detail page lists the cost lines, followed by a total row.
  • isAchieved is toggled by hand on the form for now.

The Stakeholder object

  • Entity/Stakeholder.php and StakeholderRepository.php: a stakeholder (table mt3s_mp_program_stakeholders), the global directory of the people, companies and teams involved in the mt3s_mp_programs: name, email (validated, indexed for duplicate detection), phone, role, type and the active flag (isPublished). Independent of mt3s_mp_programs.
  • Entity/ProgramStakeholder.php: the link between a program and a stakeholder (table mt3s_mp_program_stakeholders_program), with the stakeholder's role in that program (free text, column role_in_program) and a position. Deleting the program or the stakeholder deletes the link (ON DELETE CASCADE both sides).
  • Model/StakeholderModel.php: the model, available as mt3s.marketing_program.model.stakeholder or with getModel('mt3smp.stakeholder'). On save, the phone number is normalized to E.164 using the default region from Settings > Configuration > Marketing Program Settings (parameter mt3s_marketing_program_stakeholder_phone_region, FR by default); a number that doesn't parse is kept exactly as typed, and the save is never blocked.
  • Controller/StakeholderController.php and Resources/views/Stakeholder/: the directory (Marketing Programs > Stakeholders), with the columns ID, Pictogram, Type, Name, Role, Email (mailto link), Phone (tel link), Active, and Assigned mt3s_mp_programs — the mt3s_mp_programs the stakeholder is linked to, each with its role in that program. The detail page lists those mt3s_mp_programs too.
  • The stakeholder's type is the key of a stakeholder type set up in Settings > Configuration > Marketing Program Settings (parameter mt3s_marketing_program_stakeholder_types), same pattern as the other item types, pictogram included.
  • A program's Stakeholders tab links the directory to the program: each row picks an active stakeholder and gives its role in the program. The tab shows the harmonized table (pictogram, Type, Name, Role in the program, Role, Email, Phone, Active). Unpublished stakeholders are not offered in the picker, but keep their links.

The Task object

  • Entity/Task.php and TaskRepository.php: a task (table mt3s_mp_program_tasks): type (with its pictogram), name, description, program, kind (task, milestone or phase), optional start and end dates (plain dates, no time), definition of done, planned work in whole hours, status (not for phases), dependencies (table mt3s_mp_program_task_dependencies) and RACI assignments (table mt3s_mp_program_task_raci with its mt3s_mp_program_task_raci_stakeholders join table)
  • Entity/TaskStatus.php: the status enum. The order of its cases is the order of the dropdown: new (New, the default), todo (To do), in_progress (In progress), done (Done). Stored as VARCHAR(20), indexed.
  • Model/TaskModel.php: the model, available as mt3s.marketing_program.model.task or with getModel('mt3smp.task'). getTaskTree($program) returns a program's tasks as flat rows for the Tasks tab, ordered by name, with their dependencies and RACI rows fully loaded.
  • Form/Type/TaskType.php: the create and edit form
  • Validator/Constraints/ValidTaskDependency.php: a dependency must point at another task of the same program, and the dependency graph must not form a cycle (followed through the database, so a cycle crossing other tasks is caught too)

Behaviour to know about:

  • A task must belong to a program. A program can have any number of tasks, including none.
  • A task's end date must be on or after its start date, when both are set.
  • The task list (Marketing Programs > Tasks) shows these columns, in this order: ID, Pictogram, Type, Name, Description (first 120 characters), Start date, End date, Status. Every column except Pictogram and Description can be sorted.
  • A task's type is required. It's the key of a task type set up in Settings > Configuration > Marketing Program Settings (parameter mt3s_marketing_program_task_types); on the task form the type's pictogram appears next to the dropdown and its description under it. The program's Tasks tab shows the same Pictogram and Type columns as the task list, without the ID column.
  • Deleting a program deletes its tasks (program_id ON DELETE CASCADE).
  • Deleting a task removes its dependency edges and RACI rows too (ON DELETE CASCADE).
  • Tasks are edited on their own pages, not inside the program form: a task can only be picked as a dependency once it exists.
  • Kinds: a milestone's end date is enslaved to its start date (same day — the entity's setTaskKind copies it, the TaskDates validator keeps it in step, the form shows it disabled); a phase has no status of its own, it comes from its tasks (the form shows no status field).
  • RACI: one row per role (Responsible, Accountable, Consulted, Informed), each with several stakeholders picked from the program's stakeholders.

After you change Assets/js/mt3s-mp-program.js, run php bin/console mautic:assets:generate (in the dev environment, ./dev.sh console mautic:assets:generate), because production mode bundles plugin scripts into app.js.

Database schema

Mautic creates the mt3s_mp_programs table from the entity mapping when it installs the plugin. However, the installer drops foreign keys that point to core tables (users, categories). Migrations/Version_0_2_0.php adds them and only runs when they are missing. Core runs plugin migrations when the plugin version changes, and EventListener/PluginInstallSubscriber.php also runs them right after a fresh install.

Migrations/Version_0_16_0.php renames every table and column of the Plan era to the Program one: plans → mt3s_mp_programs, plan_tasks → mt3s_mp_program_tasks, plan_stakeholders → mt3s_mp_program_stakeholders, plan_audiences → mt3s_mp_program_audiences, plan_stakeholders_plan → mt3s_mp_program_stakeholders_program, plan_audiences_plan → mt3s_mp_program_audiences_program, plan_audiences_segments → mt3s_mp_program_audiences_segments, plan_audiences_stages → mt3s_mp_program_audiences_stages, plan_objectives → mt3s_mp_program_objectives, plan_description_items → mt3s_mp_program_description_items, plan_allocation_items → mt3s_mp_program_allocation_items, plan_task_dependencies → mt3s_mp_program_task_dependencies, plan_task_raci → mt3s_mp_program_task_raci, plan_task_raci_stakeholders → mt3s_mp_program_task_raci_stakeholders, and the plan_id foreign key columns become program_id; role_in_plan becomes role_in_program. The earlier migrations (Version_0_2_0.php … Version_0_14_0.php) keep their historical table names in their bodies but are disabled (isApplicable() returns false), since their changes are history now kept by the renames in 0.16.0.

When you change the schema, add a migration in Migrations/ and increase version in Config/config.php, then run ./dev.sh reload. The migration engine executes the addSql() statements after up() returns; a rename migration must instead run its statements immediately through $connection->executeStatement(), re-reading the schema between steps.

Naming conventions

To avoid collisions with other plugins, such as UTM Manager, every identifier in this bundle is prefixed with the bundle's name (the MT3S in MT3SMarketingProgramBundle):

  • Service IDs: mt3s.marketing_program.* (and the models resolve from getModel('mt3smp.program') etc.)
  • Form block prefixes: mt3s_marketing_program_* (mt3s_marketing_program_task, mt3s_marketing_program_audience, …)
  • Route names: mt3s_marketing_program_* (e.g. mt3s_marketing_program_index, mt3s_marketing_program_task_action, with mt3s_marketing_program_utm_taxonomy_index for the placeholder)
  • Translation keys: mt3s.marketing_program.*, plus mautic.plugin.mt3smarketingprogram.name
  • Permission keys: mt3smarketingprogram:* (from the bundle name, lowercased)
  • Config parameters: mt3s_marketing_program_* (mt3s_marketing_program_currency, mt3s_marketing_program_*_types, …)
  • Menu keys: mt3s.marketing_program.menu.*
  • URL paths: /s/marketing-programs, /s/marketing-program-tasks, /s/marketing-program-stakeholders, /s/marketing-program-audiences, /s/marketing-program-utm-taxonomies

The bundle class is MT3SMarketingProgramBundle, the integration name is MT3SMarketingProgram, the entity classes are Program, Task, Stakeholder and Audience, and their tables are mt3s_mp_programs, mt3s_mp_program_tasks, mt3s_mp_program_stakeholders and mt3s_mp_program_audiences. The DB index names are kept from before 0.17.0: program_status on mt3s_mp_programs, program_task_status on mt3s_mp_program_tasks, program_stakeholder_email on mt3s_mp_program_stakeholders. The plugin also dispatches mt3s.marketing_program.* events (Event/MT3SMarketingProgramEvents.php, payload Event/ProgramEvent.php) and ships Command/RefreshStatsCommand.php (php bin/console mt3s:marketing-program:refresh-stats).

Rename history

The plugin was born as PlanBundle with a Plan entity (table plans) and menu root Planning > Plans:

  • Before 0.15.0: "targets" were renamed to "audiences" (entity Audience, table plan_targets → plan_audiences), with Mautic segments attached to each audience.
  • 0.16.0: the full rename to ProgramBundle / Program (and a "plan" became an "initiative"). The bundle namespace, class names, the plugins DB row (ProgramBundle), all tables (plan_* → initiative_*), all columns (plan_id → initiative_id, role_in_plan → role_in_initiative), all permission keys (plan:* → program:*), the config parameters and the menu (root Programs, entry Initiatives, plus the placeholder UTM Taxonomies) took the new names. The data was kept: the migration renames the tables, it doesn't rebuild them.
  • 0.17.0: the rename to MT3SMarketingProgramBundle / "MT3S Marketing Program", and an initiative became a marketing program. The bundle namespace, class names, the plugins DB row (MT3SMarketingProgramBundle, name "MT3S Marketing Program"), all tables (initiative_* → mt3s_mp_program_*), all columns (initiative_id → program_id, role_in_initiative → role_in_program), all permission keys (program:* → mt3smarketingprogram:*), the routes, the service IDs, the config parameters, the URLs (/s/marketing-programs, …) and the menu (root Marketing Programs, entry Marketing Programs) took the new names, and the plugin's events (mt3s.marketing_program.*) and the mt3s:marketing-program:refresh-stats command were added. The data was kept again: Version_0_17_0.php renames the tables and carries over the rows the rename orphans — the plugins row, the roles' permission rows (which the 0.16.0 rename had missed), the categories (plan- and initiative-era rows) and the audit log.
  • 0.18.0: the merge of the standalone Smartlinks plugin (SmartlinksBundle, versions 0.1.0–0.6.0) into this bundle. The Smart Links and UTM Taxonomies code, tables (smart_links, smart_link_hits, utm_taxonomies), routes (/s/smart-links, /s/utm-taxonomies, the public /l/{slug}), translation keys (mautic.smartlinks.*) and settings keys (smartlinks_*, with the legacy utm_manager_* keys still readable) are unchanged; only the PHP namespace (MauticPlugin\SmartlinksBundle\ → MauticPlugin\MT3SMarketingProgramBundle\), the service IDs, the template namespace (@Smartlinks/ → @MT3SMarketingProgram/), the Plugins page entry (one row: "MT3S Marketing Program") and the permission base changed (smartlinks:smart_links:* → mt3smarketingprogram:smart_links:*, smartlinks:taxonomies:* → mt3smarketingprogram:taxonomies:* — roles must be re-granted). The incoming migrations were renamed Version_0_X_0_SmartLinks.php to avoid the class-name collision with this bundle's own migrations. The old placeholder page /s/marketing-program-utm-taxonomies is gone (the real feature is at /s/utm-taxonomies), and the dev environment mounts only this repository. The source repository is archived at its post-merge-v1 tag.
  • The old URLs (/s/plans, /s/plan-tasks, /s/programs, /s/program-tasks, …) are gone: the routes were renamed and the old names return 404.

A rename like this needs care:

  • The historical migrations must stay literal (they describe the old schema) or be neutralized; after the entity renames, their Doctrine mappings no longer match and they can only run with literal SQL.
  • The plugins DB row must be updated to the new bundle name (and its version kept), or Mautic's installer treats the plugin as new and its SchemaTool pass creates empty tables from the current mappings. If that happens, drop the empty tables and turn the install into an update before reloading.
  • The permission keys of each role are stored in the permissions table per (bundle, name); a role that had plan:plans:* grants doesn't automatically get mt3smarketingprogram:programs:*, and cached permission sets in the sessions need a re-login.
  • getModel() resolves mt3smp.program to the service mt3s.marketing_program.model.program, unlike core bundles' mautic.<x>.model.<x>: only the service IDs decide.
  • The config/local.php parameter keys are not renamed by the migration either (they are not in the database): plan_currency → mt3s_marketing_program_currency, the plan_*_types lists → mt3s_marketing_program_*_types, and the pre-0.15 audience keys plan_target_attribute_*, plan_target_decision_roles and plan_target_tones → mt3s_marketing_program_audience_attribute_*, mt3s_marketing_program_audience_decision_roles and mt3s_marketing_program_audience_tones. Rename them by hand after upgrading, or the type lists on the settings page and every type dropdown read empty (the stored items keep their type keys, they only show "Unknown type").