refactor(plugin): rebrand as MT3SMarketingProgram, release 0.17.0

Rename the plugin's vendor/namespace from experiential/Program to mt3s/MT3SMarketingProgram (composer: mt3s/mautic-marketing-program-bundle):

- ProgramBundle -> MT3SMarketingProgramBundle; extension, integration,
  config support, permissions, events and twig extension renamed likewise
- Initiative* -> Program*: controller (InitiativeController ->
  ProgramController), model, entities, repositories, form types and views
  (new _tabs/_task_table/_tab_table_filter partials, details page)
- Settings config form theme -> _config_mt3smarketingprogramconfig_widget;
  routes and translations re-prefixed (mt3s_marketing_program_*)
- Assets: icon.svg -> mt3s-mp-icon.svg; program.js -> mt3s-mp-program.js
  (OnLoad hooks renamed mt3sMpProgram*)
- Add Command/RefreshStatsCommand; Migrations/Version_0_17_0.php renames
  the tables to mt3s_mp_program_*
This commit is contained in:
Alexandre Gain committed 2026-11-15 17:48:01 +01:00
1 parent 687d33d30c
commit ea88b7a772
131 files changed
+3238 -2836

No files matched your search

File renamed without changes.

Before

Width:  |  Height:  |  Size: 249 B

After

Width:  |  Height:  |  Size: 249 B

@@ -2,26 +2,26 @@
* Plan plugin scripts. * Plan plugin scripts.
* *
* - Plan form: editable, sortable rows (objectives, description items, allocation items), the selected * - Plan form: editable, sortable rows (objectives, description items, allocation items), the selected
* item type's description, and tab error markers. Started by Mautic.programOnLoad(), which Mautic calls after * item type's description, and tab error markers. Started by Mautic.mt3sMpProgramOnLoad(), which Mautic calls after
* it loads any page whose mauticContent is "initiative", including pages loaded through Ajax. * it loads any page whose mauticContent is "program", including pages loaded through Ajax.
* - Task form (mauticContent "programTask", started by Mautic.programTaskOnLoad()): the dependencies and * - Task form (mauticContent "mt3sMpProgramTask", started by Mautic.mt3sMpProgramTaskOnLoad()): the dependencies and
* the RACI rows work like the initiative form's collections; the selected kind enslaves a milestone's * the RACI rows work like the program form's collections; the selected kind enslaves a milestone's
* end date; the selected type's description and pictogram sit next to the type dropdown. * end date; the selected type's description and pictogram sit next to the type dropdown.
* - Audience form (mauticContent "programAudience", started by Mautic.programAudienceOnLoad()): the selected * - Audience form (mauticContent "mt3sMpProgramAudience", started by Mautic.mt3sMpProgramAudienceOnLoad()): the selected
* type's pictogram next to the type dropdown (fixed per type, not admin-configured). * type's pictogram next to the type dropdown (fixed per type, not admin-configured).
* - Settings > Configuration > Plan: adding and removing item types (delegated handlers, * - Settings > Configuration > Plan: adding and removing item types (delegated handlers,
* because that page isn't a "initiative" page). * because that page isn't a "program" page).
*/ */
Mautic.programAudienceOnLoad = function (container) { Mautic.mt3sMpProgramAudienceOnLoad = function (container) {
// The type dropdown's pictogram is fixed per type (AudienceType), not admin-configured: it is // The type dropdown's pictogram is fixed per type (AudienceType), not admin-configured: it is
// rendered from the value server-side (the program_audience_type_icon filter), and updated here. // rendered from the value server-side (the mt3s_marketing_program_audience_type_icon filter), and updated here.
mQuery(container).find('select[name$="[audienceType]"]').each(function () { mQuery(container).find('select[name$="[audienceType]"]').each(function () {
var $select = mQuery(this); var $select = mQuery(this);
if ($select.data('programAudienceInitialized')) { if ($select.data('mt3sMpProgramAudienceInitialized')) {
return; return;
} }
$select.data('programAudienceInitialized', true); $select.data('mt3sMpProgramAudienceInitialized', true);
// The same icons as AudienceType::getIcon(). // The same icons as AudienceType::getIcon().
var icons = { var icons = {
@@ -34,30 +34,30 @@ Mautic.programAudienceOnLoad = function (container) {
$select.on('change', function () { $select.on('change', function () {
var icon = icons[mQuery(this).val()] || 'ri-user-heart-line'; var icon = icons[mQuery(this).val()] || 'ri-user-heart-line';
mQuery(this).closest('form').find('.initiative-item-type-icon').first() mQuery(this).closest('form').find('.program-item-type-icon').first()
.attr('class', 'initiative-item-type-icon ' + icon); .attr('class', 'program-item-type-icon ' + icon);
}); });
}); });
}; };
Mautic.programTaskOnLoad = function (container) { Mautic.mt3sMpProgramTaskOnLoad = function (container) {
// The dependencies and RACI rows work like the initiative form's collections. // The dependencies and RACI rows work like the program form's collections.
mQuery(container).find('.initiative-collection').each(function () { mQuery(container).find('.program-collection').each(function () {
Mautic.programInitCollection(mQuery(this)); Mautic.mt3sMpProgramInitCollection(mQuery(this));
}); });
// The type dropdown works the same way as in the initiative form. // The type dropdown works the same way as in the program form.
mQuery(container).find('select.initiative-item-type').each(function () { mQuery(container).find('select.program-item-type').each(function () {
var $select = mQuery(this); var $select = mQuery(this);
if ($select.data('programTaskInitialized')) { if ($select.data('mt3sMpProgramTaskInitialized')) {
return; return;
} }
$select.data('programTaskInitialized', true); $select.data('mt3sMpProgramTaskInitialized', true);
$select.on('change', function () { $select.on('change', function () {
var $option = $select.find('option:selected'); var $option = $select.find('option:selected');
var $scope = $select.closest('form'); var $scope = $select.closest('form');
$scope.find('.initiative-item-type-help').first().text($option.attr('data-description') || ''); $scope.find('.program-item-type-help').first().text($option.attr('data-description') || '');
$scope.find('.initiative-item-type-icon').first().attr('class', 'initiative-item-type-icon ' + ($option.attr('data-icon') || '')); $scope.find('.program-item-type-icon').first().attr('class', 'program-item-type-icon ' + ($option.attr('data-icon') || ''));
}); });
}); });
@@ -93,20 +93,20 @@ Mautic.programTaskOnLoad = function (container) {
enslave.call($kind.get(0)); enslave.call($kind.get(0));
}); });
}; };
Mautic.programOnLoad = function (container) { Mautic.mt3sMpProgramOnLoad = function (container) {
mQuery(container).find('.initiative-collection').each(function () { mQuery(container).find('.program-collection').each(function () {
Mautic.programInitCollection(mQuery(this)); Mautic.mt3sMpProgramInitCollection(mQuery(this));
}); });
mQuery(container).find('.initiative-tabs').each(function () { mQuery(container).find('.program-tabs').each(function () {
Mautic.programInitTabs(mQuery(this), mQuery(container)); Mautic.mt3sMpProgramInitTabs(mQuery(this), mQuery(container));
}); });
// Detail page: the four tab tables (description items, objectives, allocation items, tasks). // Detail page: the four tab tables (description items, objectives, allocation items, tasks).
mQuery(container).find('table[data-initiative-tab-table]').each(function () { mQuery(container).find('table[data-program-tab-table]').each(function () {
Mautic.programInitTabTable(mQuery(this)); Mautic.mt3sMpProgramInitTabTable(mQuery(this));
}); });
// Detail page: long description item texts, clamped to 10 lines with a read-more toggle. // Detail page: long description item texts, clamped to 10 lines with a read-more toggle.
mQuery(container).find('.initiative-read-more').each(function () { mQuery(container).find('.program-read-more').each(function () {
Mautic.programInitReadMore(mQuery(this)); Mautic.mt3sMpProgramInitReadMore(mQuery(this));
}); });
}; };
@@ -119,14 +119,14 @@ Mautic.programOnLoad = function (container) {
* (Mautic reopens the tab last used) has no layout, so its scrollHeight is 0. The wrapper is rechecked * (Mautic reopens the tab last used) has no layout, so its scrollHeight is 0. The wrapper is rechecked
* on every tab activation until the measurement could run. * on every tab activation until the measurement could run.
*/ */
Mautic.programInitReadMore = function ($wrapper) { Mautic.mt3sMpProgramInitReadMore = function ($wrapper) {
if ($wrapper.data('planReadMoreInitialized')) { if ($wrapper.data('planReadMoreInitialized')) {
return; return;
} }
$wrapper.data('planReadMoreInitialized', true); $wrapper.data('planReadMoreInitialized', true);
var $text = $wrapper.find('.initiative-read-more-text').first(); var $text = $wrapper.find('.program-read-more-text').first();
var $toggle = $wrapper.find('.initiative-read-more-toggle').first(); var $toggle = $wrapper.find('.program-read-more-toggle').first();
var clampLines = 10; var clampLines = 10;
var measure = function () { var measure = function () {
@@ -158,16 +158,16 @@ Mautic.programInitReadMore = function ($wrapper) {
if (!measure()) { if (!measure()) {
// The pane holding this text is hidden: recheck each time a tab of this page is shown. // The pane holding this text is hidden: recheck each time a tab of this page is shown.
mQuery(document).on('shown.bs.tab.initiative-read-more', function () { mQuery(document).on('shown.bs.tab.program-read-more', function () {
if (measure()) { if (measure()) {
mQuery(document).off('shown.bs.tab.initiative-read-more'); mQuery(document).off('shown.bs.tab.program-read-more');
} }
}); });
} }
}; };
/** /**
* A initiative detail page tab table: one filter box filtering every column (case-insensitive substring), * A program detail page tab table: one filter box filtering every column (case-insensitive substring),
* and every column header sorting the rows asc/desc on click. Filtering and sorting are done on the * and every column header sorting the rows asc/desc on click. Filtering and sorting are done on the
* client, instantly: these tables hold one plan's items, never many. * client, instantly: these tables hold one plan's items, never many.
* *
@@ -175,16 +175,16 @@ Mautic.programInitReadMore = function ($wrapper) {
* Sorting the tree by another column can interleave a sub-task before its parent; the depth marker * Sorting the tree by another column can interleave a sub-task before its parent; the depth marker
* stays attached to its own row, so it just indents wherever it lands. * stays attached to its own row, so it just indents wherever it lands.
*/ */
Mautic.programInitTabTable = function ($table) { Mautic.mt3sMpProgramInitTabTable = function ($table) {
if ($table.data('planTabTableInitialized')) { if ($table.data('planTabTableInitialized')) {
return; return;
} }
$table.data('planTabTableInitialized', true); $table.data('planTabTableInitialized', true);
var $panes = $table.closest('.tab-pane'); var $panes = $table.closest('.tab-pane');
var $filterBox = $panes.find('.initiative-tab-table-filter').first(); var $filterBox = $panes.find('.program-tab-table-filter').first();
var $input = $filterBox.find('.initiative-tab-table-filter-input'); var $input = $filterBox.find('.program-tab-table-filter-input');
var $noMatch = $panes.find('.initiative-tab-table-nomatch').first(); var $noMatch = $panes.find('.program-tab-table-nomatch').first();
var $rows = $table.find('tbody tr'); var $rows = $table.find('tbody tr');
var apply = function () { var apply = function () {
@@ -212,7 +212,7 @@ Mautic.programInitTabTable = function ($table) {
$th.css('cursor', 'pointer').attr('title', $table.attr('data-sort-hint') || ''); $th.css('cursor', 'pointer').attr('title', $table.attr('data-sort-hint') || '');
$th.on('click', function () { $th.on('click', function () {
var direction = $th.hasClass('initiative-sorted-asc') ? -1 : 1; var direction = $th.hasClass('program-sorted-asc') ? -1 : 1;
var cells = []; var cells = [];
$rows.each(function () { $rows.each(function () {
@@ -243,8 +243,8 @@ Mautic.programInitTabTable = function ($table) {
this.$row.appendTo($table.find('tbody')); this.$row.appendTo($table.find('tbody'));
}); });
$table.find('thead th').removeClass('initiative-sorted-asc initiative-sorted-desc'); $table.find('thead th').removeClass('program-sorted-asc program-sorted-desc');
$th.addClass(direction > 0 ? 'initiative-sorted-asc' : 'initiative-sorted-desc'); $th.addClass(direction > 0 ? 'program-sorted-asc' : 'program-sorted-desc');
$rows = $table.find('tbody tr'); $rows = $table.find('tbody tr');
}); });
}); });
@@ -268,7 +268,7 @@ Mautic.planParseNumber = function (text) {
/** /**
* Plan tabs (detail page and form): * Plan tabs (detail page and form):
* - the tab last used for a plan is remembered for the browser session, and reopened when the initiative's * - the tab last used for a plan is remembered for the browser session, and reopened when the program's
* detail page or form loads, so that Edit, Save and Cancel keep the same tab; * detail page or form loads, so that Edit, Save and Cancel keep the same tab;
* - after a failed save, the tabs whose pane has an error get an icon, and the first of them is * - after a failed save, the tabs whose pane has an error get an icon, and the first of them is
* opened instead. * opened instead.
@@ -280,18 +280,18 @@ Mautic.planParseNumber = function (text) {
* the tab under the user. The plan's tab panes have no "fade" class: with fade, two tab('show') calls * the tab under the user. The plan's tab panes have no "fade" class: with fade, two tab('show') calls
* within the 150 ms transition left two panes visible. * within the 150 ms transition left two panes visible.
*/ */
Mautic.programInitTabs = function ($tabs, $container) { Mautic.mt3sMpProgramInitTabs = function ($tabs, $container) {
var initiativeId = $tabs.attr('data-initiative-id'); var programId = $tabs.attr('data-program-id');
var storageKey = initiativeId ? 'mautic.program.tab.' + initiativeId : null; var storageKey = programId ? 'mt3s.marketing_program.tab.' + programId : null;
var $target = null; var $target = null;
$tabs.find('a[data-toggle="tab"]').each(function () { $tabs.find('a[data-toggle="tab"]').each(function () {
var $link = mQuery(this); var $link = mQuery(this);
var hasError = Mautic.planPaneHasError($container.find($link.attr('href'))); var hasError = Mautic.planPaneHasError($container.find($link.attr('href')));
$link.toggleClass('text-danger', hasError); $link.toggleClass('text-danger', hasError);
$link.find('.initiative-tab-error').remove(); $link.find('.program-tab-error').remove();
if (hasError) { if (hasError) {
$link.append(' <i class="ri-error-warning-line text-danger initiative-tab-error"></i>'); $link.append(' <i class="ri-error-warning-line text-danger program-tab-error"></i>');
if ($target === null) { if ($target === null) {
$target = $link; $target = $link;
} }
@@ -340,7 +340,7 @@ Mautic.planApplyPendingTab = function () {
} }
}; };
// Run after core's tab restore, so that the initiative's choice wins (see Mautic.programInitTabs). // Run after core's tab restore, so that the program's choice wins (see Mautic.mt3sMpProgramInitTabs).
if (typeof Mautic.rememberActiveTabs === 'function' && !Mautic.rememberActiveTabs.planWrapped) { if (typeof Mautic.rememberActiveTabs === 'function' && !Mautic.rememberActiveTabs.planWrapped) {
(function (coreRememberActiveTabs) { (function (coreRememberActiveTabs) {
Mautic.rememberActiveTabs = function () { Mautic.rememberActiveTabs = function () {
@@ -368,34 +368,34 @@ Mautic.planPaneHasError = function ($pane) {
/** /**
* An editable list of rows built from a Symfony collection: * An editable list of rows built from a Symfony collection:
* .initiative-collection[data-prototype][data-prototype-name] * .program-collection[data-prototype][data-prototype-name]
* .initiative-collection-empty, .initiative-collection-list > .initiative-collection-row, .initiative-collection-add * .program-collection-empty, .program-collection-list > .program-collection-row, .program-collection-add
* in each row: .initiative-collection-handle (drag), .initiative-collection-remove, input.initiative-row-position * in each row: .program-collection-handle (drag), .program-collection-remove, input.program-row-position
* *
* The hidden position of every row is rewritten to its display index after each change, so the saved * The hidden position of every row is rewritten to its display index after each change, so the saved
* order is the displayed order. * order is the displayed order.
*/ */
Mautic.programInitCollection = function ($editor) { Mautic.mt3sMpProgramInitCollection = function ($editor) {
if ($editor.data('programInitialized')) { if ($editor.data('mt3sMpProgramInitialized')) {
return; return;
} }
$editor.data('programInitialized', true); $editor.data('mt3sMpProgramInitialized', true);
var $list = $editor.find('.initiative-collection-list').first(); var $list = $editor.find('.program-collection-list').first();
var prototypeName = new RegExp($editor.attr('data-prototype-name'), 'g'); var prototypeName = new RegExp($editor.attr('data-prototype-name'), 'g');
// New rows get indexes that were never used on this page, so they can't collide with existing ones. // New rows get indexes that were never used on this page, so they can't collide with existing ones.
var nextIndex = $list.children('.initiative-collection-row').length; var nextIndex = $list.children('.program-collection-row').length;
var refresh = function () { var refresh = function () {
var $rows = $list.children('.initiative-collection-row'); var $rows = $list.children('.program-collection-row');
$rows.each(function (index) { $rows.each(function (index) {
mQuery(this).find('input.initiative-row-position').val(index); mQuery(this).find('input.program-row-position').val(index);
}); });
$editor.find('.initiative-collection-empty').first().toggleClass('hide', $rows.length > 0); $editor.find('.program-collection-empty').first().toggleClass('hide', $rows.length > 0);
}; };
$editor.on('click', '.initiative-collection-add', function (event) { $editor.on('click', '.program-collection-add', function (event) {
event.preventDefault(); event.preventDefault();
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);
@@ -403,25 +403,25 @@ Mautic.programInitCollection = function ($editor) {
$row.find('select, input[type="text"], textarea').first().trigger('focus'); $row.find('select, input[type="text"], textarea').first().trigger('focus');
}); });
$editor.on('click', '.initiative-collection-remove', function (event) { $editor.on('click', '.program-collection-remove', function (event) {
event.preventDefault(); event.preventDefault();
mQuery(this).closest('.initiative-collection-row').remove(); mQuery(this).closest('.program-collection-row').remove();
refresh(); refresh();
}); });
// Typed items (description, allocation): show the selected type's description under the dropdown, and // Typed items (description, allocation): show the selected type's description under the dropdown, and
// its pictogram next to it. Works within a initiative-collection row. // its pictogram next to it. Works within a program-collection row.
$editor.on('change', 'select.initiative-item-type', function () { $editor.on('change', 'select.program-item-type', function () {
var $option = mQuery(this).find('option:selected'); var $option = mQuery(this).find('option:selected');
var $row = mQuery(this).closest('.initiative-collection-row'); var $row = mQuery(this).closest('.program-collection-row');
$row.find('.initiative-item-type-help').first().text($option.attr('data-description') || ''); $row.find('.program-item-type-help').first().text($option.attr('data-description') || '');
$row.find('.initiative-item-type-icon').first().attr('class', 'initiative-item-type-icon ' + ($option.attr('data-icon') || '')); $row.find('.program-item-type-icon').first().attr('class', 'program-item-type-icon ' + ($option.attr('data-icon') || ''));
}); });
if (typeof $list.sortable === 'function') { if (typeof $list.sortable === 'function') {
$list.sortable({ $list.sortable({
items: '> .initiative-collection-row', items: '> .program-collection-row',
handle: '.initiative-collection-handle', handle: '.program-collection-handle',
axis: 'y', axis: 'y',
update: refresh update: refresh
}); });
@@ -452,9 +452,9 @@ Mautic.programInitCollection = function ($editor) {
}); });
// Pictogram of an item type (description, allocation): preview the chosen icon. // Pictogram of an item type (description, allocation): preview the chosen icon.
mQuery(document).on('change', '.program-config-types select.initiative-type-icon-select', function () { mQuery(document).on('change', '.program-config-types select.program-type-icon-select', function () {
var icon = mQuery(this).find('option:selected').attr('data-icon') || ''; var icon = mQuery(this).find('option:selected').attr('data-icon') || '';
mQuery(this).closest('.program-config-type').find('.initiative-type-icon-preview').first().attr('class', 'initiative-type-icon-preview ' + icon); mQuery(this).closest('.program-config-type').find('.program-type-icon-preview').first().attr('class', 'program-type-icon-preview ' + icon);
}); });
mQuery(document).on('click', '.program-config-types .program-config-type-remove', function (event) { mQuery(document).on('click', '.program-config-types .program-config-type-remove', function (event) {
+135
View File
@@ -0,0 +1,135 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Command;
use Doctrine\ORM\EntityManagerInterface;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramAllocationItem;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramAudience;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramDescriptionItem;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramObjective;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramStakeholder;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Task;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\TaskStatus;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand(
name: 'mt3s:marketing-program:refresh-stats',
description: 'Recomputes and prints the per-program statistics (tasks, objectives, insights, allocations, stakeholders, audiences) from the tables.'
)]
class RefreshStatsCommand extends Command
{
public function __construct(private readonly EntityManagerInterface $entityManager)
{
parent::__construct();
}
protected function configure(): void
{
$this->addOption('program', null, InputOption::VALUE_REQUIRED, 'Limit the report to one program ID.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$programId = $input->getOption('program');
$programs = $this->entityManager->getRepository(Program::class)->findBy(
null !== $programId ? ['id' => (int) $programId] : []
);
if ([] === $programs) {
$io->warning(null !== $programId ? sprintf('No program with the ID %s.', $programId) : 'No programs.');
return Command::SUCCESS;
}
$counts = [
'tasks' => $this->countByProgram(Task::class),
'objectives' => $this->countByProgram(ProgramObjective::class),
'insights' => $this->countByProgram(ProgramDescriptionItem::class),
'allocations' => $this->countByProgram(ProgramAllocationItem::class),
'stakeholders' => $this->countByProgram(ProgramStakeholder::class),
'audiences' => $this->countByProgram(ProgramAudience::class),
];
$done = $this->doneByProgram();
$rows = [];
foreach ($programs as $program) {
$id = (string) $program->getId();
$rows[] = [
$id,
$program->getName(),
sprintf('%d / %d', $done[$id] ?? 0, $counts['tasks'][$id] ?? 0),
$counts['objectives'][$id] ?? 0,
$counts['insights'][$id] ?? 0,
$counts['allocations'][$id] ?? 0,
$counts['stakeholders'][$id] ?? 0,
$counts['audiences'][$id] ?? 0,
];
}
$io->title('MT3S Marketing Program statistics');
$io->table(
['ID', 'Name', 'Done / tasks', 'Objectives', 'Insights', 'Allocations', 'Stakeholders', 'Audiences'],
$rows
);
return Command::SUCCESS;
}
/**
* Rows of the given entity class grouped by their program: [program id => count].
*
* @param class-string $entityClass
*
* @return array<string, int>
*/
private function countByProgram(string $entityClass): array
{
$rows = $this->entityManager->getRepository($entityClass)
->createQueryBuilder('c')
->select('IDENTITY(c.program) AS program_id, COUNT(c.id) AS total')
->groupBy('program_id')
->getQuery()
->getArrayResult();
$counts = [];
foreach ($rows as $row) {
$counts[(string) $row['program_id']] = (int) $row['total'];
}
return $counts;
}
/**
* Done tasks per program: [program id => done count].
*
* @return array<string, int>
*/
private function doneByProgram(): array
{
$rows = $this->entityManager->getRepository(Task::class)
->createQueryBuilder('t')
->select('IDENTITY(t.program) AS program_id, SUM(CASE WHEN t.status = :done THEN 1 ELSE 0 END) AS done')
->setParameter('done', TaskStatus::Done)
->groupBy('program_id')
->getQuery()
->getArrayResult();
$done = [];
foreach ($rows as $row) {
$done[(string) $row['program_id']] = (int) $row['done'];
}
return $done;
}
}
+88 -115
View File
@@ -3,106 +3,101 @@
declare(strict_types=1); declare(strict_types=1);
return [ return [
'name' => 'Program', 'name' => 'MT3S Marketing Program',
'description' => 'Program plugin for Mautic.', 'description' => 'Marketing Program for Mautic.',
'version' => '0.16.0', 'version' => '0.17.0',
'author' => 'Experiential', 'author' => 'Experiential',
'routes' => [ 'routes' => [
'main' => [ 'main' => [
'initiative_index' => [ 'mt3s_marketing_program_index' => [
'path' => '/programs/{page}', 'path' => '/marketing-programs/{page}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\InitiativeController::indexAction', 'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\ProgramController::indexAction',
], ],
// objectAction: view, new, edit, delete, batchDelete. // objectAction: view, new, edit, delete, batchDelete.
'initiative_action' => [ 'mt3s_marketing_program_action' => [
'path' => '/programs/{objectAction}/{objectId}', 'path' => '/marketing-programs/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\InitiativeController::executeAction', 'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\ProgramController::executeAction',
], ],
'initiative_task_index' => [ 'mt3s_marketing_program_task_index' => [
'path' => '/program-tasks/{page}', 'path' => '/marketing-program-tasks/{page}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\TaskController::indexAction', 'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\TaskController::indexAction',
], ],
// objectAction: new (optional ?initiative=ID), edit, delete, batchDelete. // objectAction: new (optional ?program=ID), edit, delete, batchDelete.
'initiative_task_action' => [ 'mt3s_marketing_program_task_action' => [
'path' => '/program-tasks/{objectAction}/{objectId}', 'path' => '/marketing-program-tasks/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\TaskController::executeAction', 'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\TaskController::executeAction',
], ],
'initiative_stakeholder_index' => [ 'mt3s_marketing_program_stakeholder_index' => [
'path' => '/program-stakeholders/{page}', 'path' => '/marketing-program-stakeholders/{page}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\StakeholderController::indexAction', 'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\StakeholderController::indexAction',
], ],
// objectAction: new, edit, delete, batchDelete. // objectAction: new, edit, delete, batchDelete.
'initiative_stakeholder_action' => [ 'mt3s_marketing_program_stakeholder_action' => [
'path' => '/program-stakeholders/{objectAction}/{objectId}', 'path' => '/marketing-program-stakeholders/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\StakeholderController::executeAction', 'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\StakeholderController::executeAction',
], ],
'initiative_audience_index' => [ 'mt3s_marketing_program_audience_index' => [
'path' => '/program-audiences/{page}', 'path' => '/marketing-program-audiences/{page}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\AudienceController::indexAction', 'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\AudienceController::indexAction',
], ],
// objectAction: new, edit, delete, batchDelete. // objectAction: new, edit, delete, batchDelete.
'initiative_audience_action' => [ 'mt3s_marketing_program_audience_action' => [
'path' => '/program-audiences/{objectAction}/{objectId}', 'path' => '/marketing-program-audiences/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\AudienceController::executeAction', 'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\AudienceController::executeAction',
], ],
// UTM Taxonomies: a placeholder page under Programs for now. // UTM Taxonomies: a placeholder page for the coming feature, kept out of the menu
'program_utm_taxonomy_index' => [ // (the route stays; the page is reachable at /s/marketing-program-utm-taxonomies).
'path' => '/program-utm-taxonomies/{page}', 'mt3s_marketing_program_utm_taxonomy_index' => [
'controller' => 'MauticPlugin\ProgramBundle\Controller\UtmTaxonomyController::indexAction', 'path' => '/marketing-program-utm-taxonomies/{page}',
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\UtmTaxonomyController::indexAction',
], ],
// The type lists of the plugin's items (Insights, allocations, objectives, tasks, // The type lists of the plugin's items (Insights, allocations, objectives, tasks,
// stakeholders, audience values), moved out of Settings > Configuration. // stakeholders, audience values), moved out of Settings > Configuration.
'program_item_types_index' => [ 'mt3s_marketing_program_item_types_index' => [
'path' => '/program-item-types', 'path' => '/marketing-program-item-types',
'controller' => 'MauticPlugin\ProgramBundle\Controller\ItemTypesController::indexAction', 'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\ItemTypesController::indexAction',
], ],
], ],
], ],
// Top-level "Programs" menu. Future program objects go in its children, after Initiatives. // Top-level "Programs" menu. Future program objects go in its children, after Programs.
'menu' => [ 'menu' => [
'main' => [ 'main' => [
'mautic.program.menu.root' => [ 'mt3s.marketing_program.menu.root' => [
'id' => 'program_root', 'id' => 'mt3s_marketing_program_root',
'iconClass' => 'ri-calendar-line', 'iconClass' => 'ri-calendar-line',
'access' => ['program:initiatives:viewown', 'program:initiatives:viewother', 'program:tasks:viewown', 'program:tasks:viewother', 'program:stakeholders:viewown', 'program:stakeholders:viewother', 'program:audiences:viewown', 'program:audiences:viewother', 'program: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'],
'priority' => 5, 'priority' => 5,
'children' => [ 'children' => [
'mautic.program.menu.index' => [ 'mt3s.marketing_program.menu.index' => [
'id' => 'initiative_index', 'id' => 'mt3s_marketing_program_index',
'route' => 'initiative_index', 'route' => 'mt3s_marketing_program_index',
'access' => ['program:initiatives:viewown', 'program:initiatives:viewother'], 'access' => ['mt3smarketingprogram:programs:viewown', 'mt3smarketingprogram:programs:viewother'],
'priority' => 100, 'priority' => 100,
], ],
'mautic.program.task.menu.index' => [ 'mt3s.marketing_program.task.menu.index' => [
'id' => 'initiative_task_index', 'id' => 'mt3s_marketing_program_task_index',
'route' => 'initiative_task_index', 'route' => 'mt3s_marketing_program_task_index',
'access' => ['program:tasks:viewown', 'program:tasks:viewother'], 'access' => ['mt3smarketingprogram:tasks:viewown', 'mt3smarketingprogram:tasks:viewother'],
'priority' => 90, 'priority' => 90,
], ],
'mautic.program.stakeholder.menu.index' => [ 'mt3s.marketing_program.stakeholder.menu.index' => [
'id' => 'initiative_stakeholder_index', 'id' => 'mt3s_marketing_program_stakeholder_index',
'route' => 'initiative_stakeholder_index', 'route' => 'mt3s_marketing_program_stakeholder_index',
'access' => ['program:stakeholders:viewown', 'program:stakeholders:viewother'], 'access' => ['mt3smarketingprogram:stakeholders:viewown', 'mt3smarketingprogram:stakeholders:viewother'],
'priority' => 80, 'priority' => 80,
], ],
'mautic.program.audience.menu.index' => [ 'mt3s.marketing_program.audience.menu.index' => [
'id' => 'initiative_audience_index', 'id' => 'mt3s_marketing_program_audience_index',
'route' => 'initiative_audience_index', 'route' => 'mt3s_marketing_program_audience_index',
'access' => ['program:audiences:viewown', 'program:audiences:viewother'], 'access' => ['mt3smarketingprogram:audiences:viewown', 'mt3smarketingprogram:audiences:viewother'],
'priority' => 70, 'priority' => 70,
], ],
'mautic.program.utm_taxonomy.menu.index' => [ 'mt3s.marketing_program.menu.item_types' => [
'id' => 'program_utm_taxonomy_index', 'id' => 'mt3s_marketing_program_item_types_index',
'route' => 'program_utm_taxonomy_index', 'route' => 'mt3s_marketing_program_item_types_index',
'access' => ['program:initiatives:viewown', 'program:initiatives:viewother'], 'access' => ['mt3smarketingprogram:itemtypes:view'],
'priority' => 60,
],
'mautic.program.menu.item_types' => [
'id' => 'program_item_types_index',
'route' => 'program_item_types_index',
'access' => ['program:itemtypes:view'],
'priority' => 55, 'priority' => 55,
], ],
], ],
@@ -112,15 +107,15 @@ return [
'services' => [ 'services' => [
'integrations' => [ 'integrations' => [
'mautic.program.integration' => [ 'mt3s.marketing_program.integration' => [
'class' => MauticPlugin\ProgramBundle\Integration\ProgramIntegration::class, 'class' => MauticPlugin\MT3SMarketingProgramBundle\Integration\MT3SMarketingProgramIntegration::class,
'tags' => [ 'tags' => [
'mautic.integration', 'mautic.integration',
'mautic.basic_integration', 'mautic.basic_integration',
], ],
], ],
'mautic.program.integration.configuration' => [ 'mt3s.marketing_program.integration.configuration' => [
'class' => MauticPlugin\ProgramBundle\Integration\Support\ProgramConfigSupport::class, 'class' => MauticPlugin\MT3SMarketingProgramBundle\Integration\Support\MT3SMarketingProgramConfigSupport::class,
'tags' => [ 'tags' => [
'mautic.config_integration', 'mautic.config_integration',
], ],
@@ -128,73 +123,51 @@ return [
], ],
], ],
// Registers "initiative" as a category type (Settings > Categories), used by Initiative::$category. // Registers "program" as a category type (Settings > Categories), used by Program::$category.
'categories' => [ 'categories' => [
'initiative' => [ 'program' => [
'class' => MauticPlugin\ProgramBundle\Entity\Initiative::class, 'class' => MauticPlugin\MT3SMarketingProgramBundle\Entity\Program::class,
'label' => 'mautic.program.category.type', 'label' => 'mt3s.marketing_program.category.type',
], ],
], ],
'parameters' => [ 'parameters' => [
// The currency of every amount in the plugin (ISO 4217), edited in Settings > Configuration > // The currency of every amount in the plugin (ISO 4217), edited in Settings > Configuration >
// Program Settings. Read it through CurrencyProvider. // Program Settings. Read it through CurrencyProvider.
'program_currency' => 'EUR', 'mt3s_marketing_program_currency' => 'EUR',
// Item types, edited on the Item types page (Programs > Item types). Read them through // Item types, edited on the Item types page (Programs > Item types). Read them through
// ItemTypeProvider. Each is a list of ['key' => …, 'names' => [locale => …], 'descriptions' => [locale => …]], // ItemTypeProvider. Each is a list of ['key' => …, 'names' => [locale => …], 'descriptions' => [locale => …]],
// plus 'icon' => a Remix Icon class for description, allocation, objective, task and stakeholder types. // plus 'icon' => a Remix Icon class for description, allocation, objective, task and stakeholder types.
'program_description_item_types' => [], 'mt3s_marketing_program_description_item_types' => [],
'program_allocation_item_types' => [], 'mt3s_marketing_program_allocation_item_types' => [],
'program_objective_types' => [], 'mt3s_marketing_program_objective_types' => [],
'program_task_types' => [], 'mt3s_marketing_program_task_types' => [],
'program_stakeholder_types' => [], 'mt3s_marketing_program_stakeholder_types' => [],
// Default region (ISO 3166-1 alpha-2, e.g. FR) used to parse stakeholder phone numbers typed // Default region (ISO 3166-1 alpha-2, e.g. FR) used to parse stakeholder phone numbers typed
// without a country prefix, on save. Read through StakeholderModel. // without a country prefix, on save. Read through StakeholderModel.
'program_stakeholder_phone_region' => 'FR', 'mt3s_marketing_program_stakeholder_phone_region' => 'FR',
// Which audience persona attributes are offered on the audience forms, one toggle per attribute // Which audience persona attributes are offered on the audience forms, one toggle per attribute
// (Settings > Configuration > Program Settings). Read through AudienceAttributes; a parameter set // (Settings > Configuration > Program Settings). Read through AudienceAttributes; a parameter set
// to false turns the attribute off, and one that was never saved means enabled. // to false turns the attribute off, and one that was never saved means enabled.
'program_audience_attribute_tagline' => true, 'mt3s_marketing_program_audience_attribute_tagline' => true,
'program_audience_attribute_profile' => true, 'mt3s_marketing_program_audience_attribute_profile' => true,
'program_audience_attribute_motivations' => true, 'mt3s_marketing_program_audience_attribute_motivations' => true,
'program_audience_attribute_barriers' => true, 'mt3s_marketing_program_audience_attribute_barriers' => true,
'program_audience_attribute_frustrations' => true, 'mt3s_marketing_program_audience_attribute_frustrations' => true,
'program_audience_attribute_triggers' => true, 'mt3s_marketing_program_audience_attribute_triggers' => true,
'program_audience_attribute_decision_role' => true, 'mt3s_marketing_program_audience_attribute_decision_role' => true,
'program_audience_attribute_tones' => true, 'mt3s_marketing_program_audience_attribute_tones' => true,
'program_audience_attribute_channels' => true, 'mt3s_marketing_program_audience_attribute_channels' => true,
'program_audience_attribute_stages' => true, 'mt3s_marketing_program_audience_attribute_stages' => true,
'program_audience_attribute_size' => true, 'mt3s_marketing_program_audience_attribute_size' => true,
// The values of an audience's closed attributes, edited in Settings > Configuration > Program // The values of an audience's closed attributes, edited in Settings > Configuration > Program
// Settings. Each is a list of ['key' => …, 'names' => [locale => …]], read through // Settings. Each is a list of ['key' => …, 'names' => [locale => …]], read through
// ItemTypeProvider (kinds "audience_decision_role" and "audience_tone"). // ItemTypeProvider (kinds "audience_decision_role" and "audience_tone").
'program_audience_decision_roles' => [], 'mt3s_marketing_program_audience_decision_roles' => [],
'program_audience_tones' => [], 'mt3s_marketing_program_audience_tones' => [],
// Which audience persona attributes are offered on the audience forms, one toggle per attribute
// (Settings > Configuration > Program Settings). The parameter names follow
// AudienceAttributes::toggleParameter(); a parameter set to false turns the attribute off.
// Defaults are handled by AudienceAttributes (enabled unless set to false).
'program_audience_attribute_tagline' => true,
'program_audience_attribute_profile' => true,
'program_audience_attribute_motivations' => true,
'program_audience_attribute_barriers' => true,
'program_audience_attribute_frustrations' => true,
'program_audience_attribute_triggers' => true,
'program_audience_attribute_decision_role' => true,
'program_audience_attribute_tones' => true,
'program_audience_attribute_channels' => true,
'program_audience_attribute_stages' => true,
'program_audience_attribute_size' => true,
// The values of an audience's closed attributes, edited in Settings > Configuration > Program
// Settings. Each is a list of ['key' => …, 'names' => [locale => …]], read through
// ItemTypeProvider (kinds "audience_decision_role" and "audience_tone").
'program_audience_decision_roles' => [],
'program_audience_tones' => [],
], ],
]; ];
+14 -10
View File
@@ -16,19 +16,23 @@ return function (ContainerConfigurator $configurator): void {
'Tests', 'Tests',
]; ];
$services->load('MauticPlugin\\ProgramBundle\\', '../') $services->load('MauticPlugin\\MT3SMarketingProgramBundle\\', '../')
->exclude('../{'.implode(',', array_merge(MauticCoreExtension::DEFAULT_EXCLUDES, $excludes)).'}'); ->exclude('../{'.implode(',', array_merge(MauticCoreExtension::DEFAULT_EXCLUDES, $excludes)).'}');
// Entity/ is excluded above; repositories must still be services for Doctrine to build them. // Entity/ is excluded above; repositories must still be services for Doctrine to build them.
$services->load('MauticPlugin\\ProgramBundle\\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('program'). // Lets core resolve the model with getModel('mt3smp.program').
$services->alias('mautic.program.model.initiative', MauticPlugin\ProgramBundle\Model\InitiativeModel::class); $services->alias('mt3s.marketing_program.model.program', MauticPlugin\MT3SMarketingProgramBundle\Model\ProgramModel::class);
// getModel('program.task'). $services->alias('mautic.mt3smp.model.program', MauticPlugin\MT3SMarketingProgramBundle\Model\ProgramModel::class);
$services->alias('mautic.program.model.task', MauticPlugin\ProgramBundle\Model\TaskModel::class); // getModel('mt3smp.task').
// getModel('program.stakeholder'). $services->alias('mt3s.marketing_program.model.task', MauticPlugin\MT3SMarketingProgramBundle\Model\TaskModel::class);
$services->alias('mautic.program.model.stakeholder', MauticPlugin\ProgramBundle\Model\StakeholderModel::class); $services->alias('mautic.mt3smp.model.task', MauticPlugin\MT3SMarketingProgramBundle\Model\TaskModel::class);
// getModel('program.audience'). // getModel('mt3smp.stakeholder').
$services->alias('mautic.program.model.audience', MauticPlugin\ProgramBundle\Model\AudienceModel::class); $services->alias('mt3s.marketing_program.model.stakeholder', MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel::class);
$services->alias('mautic.mt3smp.model.stakeholder', MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel::class);
// getModel('mt3smp.audience').
$services->alias('mt3s.marketing_program.model.audience', MauticPlugin\MT3SMarketingProgramBundle\Model\AudienceModel::class);
$services->alias('mautic.mt3smp.model.audience', MauticPlugin\MT3SMarketingProgramBundle\Model\AudienceModel::class);
}; };
+13 -13
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Controller; namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
use Mautic\CoreBundle\Controller\AbstractStandardFormController; use Mautic\CoreBundle\Controller\AbstractStandardFormController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@@ -10,26 +10,26 @@ use Symfony\Component\HttpFoundation\Response;
/** /**
* List, create, edit and delete audiences (Programs > Audiences), the global directory of who the * List, create, edit and delete audiences (Programs > Audiences), the global directory of who the
* initiatives are aimed at, using core's standard CRUD flow. Audiences are independent of initiatives; initiatives * programs are aimed at, using core's standard CRUD flow. Audiences are independent of programs; programs
* link to them from their Audiences tab (InitiativeAudience carries the audience's priority in that * link to them from their Audiences tab (ProgramAudience carries the audience's priority in that
* initiative). * program).
* *
* Model program.audience (mautic.program.model.audience), permission base program:audiences, translation * Model mt3smp.audience (mt3s.marketing_program.model.audience), permission base mt3smarketingprogram:audiences, translation
* base mautic.program.audience. * base mt3s.marketing_program.audience.
*/ */
class AudienceController extends AbstractStandardFormController class AudienceController extends AbstractStandardFormController
{ {
public const ROUTE_INDEX = 'initiative_audience_index'; public const ROUTE_INDEX = 'mt3s_marketing_program_audience_index';
public const ROUTE_ACTION = 'initiative_audience_action'; public const ROUTE_ACTION = 'mt3s_marketing_program_audience_action';
protected function getModelName(): string protected function getModelName(): string
{ {
return 'program.audience'; return 'mt3smp.audience';
} }
protected function getTemplateBase(): string protected function getTemplateBase(): string
{ {
return '@Program/Audience'; return '@MT3SMarketingProgram/Audience';
} }
protected function getIndexRoute(): string protected function getIndexRoute(): string
@@ -44,7 +44,7 @@ class AudienceController extends AbstractStandardFormController
protected function getJsLoadMethodPrefix(): string protected function getJsLoadMethodPrefix(): string
{ {
return 'programAudience'; return 'mt3sMpProgramAudience';
} }
/** /**
@@ -62,14 +62,14 @@ class AudienceController extends AbstractStandardFormController
/** /**
* The audience's detail page (the directory entry, its persona attributes, its segments and * The audience's detail page (the directory entry, its persona attributes, its segments and
* the initiatives it is assigned to). The standard controller has no view action of its own, so it * the programs it is assigned to). The standard controller has no view action of its own, so it
* is routed here. * is routed here.
* *
* @param int $objectId * @param int $objectId
*/ */
public function viewAction(Request $request, $objectId): Response public function viewAction(Request $request, $objectId): Response
{ {
return $this->viewStandard($request, $objectId, 'audience', 'initiative'); return $this->viewStandard($request, $objectId, 'audience', 'program');
} }
/** /**
+13 -13
View File
@@ -2,14 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Controller; namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
use Mautic\CoreBundle\Configurator\Configurator; use Mautic\CoreBundle\Configurator\Configurator;
use Mautic\CoreBundle\Controller\AbstractFormController; use Mautic\CoreBundle\Controller\AbstractFormController;
use Mautic\CoreBundle\Helper\CacheHelper; use Mautic\CoreBundle\Helper\CacheHelper;
use MauticPlugin\ProgramBundle\Form\Type\ItemTypesType; use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\ItemTypesType;
use MauticPlugin\ProgramBundle\Service\ItemTypeInUseGuard; use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeInUseGuard;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -20,18 +20,18 @@ use Symfony\Component\HttpFoundation\Response;
* The Item types page (Programs > Item types): the type lists of the plugin's items — insights * The Item types page (Programs > Item types): the type lists of the plugin's items — insights
* (description items), allocations, objectives, tasks, stakeholders, and the values offered for * (description items), allocations, objectives, tasks, stakeholders, and the values offered for
* an audience's decision roles and tones. Formerly part of Settings > Configuration > Program * an audience's decision roles and tones. Formerly part of Settings > Configuration > Program
* Settings; now on its own page under Programs, so a user with the program:itemtypes permissions * Settings; now on its own page under Programs, so a user with the mt3smarketingprogram:itemtypes permissions
* manages the types without being an administrator. * manages the types without being an administrator.
* *
* Each list is a local.php parameter (ItemTypeProvider::PARAMETERS), saved through core's * Each list is a local.php parameter (ItemTypeProvider::PARAMETERS), saved through core's
* Configurator exactly like Settings > Configuration saves its own forms: merge, write, refresh * Configurator exactly like Settings > Configuration saves its own forms: merge, write, refresh
* the config. A type that items still use cannot be removed (ItemTypeInUseGuard). * the config. A type that items still use cannot be removed (ItemTypeInUseGuard).
* *
* Permissions: program:itemtypes:view shows the page, program:itemtypes:edit saves it. * Permissions: mt3smarketingprogram:itemtypes:view shows the page, mt3smarketingprogram:itemtypes:edit saves it.
*/ */
class ItemTypesController extends AbstractFormController class ItemTypesController extends AbstractFormController
{ {
public const ROUTE_INDEX = 'program_item_types_index'; public const ROUTE_INDEX = 'mt3s_marketing_program_item_types_index';
/** /**
* Shows the lists, and saves them on POST. * Shows the lists, and saves them on POST.
@@ -44,7 +44,7 @@ class ItemTypesController extends AbstractFormController
Configurator $configurator, Configurator $configurator,
CacheHelper $cacheHelper, CacheHelper $cacheHelper,
): Response { ): Response {
if (!$this->security->isGranted('program:itemtypes:view')) { if (!$this->security->isGranted('mt3smarketingprogram:itemtypes:view')) {
$this->throwAccessDenied(); $this->throwAccessDenied();
} }
@@ -60,7 +60,7 @@ class ItemTypesController extends AbstractFormController
$isWritable = $configurator->isFileWritable(); $isWritable = $configurator->isFileWritable();
if ('POST' === $request->getMethod()) { if ('POST' === $request->getMethod()) {
if (!$this->security->isGranted('program:itemtypes:edit')) { if (!$this->security->isGranted('mt3smarketingprogram:itemtypes:edit')) {
$this->throwAccessDenied(); $this->throwAccessDenied();
} }
@@ -78,7 +78,7 @@ class ItemTypesController extends AbstractFormController
if ([] !== $removedInUse) { if ([] !== $removedInUse) {
foreach ($removedInUse as $names) { foreach ($removedInUse as $names) {
$form->addError(new FormError( $form->addError(new FormError(
$this->translator->trans('mautic.program.config.type.in_use', ['%types%' => implode(', ', $names)], 'validators') $this->translator->trans('mt3s.marketing_program.config.type.in_use', ['%types%' => implode(', ', $names)], 'validators')
)); ));
} }
} else { } else {
@@ -92,7 +92,7 @@ class ItemTypesController extends AbstractFormController
$configurator->write(); $configurator->write();
$this->addFlashMessage('mautic.program.item_type.saved'); $this->addFlashMessage('mt3s.marketing_program.item_type.saved');
// local.php changed: the cached container is stale until refreshed. // local.php changed: the cached container is stale until refreshed.
$cacheHelper->refreshConfig(); $cacheHelper->refreshConfig();
@@ -107,10 +107,10 @@ class ItemTypesController extends AbstractFormController
'form' => $form->createView(), 'form' => $form->createView(),
'isWritable' => $isWritable, 'isWritable' => $isWritable,
], ],
'contentTemplate' => '@Program/ItemTypes/form.html.twig', 'contentTemplate' => '@MT3SMarketingProgram/ItemTypes/form.html.twig',
'passthroughVars' => [ 'passthroughVars' => [
'activeLink' => '#'.self::ROUTE_INDEX, 'activeLink' => '#'.self::ROUTE_INDEX,
'mauticContent' => 'programItemTypes', 'mauticContent' => 'mt3sMpProgramItemTypes',
'route' => $action, 'route' => $action,
], ],
]); ]);
@@ -2,37 +2,37 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Controller; namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
use Mautic\CoreBundle\Controller\AbstractStandardFormController; use Mautic\CoreBundle\Controller\AbstractStandardFormController;
use MauticPlugin\ProgramBundle\Entity\Initiative; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\ProgramBundle\Model\TaskModel; use MauticPlugin\MT3SMarketingProgramBundle\Model\TaskModel;
use Symfony\Component\HttpFoundation\Request; 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 plans, using core's standard CRUD flow.
* *
* Core derives most names from the model name "initiative": model mautic.program.model.initiative, permission base * Core derives most names from the model name "program": model mt3s.marketing_program.model.program, permission base
* program:initiatives (from InitiativeModel), translation base mautic.program, session base mautic.program. * mt3smarketingprogram:programs (from ProgramModel), translation base mt3s.marketing_program, session base mt3s.marketing_program.
*/ */
class InitiativeController extends AbstractStandardFormController class ProgramController extends AbstractStandardFormController
{ {
public const ROUTE_INDEX = 'initiative_index'; public const ROUTE_INDEX = 'mt3s_marketing_program_index';
public const ROUTE_ACTION = 'initiative_action'; public const ROUTE_ACTION = 'mt3s_marketing_program_action';
protected function getModelName(): string protected function getModelName(): string
{ {
return 'program.initiative'; return 'mt3smp.program';
} }
protected function getTemplateBase(): string protected function getTemplateBase(): string
{ {
return '@Program/Initiative'; return '@MT3SMarketingProgram/Program';
} }
/** /**
* Core would build mautic_initiative_index; the plugin's routes use the plan_ prefix. * Core would build mautic_mt3s_marketing_program_index; the plugin's routes use the plan_ prefix.
*/ */
protected function getIndexRoute(): string protected function getIndexRoute(): string
{ {
@@ -53,7 +53,7 @@ class InitiativeController extends AbstractStandardFormController
} }
/** /**
* The initiative detail page (tabs: Details, Description, Objectives, Allocations, Audiences, Stakeholders, Tasks). * The program detail page (tabs: Details, Description, Objectives, Allocations, Audiences, Stakeholders, Tasks).
* *
* Core's viewStandard() isn't used: for users who aren't administrators it checks an * Core's viewStandard() isn't used: for users who aren't administrators it checks an
* "<entity>:export:enable" permission, which plans don't have. * "<entity>:export:enable" permission, which plans don't have.
@@ -62,13 +62,13 @@ class InitiativeController extends AbstractStandardFormController
*/ */
public function viewAction(Request $request, $objectId): Response public function viewAction(Request $request, $objectId): Response
{ {
$initiative = $this->getModel($this->getModelName())->getEntity((int) $objectId); $program = $this->getModel($this->getModelName())->getEntity((int) $objectId);
if (!$initiative instanceof Initiative) { if (!$program instanceof Program) {
return $this->notFound('mautic.program.error.notfound'); return $this->notFound('mt3s.marketing_program.error.notfound');
} }
if (!$this->checkActionPermission('view', $initiative)) { if (!$this->checkActionPermission('view', $program)) {
return $this->accessDenied(); return $this->accessDenied();
} }
@@ -88,9 +88,9 @@ class InitiativeController extends AbstractStandardFormController
$taskPermissions = $this->security->isGranted( $taskPermissions = $this->security->isGranted(
[ [
'program:tasks:create', 'mt3smarketingprogram:tasks:create',
'program:tasks:editown', 'mt3smarketingprogram:tasks:editown',
'program:tasks:editother', 'mt3smarketingprogram:tasks:editother',
], ],
'RETURN_ARRAY', 'RETURN_ARRAY',
null, null,
@@ -99,9 +99,9 @@ class InitiativeController extends AbstractStandardFormController
return $this->delegateView([ return $this->delegateView([
'viewParameters' => [ 'viewParameters' => [
'item' => $initiative, 'item' => $program,
'permissions' => $permissions, 'permissions' => $permissions,
'taskTree' => $this->getTaskModel()->getTaskTree($initiative), 'taskTree' => $this->getTaskModel()->getTaskTree($program),
'taskPermissions' => $taskPermissions, 'taskPermissions' => $taskPermissions,
// Core's page_actions helper would otherwise build mautic_plan_* route names. // Core's page_actions helper would otherwise build mautic_plan_* route names.
'indexRoute' => self::ROUTE_INDEX, 'indexRoute' => self::ROUTE_INDEX,
@@ -110,15 +110,15 @@ class InitiativeController extends AbstractStandardFormController
], ],
'contentTemplate' => $this->getTemplateName('details.html.twig'), 'contentTemplate' => $this->getTemplateName('details.html.twig'),
'passthroughVars' => [ 'passthroughVars' => [
'activeLink' => '#initiative_index', 'activeLink' => '#mt3s_marketing_program_index',
'mauticContent' => $this->getJsLoadMethodPrefix(), 'mauticContent' => $this->getJsLoadMethodPrefix(),
'route' => $this->generateUrl(self::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $initiative->getId()]), 'route' => $this->generateUrl(self::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $program->getId()]),
], ],
]); ]);
} }
/** /**
* Adds the initiative's task tree to the form, for the read-only Tasks tab. * Adds the program's task tree to the form, for the read-only Tasks tab.
* *
* @param array<string, mixed> $args * @param array<string, mixed> $args
* @param string $action * @param string $action
@@ -127,10 +127,10 @@ class InitiativeController extends AbstractStandardFormController
*/ */
protected function getViewArguments(array $args, $action): array protected function getViewArguments(array $args, $action): array
{ {
$initiative = $args['viewParameters']['entity'] ?? null; $program = $args['viewParameters']['entity'] ?? null;
if (in_array($action, ['new', 'edit'], true) && $initiative instanceof Initiative && null !== $initiative->getId()) { if (in_array($action, ['new', 'edit'], true) && $program instanceof Program && null !== $program->getId()) {
$args['viewParameters']['taskTree'] = $this->getTaskModel()->getTaskTree($initiative); $args['viewParameters']['taskTree'] = $this->getTaskModel()->getTaskTree($program);
} }
return parent::getViewArguments($args, $action); return parent::getViewArguments($args, $action);
@@ -138,7 +138,7 @@ class InitiativeController extends AbstractStandardFormController
private function getTaskModel(): TaskModel private function getTaskModel(): TaskModel
{ {
$model = $this->getModel('program.task'); $model = $this->getModel('mt3smp.task');
\assert($model instanceof TaskModel); \assert($model instanceof TaskModel);
return $model; return $model;
+9 -9
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Controller; namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
use Mautic\CoreBundle\Controller\AbstractStandardFormController; use Mautic\CoreBundle\Controller\AbstractStandardFormController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@@ -10,25 +10,25 @@ use Symfony\Component\HttpFoundation\Response;
/** /**
* List, create, edit and delete stakeholders (Programs > Stakeholders), the global directory, using * List, create, edit and delete stakeholders (Programs > Stakeholders), the global directory, using
* core's standard CRUD flow. Stakeholders are independent of initiatives; initiatives 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 program.stakeholder (mautic.program.model.stakeholder), permission base program:stakeholders, * Model mt3smp.stakeholder (mt3s.marketing_program.model.stakeholder), permission base mt3smarketingprogram:stakeholders,
* translation base mautic.program.stakeholder. * translation base mt3s.marketing_program.stakeholder.
*/ */
class StakeholderController extends AbstractStandardFormController class StakeholderController extends AbstractStandardFormController
{ {
public const ROUTE_INDEX = 'initiative_stakeholder_index'; public const ROUTE_INDEX = 'mt3s_marketing_program_stakeholder_index';
public const ROUTE_ACTION = 'initiative_stakeholder_action'; public const ROUTE_ACTION = 'mt3s_marketing_program_stakeholder_action';
protected function getModelName(): string protected function getModelName(): string
{ {
return 'program.stakeholder'; return 'mt3smp.stakeholder';
} }
protected function getTemplateBase(): string protected function getTemplateBase(): string
{ {
return '@Program/Stakeholder'; return '@MT3SMarketingProgram/Stakeholder';
} }
protected function getIndexRoute(): string protected function getIndexRoute(): string
@@ -43,7 +43,7 @@ class StakeholderController extends AbstractStandardFormController
protected function getJsLoadMethodPrefix(): string protected function getJsLoadMethodPrefix(): string
{ {
return 'programStakeholder'; return 'mt3sMpProgramStakeholder';
} }
/** /**
+38 -38
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Controller; namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
use Mautic\CoreBundle\Controller\AbstractStandardFormController; use Mautic\CoreBundle\Controller\AbstractStandardFormController;
use MauticPlugin\ProgramBundle\Entity\Initiative; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\ProgramBundle\Entity\Task; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Task;
use Symfony\Component\Form\Form; use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@@ -14,30 +14,30 @@ 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 program.task (mautic.program.model.task), permission base program:tasks, translation base mautic.program.task. * Model mt3smp.task (mt3s.marketing_program.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);
* - from an initiative's Tasks tab (links with ?returnTo=initiative): back to that initiative. * - from an program's Tasks tab (links with ?returnTo=program): back to that program.
* The origin is kept in the session when the form is opened, because the form posts to a URL * The origin is kept in the session when the form is opened, because the form posts to a URL
* without the query string. * without the query string.
*/ */
class TaskController extends AbstractStandardFormController class TaskController extends AbstractStandardFormController
{ {
public const ROUTE_INDEX = 'initiative_task_index'; public const ROUTE_INDEX = 'mt3s_marketing_program_task_index';
public const ROUTE_ACTION = 'initiative_task_action'; public const ROUTE_ACTION = 'mt3s_marketing_program_task_action';
/** /**
* Value of the returnTo query parameter that sends the user back to the initiative. * Value of the returnTo query parameter that sends the user back to the program.
*/ */
public const RETURN_TO_PLAN = 'initiative'; public const RETURN_TO_PLAN = 'program';
private const SESSION_RETURN_PLAN = 'mautic.program.task.return_initiative.'; private const SESSION_RETURN_PLAN = 'mt3s.marketing_program.task.return_program.';
/** /**
* Initiative to preselect on a new task (from ?initiative=ID, used by the initiative's "Add task" button). * Program to preselect on a new task (from ?program=ID, used by the program's "Add task" button).
*/ */
private ?int $preselectedInitiativeId = null; private ?int $preselectedProgramId = null;
/** /**
* The task saved during this request, if any. * The task saved during this request, if any.
@@ -45,18 +45,18 @@ class TaskController extends AbstractStandardFormController
private ?Task $savedTask = null; private ?Task $savedTask = null;
/** /**
* Initiative to go back to after Save or Cancel, or null for the task list. * Program to go back to after Save or Cancel, or null for the task list.
*/ */
private ?int $returnInitiativeId = null; private ?int $returnProgramId = null;
protected function getModelName(): string protected function getModelName(): string
{ {
return 'program.task'; return 'mt3smp.task';
} }
protected function getTemplateBase(): string protected function getTemplateBase(): string
{ {
return '@Program/Task'; return '@MT3SMarketingProgram/Task';
} }
protected function getIndexRoute(): string protected function getIndexRoute(): string
@@ -71,7 +71,7 @@ class TaskController extends AbstractStandardFormController
protected function getJsLoadMethodPrefix(): string protected function getJsLoadMethodPrefix(): string
{ {
return 'programTask'; return 'mt3sMpProgramTask';
} }
/** /**
@@ -84,9 +84,9 @@ class TaskController extends AbstractStandardFormController
public function newAction(Request $request): Response public function newAction(Request $request): Response
{ {
$initiativeId = $request->query->getInt('initiative'); $programId = $request->query->getInt('program');
$this->preselectedInitiativeId = $initiativeId > 0 ? $initiativeId : null; $this->preselectedProgramId = $programId > 0 ? $programId : null;
$this->returnInitiativeId = $this->resolveReturnInitiative($request, 'new', $this->preselectedInitiativeId); $this->returnProgramId = $this->resolveReturnProgram($request, 'new', $this->preselectedProgramId);
return $this->newStandard($request); return $this->newStandard($request);
} }
@@ -98,24 +98,24 @@ 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);
$initiativeId = $task instanceof Task ? $task->getInitiative()?->getId() : null; $programId = $task instanceof Task ? $task->getProgram()?->getId() : null;
$this->returnInitiativeId = $this->resolveReturnInitiative($request, (string) (int) $objectId, $initiativeId); $this->returnProgramId = $this->resolveReturnProgram($request, (string) (int) $objectId, $programId);
return $this->editStandard($request, $objectId, $ignorePost); return $this->editStandard($request, $objectId, $ignorePost);
} }
/** /**
* When the form is opened (GET), records whether it came from an initiative (?returnTo=initiative); when it is * When the form is opened (GET), records whether it came from an program (?returnTo=program); when it is
* submitted (POST), reads that record back. Opening the same form from the task list clears it. * submitted (POST), reads that record back. Opening the same form from the task list clears it.
*/ */
private function resolveReturnInitiative(Request $request, string $formKey, ?int $initiativeId): ?int private function resolveReturnProgram(Request $request, string $formKey, ?int $programId): ?int
{ {
$session = $request->getSession(); $session = $request->getSession();
$key = self::SESSION_RETURN_PLAN.$formKey; $key = self::SESSION_RETURN_PLAN.$formKey;
if (!$request->isMethod('POST')) { if (!$request->isMethod('POST')) {
$fromInitiative = self::RETURN_TO_PLAN === $request->query->get('returnTo') && null !== $initiativeId; $fromProgram = self::RETURN_TO_PLAN === $request->query->get('returnTo') && null !== $programId;
$session->set($key, $fromInitiative ? $initiativeId : null); $session->set($key, $fromProgram ? $programId : null);
} }
$value = $session->get($key); $value = $session->get($key);
@@ -143,10 +143,10 @@ class TaskController extends AbstractStandardFormController
{ {
$entity = parent::getFormEntity($action, $objectId, $isClone); $entity = parent::getFormEntity($action, $objectId, $isClone);
if ('new' === $action && $entity instanceof Task && null === $entity->getInitiative() && null !== $this->preselectedInitiativeId) { if ('new' === $action && $entity instanceof Task && null === $entity->getProgram() && null !== $this->preselectedProgramId) {
$initiative = $this->getModel('program.initiative')->getEntity($this->preselectedInitiativeId); $program = $this->getModel('mt3smp.program')->getEntity($this->preselectedProgramId);
if ($initiative instanceof Initiative) { if ($program instanceof Program) {
$entity->setInitiative($initiative); $entity->setProgram($program);
} }
} }
@@ -163,8 +163,8 @@ class TaskController extends AbstractStandardFormController
} }
/** /**
* After Save or Cancel (not Apply) on a form opened from an initiative, go back to that initiative. If the task * After Save or Cancel (not Apply) on a form opened from an program, go back to that program. If the task
* was moved to another initiative, go to its new initiative. 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
* *
@@ -172,13 +172,13 @@ class TaskController extends AbstractStandardFormController
*/ */
protected function getPostActionRedirectArguments(array $args, $action): array protected function getPostActionRedirectArguments(array $args, $action): array
{ {
if (in_array($action, ['new', 'edit'], true) && null !== $this->returnInitiativeId) { if (in_array($action, ['new', 'edit'], true) && null !== $this->returnProgramId) {
$initiativeId = $this->savedTask?->getInitiative()?->getId() ?? $this->returnInitiativeId; $programId = $this->savedTask?->getProgram()?->getId() ?? $this->returnProgramId;
$args['returnUrl'] = $this->generateUrl(InitiativeController::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $initiativeId]); $args['returnUrl'] = $this->generateUrl(ProgramController::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $programId]);
$args['contentTemplate'] = InitiativeController::class.'::viewAction'; $args['contentTemplate'] = ProgramController::class.'::viewAction';
$args['viewParameters'] = ['objectId' => $initiativeId]; $args['viewParameters'] = ['objectId' => $programId];
$args['passthroughVars'] = array_merge($args['passthroughVars'] ?? [], ['mauticContent' => 'initiative']); $args['passthroughVars'] = array_merge($args['passthroughVars'] ?? [], ['mauticContent' => 'program']);
} }
return parent::getPostActionRedirectArguments($args, $action); return parent::getPostActionRedirectArguments($args, $action);
+7 -6
View File
@@ -2,20 +2,21 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Controller; namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
use Mautic\CoreBundle\Controller\CommonController; use Mautic\CoreBundle\Controller\CommonController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
/** /**
* UTM Taxonomies (Programs > UTM Taxonomies): a placeholder for now, so the menu entry has a * UTM Taxonomies: a placeholder page for the coming feature, kept out of the menu since
* page. The content (classifying the UTM parameters of the programs' campaigns and links) comes * 0.17.0 (the route stays; the page is reachable at /s/marketing-program-utm-taxonomies).
* The content (classifying the UTM parameters of the programs' campaigns and links) comes
* later; until then the page shows an empty content block. * later; until then the page shows an empty content block.
*/ */
class UtmTaxonomyController extends CommonController class UtmTaxonomyController extends CommonController
{ {
public const ROUTE_INDEX = 'program_utm_taxonomy_index'; public const ROUTE_INDEX = 'mt3s_marketing_program_utm_taxonomy_index';
/** /**
* @param int $page * @param int $page
@@ -28,10 +29,10 @@ class UtmTaxonomyController extends CommonController
'viewParameters' => [ 'viewParameters' => [
'tmpl' => $tmpl, 'tmpl' => $tmpl,
], ],
'contentTemplate' => '@Program/UtmTaxonomy/list.html.twig', 'contentTemplate' => '@MT3SMarketingProgram/UtmTaxonomy/list.html.twig',
'passthroughVars' => [ 'passthroughVars' => [
'activeLink' => '#'.self::ROUTE_INDEX, 'activeLink' => '#'.self::ROUTE_INDEX,
'mauticContent' => 'programUtmTaxonomy', 'mauticContent' => 'mt3sMpProgramUtmTaxonomy',
'route' => $this->generateUrl(self::ROUTE_INDEX), 'route' => $this->generateUrl(self::ROUTE_INDEX),
], ],
]); ]);
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\DependencyInjection; namespace MauticPlugin\MT3SMarketingProgramBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -12,7 +12,7 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
/** /**
* Loads Config/services.php (Symfony finds this class by naming convention). * Loads Config/services.php (Symfony finds this class by naming convention).
*/ */
final class ProgramExtension extends Extension final class MT3SMarketingProgramExtension extends Extension
{ {
/** /**
* @param mixed[] $configs * @param mixed[] $configs
+34 -34
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@@ -19,11 +19,11 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
/** /**
* One audience of the global directory (Programs > Audiences): who the plan is aimed at, and how. * One audience of the global directory (Programs > Audiences): who the plan is aimed at, and how.
* Audiences are independent of plans; a plan links to them from its Audiences tab through InitiativeAudience, * Audiences are independent of plans; a plan links to them from its Audiences tab through ProgramAudience,
* which carries the audience's priority in that plan, and possibly a initiative-specific message. * which carries the audience's priority in that plan, and possibly a program-specific message.
* *
* Which attributes are offered on the forms is set up by the admin in Settings > Configuration > * Which attributes are offered on the forms is set up by the admin in Settings > Configuration >
* Initiative Settings (per-attribute toggles, so a b2b install and a b2c install define their personas * Program Settings (per-attribute toggles, so a b2b install and a b2c install define their personas
* differently); the decision roles and the tones are lists edited there too. See AudienceAttributes. * differently); the decision roles and the tones are lists edited there too. See AudienceAttributes.
* *
* The stages are the Mautic stages (Settings > Stages) this audience maps to; an audience can have * The stages are the Mautic stages (Settings > Stages) this audience maps to; an audience can have
@@ -33,26 +33,26 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
* informational: the user may assign none, one or several; the list view shows their names and * informational: the user may assign none, one or several; the list view shows their names and
* their contact counts. Deleting a segment removes the link, not the audience. * their contact counts. Deleting a segment removes the link, not the audience.
* *
* isPublished (from FormEntity) means "active": an unpublished audience is hidden from the initiative * isPublished (from FormEntity) means "active": an unpublished audience is hidden from the program
* form's audience picker, but keeps its history on the initiatives it is already linked to. * form's audience picker, but keeps its history on the mt3s_mp_programs it is already linked to.
*/ */
class Audience extends FormEntity class Audience extends FormEntity
{ {
public const TABLE_NAME = 'initiative_audiences'; public const TABLE_NAME = 'mt3s_mp_program_audiences';
/** /**
* Keys offered for preferredChannels, in display order. * Keys offered for preferredChannels, in display order.
*/ */
public const CHANNELS = [ public const CHANNELS = [
'email' => 'mautic.program.audience.channel.email', 'email' => 'mt3s.marketing_program.audience.channel.email',
'sms' => 'mautic.program.audience.channel.sms', 'sms' => 'mt3s.marketing_program.audience.channel.sms',
'web' => 'mautic.program.audience.channel.web', 'web' => 'mt3s.marketing_program.audience.channel.web',
'social_organic' => 'mautic.program.audience.channel.social_organic', 'social_organic' => 'mt3s.marketing_program.audience.channel.social_organic',
'paid_social' => 'mautic.program.audience.channel.paid_social', 'paid_social' => 'mt3s.marketing_program.audience.channel.paid_social',
'paid_search' => 'mautic.program.audience.channel.paid_search', 'paid_search' => 'mt3s.marketing_program.audience.channel.paid_search',
'events_webinar' => 'mautic.program.audience.channel.events_webinar', 'events_webinar' => 'mt3s.marketing_program.audience.channel.events_webinar',
'outbound_sales' => 'mautic.program.audience.channel.outbound_sales', 'outbound_sales' => 'mt3s.marketing_program.audience.channel.outbound_sales',
'partners' => 'mautic.program.audience.channel.partners', 'partners' => 'mt3s.marketing_program.audience.channel.partners',
]; ];
private ?int $id = null; private ?int $id = null;
@@ -92,13 +92,13 @@ class Audience extends FormEntity
private ?string $triggers = null; private ?string $triggers = null;
/** /**
* Key of a decision role set up in Settings > Configuration > Initiative Settings * Key of a decision role set up in Settings > Configuration > Program Settings
* (parameter program_audience_decision_roles), or null when the attribute is unused. * (parameter program_audience_decision_roles), or null when the attribute is unused.
*/ */
private ?string $decisionRole = null; private ?string $decisionRole = null;
/** /**
* Keys of tones set up in Settings > Configuration > Initiative Settings * Keys of tones set up in Settings > Configuration > Program Settings
* (parameter program_audience_tones), or null/[] when the attribute is unused. * (parameter program_audience_tones), or null/[] when the attribute is unused.
* *
* @var list<string>|null * @var list<string>|null
@@ -106,7 +106,7 @@ class Audience extends FormEntity
private ?array $preferredTones = null; private ?array $preferredTones = null;
/** /**
* Keys of self::CHANNELS the initiative means to use for this audience. * Keys of self::CHANNELS the program means to use for this audience.
* *
* @var list<string>|null * @var list<string>|null
*/ */
@@ -132,18 +132,18 @@ class Audience extends FormEntity
private ?int $estimatedSize = null; private ?int $estimatedSize = null;
/** /**
* The links to the initiatives this audience is assigned to. Inverse side, read-only from here: the * The links to the mt3s_mp_programs this audience is assigned to. Inverse side, read-only from here: the
* links are managed from the plans (Initiative::addAudience/removeAudience). * links are managed from the plans (Program::addAudience/removeAudience).
* *
* @var Collection<int, InitiativeAudience> * @var Collection<int, ProgramAudience>
*/ */
private Collection $initiativeLinks; private Collection $programLinks;
public function __construct() public function __construct()
{ {
$this->stages = new ArrayCollection(); $this->stages = new ArrayCollection();
$this->segments = new ArrayCollection(); $this->segments = new ArrayCollection();
$this->initiativeLinks = new ArrayCollection(); $this->programLinks = new ArrayCollection();
} }
public function __clone() public function __clone()
@@ -151,7 +151,7 @@ class Audience extends FormEntity
$this->id = null; $this->id = null;
$this->stages = new ArrayCollection(); $this->stages = new ArrayCollection();
$this->segments = new ArrayCollection(); $this->segments = new ArrayCollection();
$this->initiativeLinks = new ArrayCollection(); $this->programLinks = new ArrayCollection();
parent::__clone(); parent::__clone();
} }
@@ -213,13 +213,13 @@ class Audience extends FormEntity
->build(); ->build();
$builder->createManyToMany('stages', Stage::class) $builder->createManyToMany('stages', Stage::class)
->setJoinTable('initiative_audiences_stages') ->setJoinTable('mt3s_mp_program_audiences_stages')
->addJoinColumn('audience_id', 'id', false, false, 'CASCADE') ->addJoinColumn('audience_id', 'id', false, false, 'CASCADE')
->addInverseJoinColumn('stage_id', 'id', false, false, 'CASCADE') ->addInverseJoinColumn('stage_id', 'id', false, false, 'CASCADE')
->build(); ->build();
$builder->createManyToMany('segments', LeadList::class) $builder->createManyToMany('segments', LeadList::class)
->setJoinTable('initiative_audiences_segments') ->setJoinTable('mt3s_mp_program_audiences_segments')
->addJoinColumn('audience_id', 'id', false, false, 'CASCADE') ->addJoinColumn('audience_id', 'id', false, false, 'CASCADE')
->addInverseJoinColumn('leadlist_id', 'id', false, false, 'CASCADE') ->addInverseJoinColumn('leadlist_id', 'id', false, false, 'CASCADE')
->build(); ->build();
@@ -230,8 +230,8 @@ class Audience extends FormEntity
->option('unsigned', true) ->option('unsigned', true)
->build(); ->build();
// The links to the initiatives, managed from the initiatives. // The links to the mt3s_mp_programs, managed from the mt3s_mp_programs.
$builder->createOneToMany('initiativeLinks', InitiativeAudience::class) $builder->createOneToMany('programLinks', ProgramAudience::class)
->mappedBy('audience') ->mappedBy('audience')
->fetchExtraLazy() ->fetchExtraLazy()
->build(); ->build();
@@ -239,9 +239,9 @@ class Audience extends FormEntity
public static function loadValidatorMetadata(ClassMetadata $metadata): void public static function loadValidatorMetadata(ClassMetadata $metadata): void
{ {
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.program.audience.name.required')); $metadata->addPropertyConstraint('name', new NotBlank(message: 'mt3s.marketing_program.audience.name.required'));
$metadata->addPropertyConstraint('name', new Length(max: 191)); $metadata->addPropertyConstraint('name', new Length(max: 191));
$metadata->addPropertyConstraint('estimatedSize', new PositiveOrZero(message: 'mautic.program.audience.estimated_size.invalid')); $metadata->addPropertyConstraint('estimatedSize', new PositiveOrZero(message: 'mt3s.marketing_program.audience.estimated_size.invalid'));
$metadata->addPropertyConstraint('decisionRole', new Length(max: 64)); $metadata->addPropertyConstraint('decisionRole', new Length(max: 64));
} }
@@ -470,10 +470,10 @@ class Audience extends FormEntity
} }
/** /**
* @return Collection<int, InitiativeAudience> * @return Collection<int, ProgramAudience>
*/ */
public function getInitiativeLinks(): Collection public function getProgramLinks(): Collection
{ {
return $this->initiativeLinks; return $this->programLinks;
} }
} }
+3 -3
View File
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
/** /**
* How important an initiative's audience is to the initiative. The order of the cases is the order of the dropdown. * How important an program's audience is to the program. The order of the cases is the order of the dropdown.
*/ */
enum AudiencePriority: string enum AudiencePriority: string
{ {
@@ -15,7 +15,7 @@ enum AudiencePriority: string
public function getLabelKey(): string public function getLabelKey(): string
{ {
return 'mautic.program.audience.priority.'.$this->value; return 'mt3s.marketing_program.audience.priority.'.$this->value;
} }
public function getLabelClass(): string public function getLabelClass(): string
+3 -3
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Entity\CommonRepository;
@@ -40,7 +40,7 @@ class AudienceRepository extends CommonRepository
{ {
$rows = $this->getEntityManager()->getConnection()->fetchAllAssociative( $rows = $this->getEntityManager()->getConnection()->fetchAllAssociative(
'SELECT s.leadlist_id, COUNT(ll.lead_id) AS cnt 'SELECT s.leadlist_id, COUNT(ll.lead_id) AS cnt
FROM initiative_audiences_segments s FROM mt3s_mp_program_audiences_segments s
JOIN lead_lists_leads ll ON ll.leadlist_id = s.leadlist_id AND ll.manually_removed = 0 JOIN lead_lists_leads ll ON ll.leadlist_id = s.leadlist_id AND ll.manually_removed = 0
WHERE s.audience_id = :audienceId WHERE s.audience_id = :audienceId
GROUP BY s.leadlist_id', GROUP BY s.leadlist_id',
@@ -72,7 +72,7 @@ class AudienceRepository extends CommonRepository
$connection = $this->getEntityManager()->getConnection(); $connection = $this->getEntityManager()->getConnection();
$rows = $connection->fetchAllAssociative( $rows = $connection->fetchAllAssociative(
'SELECT s.audience_id, s.leadlist_id, COUNT(ll.lead_id) AS cnt 'SELECT s.audience_id, s.leadlist_id, COUNT(ll.lead_id) AS cnt
FROM initiative_audiences_segments s FROM mt3s_mp_program_audiences_segments s
JOIN lead_lists_leads ll ON ll.leadlist_id = s.leadlist_id AND ll.manually_removed = 0 JOIN lead_lists_leads ll ON ll.leadlist_id = s.leadlist_id AND ll.manually_removed = 0
WHERE s.audience_id IN (:audienceIds) WHERE s.audience_id IN (:audienceIds)
GROUP BY s.audience_id, s.leadlist_id', GROUP BY s.audience_id, s.leadlist_id',
+3 -3
View File
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
/** /**
* The kind of audience an initiative's audience entry describes. The order of the cases is the order of the dropdown. * The kind of audience an program's audience entry describes. The order of the cases is the order of the dropdown.
*/ */
enum AudienceType: string enum AudienceType: string
{ {
@@ -17,7 +17,7 @@ enum AudienceType: string
public function getLabelKey(): string public function getLabelKey(): string
{ {
return 'mautic.program.audience.type.'.$this->value; return 'mt3s.marketing_program.audience.type.'.$this->value;
} }
/** /**
+2 -2
View File
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
/** /**
* For repositories of typed initiative items (description items, allocation items, objectives, tasks). * For repositories of typed program items (description items, allocation items, objectives, tasks).
*/ */
trait CountsItemsByTypeTrait trait CountsItemsByTypeTrait
{ {
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
/** /**
* An object with an optional start and end date. Checked by the EndDateAfterStartDate constraint. * An object with an optional start and end date. Checked by the EndDateAfterStartDate constraint.
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
/** /**
* The type of a task dependency edge. The order of the cases is the order of the dropdown. * The type of a task dependency edge. The order of the cases is the order of the dropdown.
@@ -16,6 +16,6 @@ enum DependencyType: string
public function getLabelKey(): string public function getLabelKey(): string
{ {
return 'mautic.program.task.dependency_type.'.$this->value; return 'mt3s.marketing_program.task.dependency_type.'.$this->value;
} }
} }
+58 -58
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@@ -12,16 +12,16 @@ use Mautic\CategoryBundle\Entity\Category;
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder; use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
use Mautic\CoreBundle\Entity\FormEntity; use Mautic\CoreBundle\Entity\FormEntity;
use Mautic\UserBundle\Entity\User; use Mautic\UserBundle\Entity\User;
use MauticPlugin\ProgramBundle\Validator\Constraints\EndDateAfterStartDate; use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\EndDateAfterStartDate;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\ClassMetadata;
class Initiative extends FormEntity implements DateRangeInterface class Program extends FormEntity implements DateRangeInterface
{ {
public const TABLE_NAME = 'initiatives'; public const TABLE_NAME = 'mt3s_mp_programs';
public const VERSION_MIN = 1; public const VERSION_MIN = 1;
public const VERSION_MAX = 99; public const VERSION_MAX = 99;
@@ -29,51 +29,51 @@ class Initiative extends FormEntity implements DateRangeInterface
private ?int $id = null; private ?int $id = null;
/** /**
* Initiative version, 1 to 99. Edited by hand; not related to Doctrine optimistic locking. * Program version, 1 to 99. Edited by hand; not related to Doctrine optimistic locking.
*/ */
private ?int $version = self::VERSION_MIN; private ?int $version = self::VERSION_MIN;
/** /**
* @var Collection<int, InitiativeObjective> * @var Collection<int, ProgramObjective>
*/ */
private Collection $objectives; private Collection $objectives;
/** /**
* The content of the Description tab. Each item has a type set up by the admin in * The content of the Description tab. Each item has a type set up by the admin in
* Settings > Configuration > Initiative. * Settings > Configuration > Program.
* *
* @var Collection<int, InitiativeDescriptionItem> * @var Collection<int, ProgramDescriptionItem>
*/ */
private Collection $descriptionItems; private Collection $descriptionItems;
/** /**
* The cost lines of the Allocations tab. Each item has a type set up by the admin in * The cost lines of the Allocations tab. Each item has a type set up by the admin in
* Settings > Configuration > Initiative. * Settings > Configuration > Program.
* *
* @var Collection<int, InitiativeAllocationItem> * @var Collection<int, ProgramAllocationItem>
*/ */
private Collection $allocationItems; private Collection $allocationItems;
/** /**
* The audiences of the Audiences tab: links to the audiences of the global directory * The audiences of the Audiences tab: links to the audiences of the global directory
* (Programs > Audiences), each with the audience's priority in this plan and possibly a * (Programs > Audiences), each with the audience's priority in this plan and possibly a
* initiative-specific message. See InitiativeAudience. * program-specific message. See ProgramAudience.
* *
* @var Collection<int, InitiativeAudience> * @var Collection<int, ProgramAudience>
*/ */
private Collection $audiences; private Collection $audiences;
/** /**
* The links to the stakeholders of the global directory (Programs > Stakeholders), each with the * The links to the stakeholders of the global directory (Programs > Stakeholders), each with the
* stakeholder's role in this plan. See InitiativeStakeholder. * stakeholder's role in this plan. See ProgramStakeholder.
* *
* @var Collection<int, InitiativeStakeholder> * @var Collection<int, ProgramStakeholder>
*/ */
private Collection $stakeholders; private Collection $stakeholders;
/** /**
* Tasks are managed on their own pages (TaskController). * Tasks are managed on their own pages (TaskController).
* Read-only from the initiative: deleting an initiative * Read-only from the program: deleting an program
* deletes its tasks through the database (ON DELETE CASCADE). * deletes its tasks through the database (ON DELETE CASCADE).
* *
* @var Collection<int, Task> * @var Collection<int, Task>
@@ -82,7 +82,7 @@ class Initiative extends FormEntity implements DateRangeInterface
private ?string $name = null; private ?string $name = null;
private InitiativeStatus $status = InitiativeStatus::Draft; private ProgramStatus $status = ProgramStatus::Draft;
/** /**
* Required in the form. The column is nullable only so that deleting the user doesn't delete the plan (SET NULL). * Required in the form. The column is nullable only so that deleting the user doesn't delete the plan (SET NULL).
@@ -160,7 +160,7 @@ class Initiative extends FormEntity implements DateRangeInterface
$builder = new ClassMetadataBuilder($metadata); $builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME) $builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(InitiativeRepository::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).
@@ -171,7 +171,7 @@ class Initiative extends FormEntity implements DateRangeInterface
'fieldName' => 'status', 'fieldName' => 'status',
'type' => Types::STRING, 'type' => Types::STRING,
'length' => 20, 'length' => 20,
'enumType' => InitiativeStatus::class, 'enumType' => ProgramStatus::class,
]); ]);
$builder->createManyToOne('owner', User::class) $builder->createManyToOne('owner', User::class)
@@ -197,8 +197,8 @@ class Initiative extends FormEntity implements DateRangeInterface
->option('default', self::VERSION_MIN) ->option('default', self::VERSION_MIN)
->build(); ->build();
$builder->createOneToMany('objectives', InitiativeObjective::class) $builder->createOneToMany('objectives', ProgramObjective::class)
->mappedBy('initiative') ->mappedBy('program')
->cascadePersist() ->cascadePersist()
->cascadeRemove() ->cascadeRemove()
->orphanRemoval() ->orphanRemoval()
@@ -206,8 +206,8 @@ class Initiative extends FormEntity implements DateRangeInterface
->fetchExtraLazy() ->fetchExtraLazy()
->build(); ->build();
$builder->createOneToMany('descriptionItems', InitiativeDescriptionItem::class) $builder->createOneToMany('descriptionItems', ProgramDescriptionItem::class)
->mappedBy('initiative') ->mappedBy('program')
->cascadePersist() ->cascadePersist()
->cascadeRemove() ->cascadeRemove()
->orphanRemoval() ->orphanRemoval()
@@ -215,8 +215,8 @@ class Initiative extends FormEntity implements DateRangeInterface
->fetchExtraLazy() ->fetchExtraLazy()
->build(); ->build();
$builder->createOneToMany('allocationItems', InitiativeAllocationItem::class) $builder->createOneToMany('allocationItems', ProgramAllocationItem::class)
->mappedBy('initiative') ->mappedBy('program')
->cascadePersist() ->cascadePersist()
->cascadeRemove() ->cascadeRemove()
->orphanRemoval() ->orphanRemoval()
@@ -224,8 +224,8 @@ class Initiative extends FormEntity implements DateRangeInterface
->fetchExtraLazy() ->fetchExtraLazy()
->build(); ->build();
$builder->createOneToMany('audiences', InitiativeAudience::class) $builder->createOneToMany('audiences', ProgramAudience::class)
->mappedBy('initiative') ->mappedBy('program')
->cascadePersist() ->cascadePersist()
->cascadeRemove() ->cascadeRemove()
->orphanRemoval() ->orphanRemoval()
@@ -233,8 +233,8 @@ class Initiative extends FormEntity implements DateRangeInterface
->fetchExtraLazy() ->fetchExtraLazy()
->build(); ->build();
$builder->createOneToMany('stakeholders', InitiativeStakeholder::class) $builder->createOneToMany('stakeholders', ProgramStakeholder::class)
->mappedBy('initiative') ->mappedBy('program')
->cascadePersist() ->cascadePersist()
->cascadeRemove() ->cascadeRemove()
->orphanRemoval() ->orphanRemoval()
@@ -243,7 +243,7 @@ class Initiative extends FormEntity implements DateRangeInterface
->build(); ->build();
$builder->createOneToMany('tasks', Task::class) $builder->createOneToMany('tasks', Task::class)
->mappedBy('initiative') ->mappedBy('program')
->setOrderBy(['name' => 'ASC']) ->setOrderBy(['name' => 'ASC'])
->fetchExtraLazy() ->fetchExtraLazy()
->build(); ->build();
@@ -251,9 +251,9 @@ class Initiative extends FormEntity implements DateRangeInterface
public static function loadValidatorMetadata(ClassMetadata $metadata): void public static function loadValidatorMetadata(ClassMetadata $metadata): void
{ {
$metadata->addPropertyConstraint('version', new NotNull(message: 'mautic.program.version.range')); $metadata->addPropertyConstraint('version', new NotNull(message: 'mt3s.marketing_program.version.range'));
$metadata->addPropertyConstraint('version', new Range( $metadata->addPropertyConstraint('version', new Range(
notInRangeMessage: 'mautic.program.version.range', notInRangeMessage: 'mt3s.marketing_program.version.range',
min: self::VERSION_MIN, min: self::VERSION_MIN,
max: self::VERSION_MAX, max: self::VERSION_MAX,
)); ));
@@ -263,7 +263,7 @@ class Initiative extends FormEntity implements DateRangeInterface
$metadata->addPropertyConstraint('audiences', new Valid()); $metadata->addPropertyConstraint('audiences', new Valid());
$metadata->addPropertyConstraint('stakeholders', new Valid()); $metadata->addPropertyConstraint('stakeholders', new Valid());
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required')); $metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required'));
$metadata->addPropertyConstraint('owner', new NotBlank(message: 'mautic.program.owner.required')); $metadata->addPropertyConstraint('owner', new NotBlank(message: 'mt3s.marketing_program.owner.required'));
$metadata->addConstraint(new EndDateAfterStartDate()); $metadata->addConstraint(new EndDateAfterStartDate());
} }
@@ -295,12 +295,12 @@ class Initiative extends FormEntity implements DateRangeInterface
* Sorted here, not only by the mapping's orderBy: after a reorder, positions change in memory while the * Sorted here, not only by the mapping's orderBy: after a reorder, positions change in memory while the
* loaded collection keeps its old order, and the page shown right after saving uses that collection. * loaded collection keeps its old order, and the page shown right after saving uses that collection.
* *
* @return Collection<int, InitiativeObjective> * @return Collection<int, ProgramObjective>
*/ */
public function getObjectives(): Collection public function getObjectives(): Collection
{ {
$objectives = self::sortedByPosition($this->objectives)->toArray(); $objectives = self::sortedByPosition($this->objectives)->toArray();
usort($objectives, function (InitiativeObjective $a, InitiativeObjective $b): int { usort($objectives, function (ProgramObjective $a, ProgramObjective $b): int {
// An objective without a priority yet sorts last; ties keep the position order. // An objective without a priority yet sorts last; ties keep the position order.
$pa = $a->getPriority() ?? PHP_INT_MAX; $pa = $a->getPriority() ?? PHP_INT_MAX;
$pb = $b->getPriority() ?? PHP_INT_MAX; $pb = $b->getPriority() ?? PHP_INT_MAX;
@@ -322,17 +322,17 @@ class Initiative extends FormEntity implements DateRangeInterface
/** /**
* The audience links sorted by position, as a new collection; see getObjectives(). * The audience links sorted by position, as a new collection; see getObjectives().
* *
* @return Collection<int, InitiativeAudience> * @return Collection<int, ProgramAudience>
*/ */
public function getAudiences(): Collection public function getAudiences(): Collection
{ {
return self::sortedByPosition($this->audiences); return self::sortedByPosition($this->audiences);
} }
public function addAudience(InitiativeAudience $audience): static public function addAudience(ProgramAudience $audience): static
{ {
if (!$this->audiences->contains($audience)) { if (!$this->audiences->contains($audience)) {
$audience->setInitiative($this); $audience->setProgram($this);
$this->audiences->add($audience); $this->audiences->add($audience);
} }
@@ -343,7 +343,7 @@ class Initiative extends FormEntity implements DateRangeInterface
* Removing an audience link from the plan deletes it (orphanRemoval). The audience itself stays * Removing an audience link from the plan deletes it (orphanRemoval). The audience itself stays
* in the global directory. * in the global directory.
*/ */
public function removeAudience(InitiativeAudience $audience): static public function removeAudience(ProgramAudience $audience): static
{ {
$this->audiences->removeElement($audience); $this->audiences->removeElement($audience);
@@ -353,17 +353,17 @@ class Initiative extends FormEntity implements DateRangeInterface
/** /**
* The stakeholder links sorted by position, as a new collection; see getObjectives(). * The stakeholder links sorted by position, as a new collection; see getObjectives().
* *
* @return Collection<int, InitiativeStakeholder> * @return Collection<int, ProgramStakeholder>
*/ */
public function getStakeholders(): Collection public function getStakeholders(): Collection
{ {
return self::sortedByPosition($this->stakeholders); return self::sortedByPosition($this->stakeholders);
} }
public function addStakeholder(InitiativeStakeholder $stakeholder): static public function addStakeholder(ProgramStakeholder $stakeholder): static
{ {
if (!$this->stakeholders->contains($stakeholder)) { if (!$this->stakeholders->contains($stakeholder)) {
$stakeholder->setInitiative($this); $stakeholder->setProgram($this);
$this->stakeholders->add($stakeholder); $this->stakeholders->add($stakeholder);
} }
@@ -374,17 +374,17 @@ class Initiative extends FormEntity implements DateRangeInterface
* Removing a stakeholder link from the plan deletes it (orphanRemoval). The stakeholder itself * Removing a stakeholder link from the plan deletes it (orphanRemoval). The stakeholder itself
* stays in the global directory. * stays in the global directory.
*/ */
public function removeStakeholder(InitiativeStakeholder $stakeholder): static public function removeStakeholder(ProgramStakeholder $stakeholder): static
{ {
$this->stakeholders->removeElement($stakeholder); $this->stakeholders->removeElement($stakeholder);
return $this; return $this;
} }
public function addObjective(InitiativeObjective $objective): static public function addObjective(ProgramObjective $objective): static
{ {
if (!$this->objectives->contains($objective)) { if (!$this->objectives->contains($objective)) {
$objective->setInitiative($this); $objective->setProgram($this);
$this->objectives->add($objective); $this->objectives->add($objective);
} }
@@ -394,7 +394,7 @@ class Initiative extends FormEntity implements DateRangeInterface
/** /**
* Removing an objective from the plan deletes it (orphanRemoval). * Removing an objective from the plan deletes it (orphanRemoval).
*/ */
public function removeObjective(InitiativeObjective $objective): static public function removeObjective(ProgramObjective $objective): static
{ {
$this->objectives->removeElement($objective); $this->objectives->removeElement($objective);
@@ -404,7 +404,7 @@ class Initiative extends FormEntity implements DateRangeInterface
/** /**
* The description items sorted by position, as a new collection; see getObjectives(). * The description items sorted by position, as a new collection; see getObjectives().
* *
* @return Collection<int, InitiativeDescriptionItem> * @return Collection<int, ProgramDescriptionItem>
*/ */
public function getDescriptionItems(): Collection public function getDescriptionItems(): Collection
{ {
@@ -414,17 +414,17 @@ class Initiative extends FormEntity implements DateRangeInterface
/** /**
* The allocation items sorted by position, as a new collection; see getObjectives(). * The allocation items sorted by position, as a new collection; see getObjectives().
* *
* @return Collection<int, InitiativeAllocationItem> * @return Collection<int, ProgramAllocationItem>
*/ */
public function getAllocationItems(): Collection public function getAllocationItems(): Collection
{ {
return self::sortedByPosition($this->allocationItems); return self::sortedByPosition($this->allocationItems);
} }
public function addAllocationItem(InitiativeAllocationItem $allocationItem): static public function addAllocationItem(ProgramAllocationItem $allocationItem): static
{ {
if (!$this->allocationItems->contains($allocationItem)) { if (!$this->allocationItems->contains($allocationItem)) {
$allocationItem->setInitiative($this); $allocationItem->setProgram($this);
$this->allocationItems->add($allocationItem); $this->allocationItems->add($allocationItem);
} }
@@ -434,7 +434,7 @@ class Initiative extends FormEntity implements DateRangeInterface
/** /**
* Removing an allocation item from the plan deletes it (orphanRemoval). * Removing an allocation item from the plan deletes it (orphanRemoval).
*/ */
public function removeAllocationItem(InitiativeAllocationItem $allocationItem): static public function removeAllocationItem(ProgramAllocationItem $allocationItem): static
{ {
$this->allocationItems->removeElement($allocationItem); $this->allocationItems->removeElement($allocationItem);
@@ -468,7 +468,7 @@ class Initiative extends FormEntity implements DateRangeInterface
} }
/** /**
* @template T of InitiativeObjective|InitiativeDescriptionItem|InitiativeAllocationItem|Audience|InitiativeStakeholder * @template T of ProgramObjective|ProgramDescriptionItem|ProgramAllocationItem|Audience|ProgramStakeholder
* *
* @param Collection<int, T> $collection * @param Collection<int, T> $collection
* *
@@ -482,10 +482,10 @@ class Initiative extends FormEntity implements DateRangeInterface
return new ArrayCollection($rows); return new ArrayCollection($rows);
} }
public function addDescriptionItem(InitiativeDescriptionItem $descriptionItem): static public function addDescriptionItem(ProgramDescriptionItem $descriptionItem): static
{ {
if (!$this->descriptionItems->contains($descriptionItem)) { if (!$this->descriptionItems->contains($descriptionItem)) {
$descriptionItem->setInitiative($this); $descriptionItem->setProgram($this);
$this->descriptionItems->add($descriptionItem); $this->descriptionItems->add($descriptionItem);
} }
@@ -495,7 +495,7 @@ class Initiative extends FormEntity implements DateRangeInterface
/** /**
* Removing a description item from the plan deletes it (orphanRemoval). * Removing a description item from the plan deletes it (orphanRemoval).
*/ */
public function removeDescriptionItem(InitiativeDescriptionItem $descriptionItem): static public function removeDescriptionItem(ProgramDescriptionItem $descriptionItem): static
{ {
$this->descriptionItems->removeElement($descriptionItem); $this->descriptionItems->removeElement($descriptionItem);
@@ -531,7 +531,7 @@ class Initiative extends FormEntity implements DateRangeInterface
return $this; return $this;
} }
public function getStatus(): InitiativeStatus public function getStatus(): ProgramStatus
{ {
return $this->status; return $this->status;
} }
@@ -540,7 +540,7 @@ class Initiative extends FormEntity implements DateRangeInterface
* Sets completedAt when the plan moves to "completed" from another status, * Sets completedAt when the plan moves to "completed" from another status,
* and clears it when the plan leaves "completed". * and clears it when the plan leaves "completed".
*/ */
public function setStatus(InitiativeStatus $status): static public function setStatus(ProgramStatus $status): static
{ {
if ($status === $this->status) { if ($status === $this->status) {
return $this; return $this;
@@ -549,9 +549,9 @@ class Initiative extends FormEntity implements DateRangeInterface
// isChanged() can't log enums (they aren't stringable), so log the backing values. // isChanged() can't log enums (they aren't stringable), so log the backing values.
$this->addChange('status', [$this->status->value, $status->value]); $this->addChange('status', [$this->status->value, $status->value]);
if (InitiativeStatus::Completed === $status) { if (ProgramStatus::Completed === $status) {
$this->setCompletedAt(new \DateTime()); $this->setCompletedAt(new \DateTime());
} elseif (InitiativeStatus::Completed === $this->status) { } elseif (ProgramStatus::Completed === $this->status) {
$this->setCompletedAt(null); $this->setCompletedAt(null);
} }
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
@@ -13,21 +13,21 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
/** /**
* One item of a plan's Allocations tab: a typed cost line with a planned and a real cost, both in * One item of a plan's Allocations tab: a typed cost line with a planned and a real cost, both in
* the general currency (CurrencyProvider). Initiative::$allocationItems owns the lifecycle: items are saved * the general currency (CurrencyProvider). Program::$allocationItems owns the lifecycle: items are saved
* and deleted with their plan, and are ordered by position. * and deleted with their plan, and are ordered by position.
* *
* The type is the key of an allocation item type set up in Settings > Configuration > Initiative Settings * The type is the key of an allocation item type set up in Settings > Configuration > Program Settings
* (parameter program_allocation_item_types); see ItemTypeProvider. * (parameter program_allocation_item_types); see ItemTypeProvider.
*/ */
class InitiativeAllocationItem class ProgramAllocationItem
{ {
public const TABLE_NAME = 'initiative_allocation_items'; public const TABLE_NAME = 'mt3s_mp_program_allocation_items';
public const TYPE_MAX_LENGTH = 64; public const TYPE_MAX_LENGTH = 64;
private ?int $id = null; private ?int $id = null;
private ?Initiative $initiative = null; private ?Program $program = null;
private ?string $type = null; private ?string $type = null;
@@ -50,7 +50,7 @@ class InitiativeAllocationItem
public function __clone() public function __clone()
{ {
$this->id = null; $this->id = null;
$this->initiative = null; $this->program = null;
} }
public static function loadMetadata(OrmClassMetadata $metadata): void public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -58,13 +58,13 @@ class InitiativeAllocationItem
$builder = new ClassMetadataBuilder($metadata); $builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME) $builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(InitiativeAllocationItemRepository::class); ->setCustomRepositoryClass(ProgramAllocationItemRepository::class);
$builder->addId(); $builder->addId();
$builder->createManyToOne('initiative', Initiative::class) $builder->createManyToOne('program', Program::class)
->inversedBy('allocationItems') ->inversedBy('allocationItems')
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE') ->addJoinColumn('program_id', 'id', false, false, 'CASCADE')
->build(); ->build();
$builder->createField('type', Types::STRING) $builder->createField('type', Types::STRING)
@@ -96,7 +96,7 @@ class InitiativeAllocationItem
public static function loadValidatorMetadata(ClassMetadata $metadata): void public static function loadValidatorMetadata(ClassMetadata $metadata): void
{ {
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.program.allocation_item.type.required')); $metadata->addPropertyConstraint('type', new NotBlank(message: 'mt3s.marketing_program.allocation_item.type.required'));
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH)); $metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
$metadata->addPropertyConstraint('name', new Length(max: 255)); $metadata->addPropertyConstraint('name', new Length(max: 255));
} }
@@ -106,14 +106,14 @@ class InitiativeAllocationItem
return $this->id; return $this->id;
} }
public function getInitiative(): ?Initiative public function getProgram(): ?Program
{ {
return $this->initiative; return $this->program;
} }
public function setInitiative(?Initiative $initiative): static public function setProgram(?Program $program): static
{ {
$this->initiative = $initiative; $this->program = $program;
return $this; return $this;
} }
@@ -2,14 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Entity\CommonRepository;
/** /**
* @extends CommonRepository<InitiativeAllocationItem> * @extends CommonRepository<ProgramAllocationItem>
*/ */
class InitiativeAllocationItemRepository extends CommonRepository class ProgramAllocationItemRepository extends CommonRepository
{ {
use CountsItemsByTypeTrait; use CountsItemsByTypeTrait;
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
@@ -13,19 +13,19 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
/** /**
* The link between a plan and an audience of the global directory, with the audience's priority * The link between a plan and an audience of the global directory, with the audience's priority
* in that plan and possibly a initiative-specific message ("Key message for this plan"): the same * in that plan and possibly a program-specific message ("Key message for this plan"): the same
* audience can be primary in one plan and secondary in another. * audience can be primary in one plan and secondary in another.
* *
* Initiative::$audiences owns the lifecycle: links are saved and deleted with their plan. Deleting an * Program::$audiences owns the lifecycle: links are saved and deleted with their plan. Deleting an
* audience deletes its links (ON DELETE CASCADE on both sides). * audience deletes its links (ON DELETE CASCADE on both sides).
*/ */
class InitiativeAudience class ProgramAudience
{ {
public const TABLE_NAME = 'initiative_audiences_initiative'; public const TABLE_NAME = 'mt3s_mp_program_audiences_program';
private ?int $id = null; private ?int $id = null;
private ?Initiative $initiative = null; private ?Program $program = null;
private ?Audience $audience = null; private ?Audience $audience = null;
@@ -44,7 +44,7 @@ class InitiativeAudience
public function __clone() public function __clone()
{ {
$this->id = null; $this->id = null;
$this->initiative = null; $this->program = null;
} }
public static function loadMetadata(OrmClassMetadata $metadata): void public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -52,13 +52,13 @@ class InitiativeAudience
$builder = new ClassMetadataBuilder($metadata); $builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME) $builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(InitiativeAudienceRepository::class); ->setCustomRepositoryClass(ProgramAudienceRepository::class);
$builder->addId(); $builder->addId();
$builder->createManyToOne('initiative', Initiative::class) $builder->createManyToOne('program', Program::class)
->inversedBy('audiences') ->inversedBy('audiences')
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE') ->addJoinColumn('program_id', 'id', false, false, 'CASCADE')
->build(); ->build();
$builder->createManyToOne('audience', Audience::class) $builder->createManyToOne('audience', Audience::class)
@@ -86,7 +86,7 @@ class InitiativeAudience
public static function loadValidatorMetadata(ClassMetadata $metadata): void public static function loadValidatorMetadata(ClassMetadata $metadata): void
{ {
$metadata->addPropertyConstraint('audience', new NotBlank(message: 'mautic.program.audience_link.audience.required')); $metadata->addPropertyConstraint('audience', new NotBlank(message: 'mt3s.marketing_program.audience_link.audience.required'));
$metadata->addPropertyConstraint('valueProposition', new Length(max: 1000)); $metadata->addPropertyConstraint('valueProposition', new Length(max: 1000));
} }
@@ -95,14 +95,14 @@ class InitiativeAudience
return $this->id; return $this->id;
} }
public function getInitiative(): ?Initiative public function getProgram(): ?Program
{ {
return $this->initiative; return $this->program;
} }
public function setInitiative(?Initiative $initiative): static public function setProgram(?Program $program): static
{ {
$this->initiative = $initiative; $this->program = $program;
return $this; return $this;
} }
@@ -2,14 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Entity\CommonRepository;
/** /**
* @extends CommonRepository<InitiativeAudience> * @extends CommonRepository<ProgramAudience>
*/ */
class InitiativeAudienceRepository extends CommonRepository class ProgramAudienceRepository extends CommonRepository
{ {
public function getTableAlias(): string public function getTableAlias(): string
{ {
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
@@ -12,21 +12,21 @@ use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\ClassMetadata;
/** /**
* One item of a plan's Description tab. Initiative::$descriptionItems owns the lifecycle: items are saved and * One item of a plan's Description tab. Program::$descriptionItems owns the lifecycle: items are saved and
* deleted with their plan, and are ordered by position. * deleted with their plan, and are ordered by position.
* *
* The type is the key of a type set up in Settings > Configuration > Initiative (parameter * The type is the key of a type set up in Settings > Configuration > Program (parameter
* program_description_item_types); see ItemTypeProvider (kind "description") for its name and description. * program_description_item_types); see ItemTypeProvider (kind "description") for its name and description.
*/ */
class InitiativeDescriptionItem class ProgramDescriptionItem
{ {
public const TABLE_NAME = 'initiative_description_items'; public const TABLE_NAME = 'mt3s_mp_program_description_items';
public const TYPE_MAX_LENGTH = 64; public const TYPE_MAX_LENGTH = 64;
private ?int $id = null; private ?int $id = null;
private ?Initiative $initiative = null; private ?Program $program = null;
private ?string $type = null; private ?string $type = null;
@@ -40,7 +40,7 @@ class InitiativeDescriptionItem
public function __clone() public function __clone()
{ {
$this->id = null; $this->id = null;
$this->initiative = null; $this->program = null;
} }
public static function loadMetadata(OrmClassMetadata $metadata): void public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -48,13 +48,13 @@ class InitiativeDescriptionItem
$builder = new ClassMetadataBuilder($metadata); $builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME) $builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(InitiativeDescriptionItemRepository::class); ->setCustomRepositoryClass(ProgramDescriptionItemRepository::class);
$builder->addId(); $builder->addId();
$builder->createManyToOne('initiative', Initiative::class) $builder->createManyToOne('program', Program::class)
->inversedBy('descriptionItems') ->inversedBy('descriptionItems')
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE') ->addJoinColumn('program_id', 'id', false, false, 'CASCADE')
->build(); ->build();
$builder->createField('type', Types::STRING) $builder->createField('type', Types::STRING)
@@ -72,7 +72,7 @@ class InitiativeDescriptionItem
public static function loadValidatorMetadata(ClassMetadata $metadata): void public static function loadValidatorMetadata(ClassMetadata $metadata): void
{ {
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.program.description_item.type.required')); $metadata->addPropertyConstraint('type', new NotBlank(message: 'mt3s.marketing_program.description_item.type.required'));
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH)); $metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
} }
@@ -81,14 +81,14 @@ class InitiativeDescriptionItem
return $this->id; return $this->id;
} }
public function getInitiative(): ?Initiative public function getProgram(): ?Program
{ {
return $this->initiative; return $this->program;
} }
public function setInitiative(?Initiative $initiative): static public function setProgram(?Program $program): static
{ {
$this->initiative = $initiative; $this->program = $program;
return $this; return $this;
} }
@@ -2,14 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Entity\CommonRepository;
/** /**
* @extends CommonRepository<InitiativeDescriptionItem> * @extends CommonRepository<ProgramDescriptionItem>
*/ */
class InitiativeDescriptionItemRepository extends CommonRepository class ProgramDescriptionItemRepository extends CommonRepository
{ {
use CountsItemsByTypeTrait; use CountsItemsByTypeTrait;
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
@@ -14,12 +14,12 @@ use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\ClassMetadata;
/** /**
* An objective of a plan. Initiative::$objectives owns the lifecycle: objectives are saved and deleted with * An objective of a plan. Program::$objectives owns the lifecycle: objectives are saved and deleted with
* their plan, and are ordered by position. * their plan, and are ordered by position.
*/ */
class InitiativeObjective class ProgramObjective
{ {
public const TABLE_NAME = 'initiative_objectives'; public const TABLE_NAME = 'mt3s_mp_program_objectives';
public const TYPE_MAX_LENGTH = 64; public const TYPE_MAX_LENGTH = 64;
@@ -28,7 +28,7 @@ class InitiativeObjective
private ?int $id = null; private ?int $id = null;
private ?Initiative $initiative = null; private ?Program $program = null;
private ?string $type = null; private ?string $type = null;
@@ -54,7 +54,7 @@ class InitiativeObjective
public function __clone() public function __clone()
{ {
$this->id = null; $this->id = null;
$this->initiative = null; $this->program = null;
} }
public static function loadMetadata(OrmClassMetadata $metadata): void public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -62,13 +62,13 @@ class InitiativeObjective
$builder = new ClassMetadataBuilder($metadata); $builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME) $builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(InitiativeObjectiveRepository::class); ->setCustomRepositoryClass(ProgramObjectiveRepository::class);
$builder->addId(); $builder->addId();
$builder->createManyToOne('initiative', Initiative::class) $builder->createManyToOne('program', Program::class)
->inversedBy('objectives') ->inversedBy('objectives')
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE') ->addJoinColumn('program_id', 'id', false, false, 'CASCADE')
->build(); ->build();
$builder->createField('type', Types::STRING) $builder->createField('type', Types::STRING)
@@ -100,13 +100,13 @@ class InitiativeObjective
public static function loadValidatorMetadata(ClassMetadata $metadata): void public static function loadValidatorMetadata(ClassMetadata $metadata): void
{ {
$metadata->addPropertyConstraint('title', new NotBlank(message: 'mautic.program.objective.title.required')); $metadata->addPropertyConstraint('title', new NotBlank(message: 'mt3s.marketing_program.objective.title.required'));
$metadata->addPropertyConstraint('title', new Length(max: 255)); $metadata->addPropertyConstraint('title', new Length(max: 255));
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.program.objective.type.required')); $metadata->addPropertyConstraint('type', new NotBlank(message: 'mt3s.marketing_program.objective.type.required'));
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH)); $metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
$metadata->addPropertyConstraint('priority', new NotNull(message: 'mautic.program.objective.priority.range')); $metadata->addPropertyConstraint('priority', new NotNull(message: 'mt3s.marketing_program.objective.priority.range'));
$metadata->addPropertyConstraint('priority', new Range( $metadata->addPropertyConstraint('priority', new Range(
notInRangeMessage: 'mautic.program.objective.priority.range', notInRangeMessage: 'mt3s.marketing_program.objective.priority.range',
min: self::PRIORITY_MIN, min: self::PRIORITY_MIN,
max: self::PRIORITY_MAX, max: self::PRIORITY_MAX,
)); ));
@@ -117,14 +117,14 @@ class InitiativeObjective
return $this->id; return $this->id;
} }
public function getInitiative(): ?Initiative public function getProgram(): ?Program
{ {
return $this->initiative; return $this->program;
} }
public function setInitiative(?Initiative $initiative): static public function setProgram(?Program $program): static
{ {
$this->initiative = $initiative; $this->program = $program;
return $this; return $this;
} }
@@ -2,14 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Entity\CommonRepository;
/** /**
* @extends CommonRepository<InitiativeObjective> * @extends CommonRepository<ProgramObjective>
*/ */
class InitiativeObjectiveRepository extends CommonRepository class ProgramObjectiveRepository extends CommonRepository
{ {
use CountsItemsByTypeTrait; use CountsItemsByTypeTrait;
@@ -2,14 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Entity\CommonRepository;
/** /**
* @extends CommonRepository<Initiative> * @extends CommonRepository<Program>
*/ */
class InitiativeRepository extends CommonRepository class ProgramRepository extends CommonRepository
{ {
public function getTableAlias(): string public function getTableAlias(): string
{ {
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
@@ -15,23 +15,23 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
* that plan ("Approves budget", "Media buyer"): free text, because the same person can have a * that plan ("Approves budget", "Media buyer"): free text, because the same person can have a
* different role on each plan. * different role on each plan.
* *
* Initiative::$stakeholders owns the lifecycle: links are saved and deleted with their plan. Deleting a * Program::$stakeholders owns the lifecycle: links are saved and deleted with their plan. Deleting a
* stakeholder deletes its links (ON DELETE CASCADE on both sides). * stakeholder deletes its links (ON DELETE CASCADE on both sides).
*/ */
class InitiativeStakeholder class ProgramStakeholder
{ {
public const TABLE_NAME = 'initiative_stakeholders_initiative'; public const TABLE_NAME = 'mt3s_mp_program_stakeholders_program';
private ?int $id = null; private ?int $id = null;
private ?Initiative $initiative = null; private ?Program $program = null;
private ?Stakeholder $stakeholder = null; private ?Stakeholder $stakeholder = null;
/** /**
* The stakeholder's role in this plan, free text. * The stakeholder's role in this plan, free text.
*/ */
private ?string $roleInInitiative = null; private ?string $roleInProgram = null;
/** /**
* Display order within the plan, from 0. Set by drag and drop in the form. * Display order within the plan, from 0. Set by drag and drop in the form.
@@ -41,7 +41,7 @@ class InitiativeStakeholder
public function __clone() public function __clone()
{ {
$this->id = null; $this->id = null;
$this->initiative = null; $this->program = null;
} }
public static function loadMetadata(OrmClassMetadata $metadata): void public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -49,21 +49,21 @@ class InitiativeStakeholder
$builder = new ClassMetadataBuilder($metadata); $builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME) $builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(InitiativeStakeholderRepository::class); ->setCustomRepositoryClass(ProgramStakeholderRepository::class);
$builder->addId(); $builder->addId();
$builder->createManyToOne('initiative', Initiative::class) $builder->createManyToOne('program', Program::class)
->inversedBy('stakeholders') ->inversedBy('stakeholders')
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE') ->addJoinColumn('program_id', 'id', false, false, 'CASCADE')
->build(); ->build();
$builder->createManyToOne('stakeholder', Stakeholder::class) $builder->createManyToOne('stakeholder', Stakeholder::class)
->addJoinColumn('stakeholder_id', 'id', false, false, 'CASCADE') ->addJoinColumn('stakeholder_id', 'id', false, false, 'CASCADE')
->build(); ->build();
$builder->createField('roleInInitiative', Types::STRING) $builder->createField('roleInProgram', Types::STRING)
->columnName('role_in_initiative') ->columnName('role_in_program')
->length(191) ->length(191)
->nullable() ->nullable()
->build(); ->build();
@@ -75,8 +75,8 @@ class InitiativeStakeholder
public static function loadValidatorMetadata(ClassMetadata $metadata): void public static function loadValidatorMetadata(ClassMetadata $metadata): void
{ {
$metadata->addPropertyConstraint('stakeholder', new \Symfony\Component\Validator\Constraints\NotBlank(message: 'mautic.program.stakeholder_link.stakeholder.required')); $metadata->addPropertyConstraint('stakeholder', new \Symfony\Component\Validator\Constraints\NotBlank(message: 'mt3s.marketing_program.stakeholder_link.stakeholder.required'));
$metadata->addPropertyConstraint('roleInInitiative', new Length(max: 191)); $metadata->addPropertyConstraint('roleInProgram', new Length(max: 191));
} }
public function getId(): ?int public function getId(): ?int
@@ -84,14 +84,14 @@ class InitiativeStakeholder
return $this->id; return $this->id;
} }
public function getInitiative(): ?Initiative public function getProgram(): ?Program
{ {
return $this->initiative; return $this->program;
} }
public function setInitiative(?Initiative $initiative): static public function setProgram(?Program $program): static
{ {
$this->initiative = $initiative; $this->program = $program;
return $this; return $this;
} }
@@ -108,14 +108,14 @@ class InitiativeStakeholder
return $this; return $this;
} }
public function getRoleInInitiative(): ?string public function getRoleInProgram(): ?string
{ {
return $this->roleInInitiative; return $this->roleInProgram;
} }
public function setRoleInInitiative(?string $roleInInitiative): static public function setRoleInProgram(?string $roleInProgram): static
{ {
$this->roleInInitiative = $roleInInitiative; $this->roleInProgram = $roleInProgram;
return $this; return $this;
} }
@@ -2,14 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Entity\CommonRepository;
/** /**
* @extends CommonRepository<InitiativeStakeholder> * @extends CommonRepository<ProgramStakeholder>
*/ */
class InitiativeStakeholderRepository extends CommonRepository class ProgramStakeholderRepository extends CommonRepository
{ {
public function getTableAlias(): string public function getTableAlias(): string
{ {
@@ -2,9 +2,9 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
enum InitiativeStatus: string enum ProgramStatus: string
{ {
case Draft = 'draft'; case Draft = 'draft';
case Planned = 'planned'; case Planned = 'planned';
@@ -15,11 +15,11 @@ enum InitiativeStatus: string
public function getLabelKey(): string public function getLabelKey(): string
{ {
return 'mautic.program.status.'.$this->value; return 'mt3s.marketing_program.status.'.$this->value;
} }
/** /**
* The Bootstrap class of the status label in the tables (the initiative's Status column). * The Bootstrap class of the status label in the tables (the program's Status column).
*/ */
public function getLabelClass(): string public function getLabelClass(): string
{ {
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
/** /**
* The RACI roles of a task assignment. The order of the cases is the order of the dropdown. * The RACI roles of a task assignment. The order of the cases is the order of the dropdown.
@@ -16,7 +16,7 @@ enum RaciRole: string
public function getLabelKey(): string public function getLabelKey(): string
{ {
return 'mautic.program.task.raci_role.'.$this->value; return 'mt3s.marketing_program.task.raci_role.'.$this->value;
} }
public function getLabelClass(): string public function getLabelClass(): string
+19 -19
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@@ -16,20 +16,20 @@ use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\ClassMetadata;
/** /**
* A stakeholder of the program: a person, a company or a team involved in the initiatives ("Agency XYZ", * A stakeholder of the program: a person, a company or a team involved in the mt3s_mp_programs ("Agency XYZ",
* "Exec committee"). Stakeholders are a global directory (Programs > Stakeholders), independent of * "Exec committee"). Stakeholders are a global directory (Programs > Stakeholders), independent of
* initiatives; an initiative links to them through InitiativeStakeholder, which carries the stakeholder's role in that * mt3s_mp_programs; an program links to them through ProgramStakeholder, which carries the stakeholder's role in that
* initiative. * program.
* *
* The type is the key of a stakeholder type set up in Settings > Configuration > Initiative Settings * The type is the key of a stakeholder type set up in Settings > Configuration > Program Settings
* (parameter program_stakeholder_types); see ItemTypeProvider (kind "stakeholder"). * (parameter program_stakeholder_types); see ItemTypeProvider (kind "stakeholder").
* *
* isPublished (from FormEntity) means "active": an unpublished stakeholder is hidden from the initiative * isPublished (from FormEntity) means "active": an unpublished stakeholder is hidden from the program
* form's stakeholder picker, but keeps its history on the initiatives it is already linked to. * form's stakeholder picker, but keeps its history on the mt3s_mp_programs it is already linked to.
*/ */
class Stakeholder extends FormEntity class Stakeholder extends FormEntity
{ {
public const TABLE_NAME = 'initiative_stakeholders'; public const TABLE_NAME = 'mt3s_mp_program_stakeholders';
public const TYPE_MAX_LENGTH = 64; public const TYPE_MAX_LENGTH = 64;
@@ -50,16 +50,16 @@ class Stakeholder extends FormEntity
private ?string $type = null; private ?string $type = null;
/** /**
* The links to the initiatives this stakeholder is assigned to. Inverse side, read-only from here: the * The links to the mt3s_mp_programs this stakeholder is assigned to. Inverse side, read-only from here: the
* links are managed from the plans (Initiative::addStakeholder/removeStakeholder). * links are managed from the plans (Program::addStakeholder/removeStakeholder).
* *
* @var Collection<int, InitiativeStakeholder> * @var Collection<int, ProgramStakeholder>
*/ */
private Collection $initiativeLinks; private Collection $programLinks;
public function __construct() public function __construct()
{ {
$this->initiativeLinks = new ArrayCollection(); $this->programLinks = new ArrayCollection();
} }
public static function loadMetadata(OrmClassMetadata $metadata): void public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -96,7 +96,7 @@ class Stakeholder extends FormEntity
->nullable() ->nullable()
->build(); ->build();
$builder->createOneToMany('initiativeLinks', InitiativeStakeholder::class) $builder->createOneToMany('programLinks', ProgramStakeholder::class)
->mappedBy('stakeholder') ->mappedBy('stakeholder')
->fetchExtraLazy() ->fetchExtraLazy()
->build(); ->build();
@@ -108,7 +108,7 @@ class Stakeholder extends FormEntity
{ {
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required')); $metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required'));
$metadata->addPropertyConstraint('name', new Length(max: 191)); $metadata->addPropertyConstraint('name', new Length(max: 191));
$metadata->addPropertyConstraint('email', new Email(mode: Email::VALIDATION_MODE_HTML5, message: 'mautic.program.stakeholder.email.invalid')); $metadata->addPropertyConstraint('email', new Email(mode: Email::VALIDATION_MODE_HTML5, message: 'mt3s.marketing_program.stakeholder.email.invalid'));
$metadata->addPropertyConstraint('email', new Length(max: 191)); $metadata->addPropertyConstraint('email', new Length(max: 191));
$metadata->addPropertyConstraint('phone', new Length(max: 50)); $metadata->addPropertyConstraint('phone', new Length(max: 50));
$metadata->addPropertyConstraint('role', new Length(max: 191)); $metadata->addPropertyConstraint('role', new Length(max: 191));
@@ -178,13 +178,13 @@ class Stakeholder extends FormEntity
} }
/** /**
* The links to the initiatives this stakeholder is assigned to, each with its role in that initiative. * The links to the mt3s_mp_programs this stakeholder is assigned to, each with its role in that program.
* *
* @return Collection<int, InitiativeStakeholder> * @return Collection<int, ProgramStakeholder>
*/ */
public function getInitiativeLinks(): Collection public function getProgramLinks(): Collection
{ {
return $this->initiativeLinks; return $this->programLinks;
} }
public function setType(?string $type): static public function setType(?string $type): static
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Entity\CommonRepository;
+20 -20
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@@ -10,9 +10,9 @@ 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;
use Mautic\CoreBundle\Entity\FormEntity; use Mautic\CoreBundle\Entity\FormEntity;
use MauticPlugin\ProgramBundle\Validator\Constraints\EndDateAfterStartDate; use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\EndDateAfterStartDate;
use MauticPlugin\ProgramBundle\Validator\Constraints\TaskDates; use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\TaskDates;
use MauticPlugin\ProgramBundle\Validator\Constraints\ValidTaskDependency; use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\ValidTaskDependency;
use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\PositiveOrZero; use Symfony\Component\Validator\Constraints\PositiveOrZero;
@@ -20,7 +20,7 @@ use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\ClassMetadata;
/** /**
* A task of an initiative. Every task belongs to exactly one initiative. * A task of an program. Every task belongs to exactly one program.
* *
* Kinds (taskKind): a regular task; a milestone, whose end date is enslaved to its start date; or a * Kinds (taskKind): a regular task; a milestone, whose end date is enslaved to its start date; or a
* phase, which has no status of its own — it is a collection of tasks. * phase, which has no status of its own — it is a collection of tasks.
@@ -29,15 +29,15 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
* End2End, Start2Start or Start2End. The former parent/child tree is replaced by this dependency * End2End, Start2Start or Start2End. The former parent/child tree is replaced by this dependency
* graph. * graph.
* *
* RACI: a task is assigned to the initiative's stakeholders through TaskRaci rows (R/A/C/I), several * RACI: a task is assigned to the program's stakeholders through TaskRaci rows (R/A/C/I), several
* stakeholders per role. * stakeholders per role.
* *
* Database rules: deleting the initiative deletes its tasks (ON DELETE CASCADE); deleting a task deletes * Database rules: deleting the program deletes its tasks (ON DELETE CASCADE); deleting a task deletes
* its dependencies and RACI rows (ON DELETE CASCADE). * its dependencies and RACI rows (ON DELETE CASCADE).
*/ */
class Task extends FormEntity implements DateRangeInterface class Task extends FormEntity implements DateRangeInterface
{ {
public const TABLE_NAME = 'initiative_tasks'; public const TABLE_NAME = 'mt3s_mp_program_tasks';
public const TYPE_MAX_LENGTH = 64; public const TYPE_MAX_LENGTH = 64;
@@ -48,7 +48,7 @@ class Task extends FormEntity implements DateRangeInterface
private ?int $id = null; private ?int $id = null;
private ?Initiative $initiative = null; private ?Program $program = null;
/** /**
* Key of a task type set up in Settings > Configuration > Program Settings (parameter program_task_types); * Key of a task type set up in Settings > Configuration > Program Settings (parameter program_task_types);
@@ -106,9 +106,9 @@ class Task extends FormEntity implements DateRangeInterface
$builder->addId(); $builder->addId();
$builder->createManyToOne('initiative', Initiative::class) $builder->createManyToOne('program', Program::class)
->inversedBy('tasks') ->inversedBy('tasks')
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE') ->addJoinColumn('program_id', 'id', false, false, 'CASCADE')
->build(); ->build();
$builder->createField('type', Types::STRING) $builder->createField('type', Types::STRING)
@@ -191,11 +191,11 @@ class Task extends FormEntity implements DateRangeInterface
{ {
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required')); $metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required'));
$metadata->addPropertyConstraint('name', new Length(max: 255)); $metadata->addPropertyConstraint('name', new Length(max: 255));
$metadata->addPropertyConstraint('initiative', new NotBlank(message: 'mautic.program.task.initiative.required')); $metadata->addPropertyConstraint('program', new NotBlank(message: 'mt3s.marketing_program.task.program.required'));
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.program.task.type.required')); $metadata->addPropertyConstraint('type', new NotBlank(message: 'mt3s.marketing_program.task.type.required'));
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH)); $metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
$metadata->addPropertyConstraint('plannedWork', new PositiveOrZero(message: 'mautic.program.task.planned_work.invalid')); $metadata->addPropertyConstraint('plannedWork', new PositiveOrZero(message: 'mt3s.marketing_program.task.planned_work.invalid'));
$metadata->addPropertyConstraint('plannedWork', new Range(notInRangeMessage: 'mautic.program.task.planned_work.range', min: 0, max: self::PLANNED_WORK_MAX)); $metadata->addPropertyConstraint('plannedWork', new Range(notInRangeMessage: 'mt3s.marketing_program.task.planned_work.range', min: 0, max: self::PLANNED_WORK_MAX));
$metadata->addConstraint(new EndDateAfterStartDate()); $metadata->addConstraint(new EndDateAfterStartDate());
$metadata->addConstraint(new TaskDates()); $metadata->addConstraint(new TaskDates());
$metadata->addConstraint(new ValidTaskDependency()); $metadata->addConstraint(new ValidTaskDependency());
@@ -206,15 +206,15 @@ class Task extends FormEntity implements DateRangeInterface
return $this->id; return $this->id;
} }
public function getInitiative(): ?Initiative public function getProgram(): ?Program
{ {
return $this->initiative; return $this->program;
} }
public function setInitiative(?Initiative $initiative): static public function setProgram(?Program $program): static
{ {
$this->isChanged('initiative', $initiative); $this->isChanged('program', $program);
$this->initiative = $initiative; $this->program = $program;
return $this; return $this;
} }
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
@@ -17,7 +17,7 @@ use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
*/ */
class TaskDependency class TaskDependency
{ {
public const TABLE_NAME = 'initiative_task_dependencies'; public const TABLE_NAME = 'mt3s_mp_program_task_dependencies';
private ?int $id = null; private ?int $id = null;
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Entity\CommonRepository;
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
/** /**
* The kind of a task. The order of the cases is the order of the dropdown. * The kind of a task. The order of the cases is the order of the dropdown.
@@ -15,7 +15,7 @@ enum TaskKind: string
public function getLabelKey(): string public function getLabelKey(): string
{ {
return 'mautic.program.task.kind.'.$this->value; return 'mt3s.marketing_program.task.kind.'.$this->value;
} }
/** /**
+3 -3
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
@@ -19,12 +19,12 @@ use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
*/ */
class TaskRaci class TaskRaci
{ {
public const TABLE_NAME = 'initiative_task_raci'; public const TABLE_NAME = 'mt3s_mp_program_task_raci';
/** /**
* The join table carrying the stakeholders of a RACI row (TaskRaci -> Stakeholder). * The join table carrying the stakeholders of a RACI row (TaskRaci -> Stakeholder).
*/ */
public const JOIN_TABLE_NAME = 'initiative_task_raci_stakeholders'; public const JOIN_TABLE_NAME = 'mt3s_mp_program_task_raci_stakeholders';
private ?int $id = null; private ?int $id = null;
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Entity\CommonRepository;
+7 -7
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository; use Mautic\CoreBundle\Entity\CommonRepository;
@@ -19,7 +19,7 @@ class TaskRepository extends CommonRepository
} }
/** /**
* Loads the initiative, the dependencies (with their depends-on task) and the RACI rows (with their * Loads the program, the dependencies (with their depends-on task) and the RACI rows (with their
* stakeholders) with the tasks, so that the list doesn't query them one by one. * stakeholders) with the tasks, so that the list doesn't query them one by one.
* *
* @param array<string, mixed> $args * @param array<string, mixed> $args
@@ -30,7 +30,7 @@ class TaskRepository extends CommonRepository
$args['qb'] = $this->createQueryBuilder($alias) $args['qb'] = $this->createQueryBuilder($alias)
->select($alias, 'init', 'dep', 'depTask', 'raci', 'raciStakeholder') ->select($alias, 'init', 'dep', 'depTask', 'raci', 'raciStakeholder')
->leftJoin($alias.'.initiative', 'init') ->leftJoin($alias.'.program', 'init')
->leftJoin($alias.'.dependencies', 'dep') ->leftJoin($alias.'.dependencies', 'dep')
->leftJoin('dep.dependsOn', 'depTask') ->leftJoin('dep.dependsOn', 'depTask')
->leftJoin($alias.'.raci', 'raci') ->leftJoin($alias.'.raci', 'raci')
@@ -40,11 +40,11 @@ class TaskRepository extends CommonRepository
} }
/** /**
* All tasks of an initiative, ordered by name, with their dependencies and RACI rows loaded. * All tasks of an program, ordered by name, with their dependencies and RACI rows loaded.
* *
* @return Task[] * @return Task[]
*/ */
public function findByInitiative(Initiative $initiative): array public function findByProgram(Program $program): array
{ {
return $this->createQueryBuilder('t') return $this->createQueryBuilder('t')
->select('t', 'dep', 'depTask', 'raci', 'raciStakeholder') ->select('t', 'dep', 'depTask', 'raci', 'raciStakeholder')
@@ -52,8 +52,8 @@ class TaskRepository extends CommonRepository
->leftJoin('dep.dependsOn', 'depTask') ->leftJoin('dep.dependsOn', 'depTask')
->leftJoin('t.raci', 'raci') ->leftJoin('t.raci', 'raci')
->leftJoin('raci.stakeholders', 'raciStakeholder') ->leftJoin('raci.stakeholders', 'raciStakeholder')
->where('t.initiative = :initiative') ->where('t.program = :program')
->setParameter('initiative', $initiative) ->setParameter('program', $program)
->orderBy('t.name', 'ASC') ->orderBy('t.name', 'ASC')
->addOrderBy('t.id', 'ASC') ->addOrderBy('t.id', 'ASC')
->getQuery() ->getQuery()
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity; namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
/** /**
* Task status. The order of the cases is the order of the dropdown on the task form. * Task status. The order of the cases is the order of the dropdown on the task form.
@@ -16,7 +16,7 @@ enum TaskStatus: string
public function getLabelKey(): string public function getLabelKey(): string
{ {
return 'mautic.program.task.status.'.$this->value; return 'mt3s.marketing_program.task.status.'.$this->value;
} }
/** /**
+32
View File
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Event;
/**
* The plugin's event names. Dispatched by ProgramModel with a ProgramEvent payload.
*/
final class MT3SMarketingProgramEvents
{
/** Before a program is written to the database. */
public const PROGRAM_PRE_SAVE = 'mt3s.marketing_program.pre_save';
/** After a program was written to the database. */
public const PROGRAM_POST_SAVE = 'mt3s.marketing_program.post_save';
/** After a program was created (a POST_SAVE with a brand-new record). */
public const PROGRAM_CREATED = 'mt3s.marketing_program.created';
/** After an existing program was updated. */
public const PROGRAM_UPDATED = 'mt3s.marketing_program.updated';
/** Before a program (and its children) is removed from the database. */
public const PROGRAM_PRE_DELETE = 'mt3s.marketing_program.pre_delete';
/** After a program was removed from the database. */
public const PROGRAM_POST_DELETE = 'mt3s.marketing_program.post_delete';
/** After a program was removed from the database. */
public const PROGRAM_DELETED = 'mt3s.marketing_program.deleted';
}
+30
View File
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Event;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use Symfony\Contracts\EventDispatcher\Event;
/**
* The payload of the plugin's mt3s.marketing_program.* events (see MT3SMarketingProgramEvents).
*/
final class ProgramEvent extends Event
{
public function __construct(
private readonly Program $program,
private readonly bool $isNew,
) {
}
public function getProgram(): Program
{
return $this->program;
}
public function isNew(): bool
{
return $this->isNew;
}
}
+5 -5
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\EventListener; namespace MauticPlugin\MT3SMarketingProgramBundle\EventListener;
use Mautic\ConfigBundle\ConfigEvents; use Mautic\ConfigBundle\ConfigEvents;
use Mautic\ConfigBundle\Event\ConfigBuilderEvent; use Mautic\ConfigBundle\Event\ConfigBuilderEvent;
use MauticPlugin\ProgramBundle\Form\Type\ConfigType; use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\ConfigType;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/** /**
@@ -27,11 +27,11 @@ class ConfigSubscriber implements EventSubscriberInterface
public function onConfigGenerate(ConfigBuilderEvent $event): void public function onConfigGenerate(ConfigBuilderEvent $event): void
{ {
$event->addForm([ $event->addForm([
'bundle' => 'ProgramBundle', 'bundle' => 'MT3SMarketingProgramBundle',
'formAlias' => ConfigType::FORM_ALIAS, 'formAlias' => ConfigType::FORM_ALIAS,
'formType' => ConfigType::class, 'formType' => ConfigType::class,
'formTheme' => '@Program/FormTheme/Config/_config_programconfig_widget.html.twig', 'formTheme' => '@MT3SMarketingProgram/FormTheme/Config/_config_mt3smarketingprogramconfig_widget.html.twig',
'parameters' => $event->getParametersFromConfig('ProgramBundle'), 'parameters' => $event->getParametersFromConfig('MT3SMarketingProgramBundle'),
]); ]);
} }
} }
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\EventListener; namespace MauticPlugin\MT3SMarketingProgramBundle\EventListener;
use Mautic\PluginBundle\Bundle\PluginDatabase; use Mautic\PluginBundle\Bundle\PluginDatabase;
use Mautic\PluginBundle\Event\PluginInstallEvent; use Mautic\PluginBundle\Event\PluginInstallEvent;
@@ -15,7 +15,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/ */
class PluginInstallSubscriber implements EventSubscriberInterface class PluginInstallSubscriber implements EventSubscriberInterface
{ {
private const BUNDLE = 'ProgramBundle'; private const BUNDLE = 'MT3SMarketingProgramBundle';
public function __construct( public function __construct(
private PluginDatabase $pluginDatabase, private PluginDatabase $pluginDatabase,
+23 -23
View File
@@ -2,17 +2,17 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
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 Mautic\LeadBundle\Entity\LeadList; use Mautic\LeadBundle\Entity\LeadList;
use Mautic\StageBundle\Entity\Stage; use Mautic\StageBundle\Entity\Stage;
use MauticPlugin\ProgramBundle\Entity\Audience; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\AudienceType as AudienceTypeEnum; use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceType as AudienceTypeEnum;
use MauticPlugin\ProgramBundle\Service\AudienceAttributes; use MauticPlugin\MT3SMarketingProgramBundle\Service\AudienceAttributes;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
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;
@@ -26,7 +26,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
/** /**
* The create and edit form of an audience of the global directory (Programs > Audiences): name, a * The create and edit form of an audience of the global directory (Programs > Audiences): name, a
* 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 > Initiative 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> * @extends AbstractType<Audience>
@@ -45,13 +45,13 @@ class AudienceType extends AbstractType
// Name and type are always offered; everything else is a togglable attribute. // Name and type are always offered; everything else is a togglable attribute.
$builder->add('name', TextType::class, [ $builder->add('name', TextType::class, [
'label' => 'mautic.program.audience.field.name', 'label' => 'mt3s.marketing_program.audience.field.name',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191], 'attr' => ['class' => 'form-control', 'maxlength' => 191],
]); ]);
$builder->add('audienceType', EnumType::class, [ $builder->add('audienceType', EnumType::class, [
'label' => 'mautic.program.audience.field.type', 'label' => 'mt3s.marketing_program.audience.field.type',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => AudienceTypeEnum::class, 'class' => AudienceTypeEnum::class,
@@ -59,9 +59,9 @@ class AudienceType extends AbstractType
]); ]);
// The Mautic segments this audience maps to; any number, or none. Purely informational: the // The Mautic segments this audience maps to; any number, or none. Purely informational: the
// segments are not required, and nothing in the initiative depends on them. // segments are not required, and nothing in the program depends on them.
$builder->add('segments', EntityType::class, [ $builder->add('segments', EntityType::class, [
'label' => 'mautic.program.audience.field.segments', 'label' => 'mt3s.marketing_program.audience.field.segments',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => LeadList::class, 'class' => LeadList::class,
@@ -77,7 +77,7 @@ class AudienceType extends AbstractType
if (in_array('tagline', $enabled, true)) { if (in_array('tagline', $enabled, true)) {
$builder->add('tagline', TextareaType::class, [ $builder->add('tagline', TextareaType::class, [
'label' => 'mautic.program.audience.field.tagline', 'label' => 'mt3s.marketing_program.audience.field.tagline',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2, 'maxlength' => 500], 'attr' => ['class' => 'form-control', 'rows' => 2, 'maxlength' => 500],
'required' => false, 'required' => false,
@@ -86,7 +86,7 @@ class AudienceType extends AbstractType
if (in_array('profile', $enabled, true)) { if (in_array('profile', $enabled, true)) {
$builder->add('profileCriteria', TextareaType::class, [ $builder->add('profileCriteria', TextareaType::class, [
'label' => 'mautic.program.audience.field.profile_criteria', 'label' => 'mt3s.marketing_program.audience.field.profile_criteria',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3], 'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false, 'required' => false,
@@ -95,7 +95,7 @@ class AudienceType extends AbstractType
if (in_array('motivations', $enabled, true)) { if (in_array('motivations', $enabled, true)) {
$builder->add('motivations', TextareaType::class, [ $builder->add('motivations', TextareaType::class, [
'label' => 'mautic.program.audience.field.motivations', 'label' => 'mt3s.marketing_program.audience.field.motivations',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3], 'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false, 'required' => false,
@@ -104,7 +104,7 @@ class AudienceType extends AbstractType
if (in_array('barriers', $enabled, true)) { if (in_array('barriers', $enabled, true)) {
$builder->add('barriers', TextareaType::class, [ $builder->add('barriers', TextareaType::class, [
'label' => 'mautic.program.audience.field.barriers', 'label' => 'mt3s.marketing_program.audience.field.barriers',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3], 'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false, 'required' => false,
@@ -113,7 +113,7 @@ class AudienceType extends AbstractType
if (in_array('frustrations', $enabled, true)) { if (in_array('frustrations', $enabled, true)) {
$builder->add('frustrations', TextareaType::class, [ $builder->add('frustrations', TextareaType::class, [
'label' => 'mautic.program.audience.field.frustrations', 'label' => 'mt3s.marketing_program.audience.field.frustrations',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3], 'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false, 'required' => false,
@@ -122,7 +122,7 @@ class AudienceType extends AbstractType
if (in_array('triggers', $enabled, true)) { if (in_array('triggers', $enabled, true)) {
$builder->add('triggers', TextareaType::class, [ $builder->add('triggers', TextareaType::class, [
'label' => 'mautic.program.audience.field.triggers', 'label' => 'mt3s.marketing_program.audience.field.triggers',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3], 'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false, 'required' => false,
@@ -132,7 +132,7 @@ class AudienceType extends AbstractType
if (in_array('decision_role', $enabled, true)) { if (in_array('decision_role', $enabled, true)) {
$kind = ItemTypeProvider::KIND_AUDIENCE_DECISION_ROLE; $kind = ItemTypeProvider::KIND_AUDIENCE_DECISION_ROLE;
$builder->add('decisionRole', ChoiceType::class, [ $builder->add('decisionRole', ChoiceType::class, [
'label' => 'mautic.program.audience.field.decision_role', 'label' => 'mt3s.marketing_program.audience.field.decision_role',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'choices' => $this->typeProvider->getChoices($kind), 'choices' => $this->typeProvider->getChoices($kind),
@@ -144,7 +144,7 @@ class AudienceType extends AbstractType
if (in_array('tones', $enabled, true)) { if (in_array('tones', $enabled, true)) {
$kind = ItemTypeProvider::KIND_AUDIENCE_TONE; $kind = ItemTypeProvider::KIND_AUDIENCE_TONE;
$builder->add('preferredTones', ChoiceType::class, [ $builder->add('preferredTones', ChoiceType::class, [
'label' => 'mautic.program.audience.field.preferred_tones', 'label' => 'mt3s.marketing_program.audience.field.preferred_tones',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'choices' => $this->typeProvider->getChoices($kind), 'choices' => $this->typeProvider->getChoices($kind),
'expanded' => true, 'expanded' => true,
@@ -156,7 +156,7 @@ class AudienceType extends AbstractType
if (in_array('channels', $enabled, true)) { if (in_array('channels', $enabled, true)) {
// One checkbox per channel, in the order of Audience::CHANNELS. // One checkbox per channel, in the order of Audience::CHANNELS.
$builder->add('preferredChannels', ChoiceType::class, [ $builder->add('preferredChannels', ChoiceType::class, [
'label' => 'mautic.program.audience.field.preferred_channels', 'label' => 'mt3s.marketing_program.audience.field.preferred_channels',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'choices' => array_flip(Audience::CHANNELS), 'choices' => array_flip(Audience::CHANNELS),
'expanded' => true, 'expanded' => true,
@@ -167,7 +167,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' => 'mautic.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,
@@ -181,7 +181,7 @@ class AudienceType extends AbstractType
if (in_array('size', $enabled, true)) { if (in_array('size', $enabled, true)) {
$builder->add('estimatedSize', IntegerType::class, [ $builder->add('estimatedSize', IntegerType::class, [
'label' => 'mautic.program.audience.field.estimated_size', 'label' => 'mt3s.marketing_program.audience.field.estimated_size',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'min' => 0, 'step' => 1], 'attr' => ['class' => 'form-control', 'min' => 0, 'step' => 1],
'required' => false, 'required' => false,
@@ -189,7 +189,7 @@ class AudienceType extends AbstractType
} }
$builder->add('isPublished', YesNoButtonGroupType::class, [ $builder->add('isPublished', YesNoButtonGroupType::class, [
'label' => 'mautic.program.audience.field.active', 'label' => 'mt3s.marketing_program.audience.field.active',
]); ]);
$builder->add('buttons', FormButtonsType::class); $builder->add('buttons', FormButtonsType::class);
@@ -208,6 +208,6 @@ class AudienceType extends AbstractType
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'program_audience'; return 'mt3s_marketing_program_audience';
} }
} }
+12 -12
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use MauticPlugin\ProgramBundle\Model\StakeholderModel; use MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel;
use MauticPlugin\ProgramBundle\Service\CurrencyProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
use MauticPlugin\ProgramBundle\Service\AudienceAttributes; use MauticPlugin\MT3SMarketingProgramBundle\Service\AudienceAttributes;
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;
@@ -17,8 +17,8 @@ use Symfony\Component\Validator\Constraints\NotBlank;
/** /**
* The "Program Settings" tab of Settings > Configuration: the plugin's general settings only. * The "Program Settings" tab of Settings > Configuration: the plugin's general settings only.
* Each child is a local.php parameter: * Each child is a local.php parameter:
* - program_currency: the currency of every amount in the plugin (general setting); * - mt3s_marketing_program_currency: the currency of every amount in the plugin (general setting);
* - program_stakeholder_phone_region: default region for stakeholder phone numbers typed without a prefix; * - mt3s_marketing_program_stakeholder_phone_region: default region for stakeholder phone numbers typed without a prefix;
* - one toggle per audience persona attribute (AudienceAttributes), so each install defines its * - one toggle per audience persona attribute (AudienceAttributes), so each install defines its
* personas as it needs (b2b, b2c…). * personas as it needs (b2b, b2c…).
* *
@@ -29,7 +29,7 @@ use Symfony\Component\Validator\Constraints\NotBlank;
*/ */
class ConfigType extends AbstractType class ConfigType extends AbstractType
{ {
public const FORM_ALIAS = 'programconfig'; public const FORM_ALIAS = 'mt3smarketingprogramconfig';
public function __construct( public function __construct(
private CurrencyProvider $currencyProvider, private CurrencyProvider $currencyProvider,
@@ -40,9 +40,9 @@ class ConfigType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder->add(CurrencyProvider::CONFIG_PARAMETER, ChoiceType::class, [ $builder->add(CurrencyProvider::CONFIG_PARAMETER, ChoiceType::class, [
'label' => 'mautic.program.config.currency', 'label' => 'mt3s.marketing_program.config.currency',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.program.config.currency.tooltip'], 'attr' => ['class' => 'form-control', 'tooltip' => 'mt3s.marketing_program.config.currency.tooltip'],
'choices' => $this->currencyProvider->getChoices(), 'choices' => $this->currencyProvider->getChoices(),
'placeholder' => false, 'placeholder' => false,
'required' => true, 'required' => true,
@@ -53,9 +53,9 @@ class ConfigType extends AbstractType
// Default region for stakeholder phone numbers typed without a country prefix (ISO 3166-1 // Default region for stakeholder phone numbers typed without a country prefix (ISO 3166-1
// alpha-2, e.g. FR). Read by StakeholderModel on save. // alpha-2, e.g. FR). Read by StakeholderModel on save.
$builder->add(StakeholderModel::PHONE_REGION_PARAMETER, TextType::class, [ $builder->add(StakeholderModel::PHONE_REGION_PARAMETER, TextType::class, [
'label' => 'mautic.program.config.stakeholder_phone_region', 'label' => 'mt3s.marketing_program.config.stakeholder_phone_region',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.program.config.stakeholder_phone_region.tooltip', 'maxlength' => 2], 'attr' => ['class' => 'form-control', 'tooltip' => 'mt3s.marketing_program.config.stakeholder_phone_region.tooltip', 'maxlength' => 2],
'required' => true, 'required' => true,
'constraints' => [new NotBlank()], 'constraints' => [new NotBlank()],
'empty_data' => StakeholderModel::DEFAULT_PHONE_REGION, 'empty_data' => StakeholderModel::DEFAULT_PHONE_REGION,
@@ -64,7 +64,7 @@ class ConfigType extends AbstractType
// One toggle per audience persona attribute (AudienceAttributes), defaults to enabled. // One toggle per audience persona attribute (AudienceAttributes), defaults to enabled.
foreach (AudienceAttributes::ATTRIBUTES as $attribute => $field) { foreach (AudienceAttributes::ATTRIBUTES as $attribute => $field) {
$builder->add(AudienceAttributes::toggleParameter($attribute), YesNoButtonGroupType::class, [ $builder->add(AudienceAttributes::toggleParameter($attribute), YesNoButtonGroupType::class, [
'label' => 'mautic.program.audience.attribute.'.$attribute, 'label' => 'mt3s.marketing_program.audience.attribute.'.$attribute,
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'data' => $this->audienceAttributes->isEnabled($attribute), 'data' => $this->audienceAttributes->isEnabled($attribute),
'required' => false, 'required' => false,
+12 -12
View File
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Service\Pictograms; use MauticPlugin\MT3SMarketingProgramBundle\Service\Pictograms;
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\FormType; use Symfony\Component\Form\Extension\Core\Type\FormType;
@@ -40,7 +40,7 @@ class ItemTypeConfigType extends AbstractType
$default = $this->typeProvider->getDefaultLocale(); $default = $this->typeProvider->getDefaultLocale();
$builder->add('key', HiddenType::class, [ $builder->add('key', HiddenType::class, [
'attr' => ['class' => 'initiative-type-key'], 'attr' => ['class' => 'program-type-key'],
]); ]);
$names = $builder->create('names', FormType::class, ['label' => false]); $names = $builder->create('names', FormType::class, ['label' => false]);
@@ -50,17 +50,17 @@ class ItemTypeConfigType extends AbstractType
$isDefault = $locale === $default; $isDefault = $locale === $default;
$names->add($locale, TextType::class, [ $names->add($locale, TextType::class, [
'label' => 'mautic.program.config.type.name', 'label' => 'mt3s.marketing_program.config.type.name',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191, 'data-locale' => $locale, 'data-language' => $language], 'attr' => ['class' => 'form-control', 'maxlength' => 191, 'data-locale' => $locale, 'data-language' => $language],
'required' => $isDefault, 'required' => $isDefault,
'constraints' => $isDefault 'constraints' => $isDefault
? [new NotBlank(message: 'mautic.program.config.type.name.required'), new Length(max: 191)] ? [new NotBlank(message: 'mt3s.marketing_program.config.type.name.required'), new Length(max: 191)]
: [new Length(max: 191)], : [new Length(max: 191)],
]); ]);
$descriptions->add($locale, TextareaType::class, [ $descriptions->add($locale, TextareaType::class, [
'label' => 'mautic.program.config.type.description', 'label' => 'mt3s.marketing_program.config.type.description',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2, 'data-locale' => $locale], 'attr' => ['class' => 'form-control', 'rows' => 2, 'data-locale' => $locale],
'required' => false, 'required' => false,
@@ -70,15 +70,15 @@ class ItemTypeConfigType extends AbstractType
$builder->add($names); $builder->add($names);
$builder->add($descriptions); $builder->add($descriptions);
// Pictogram; the preview next to the dropdown is updated by program.js. // Pictogram; the preview next to the dropdown is updated by mt3s-mp-program.js.
if ($options['with_icon']) { if ($options['with_icon']) {
$builder->add('icon', ChoiceType::class, [ $builder->add('icon', ChoiceType::class, [
'label' => 'mautic.program.config.type.icon', 'label' => 'mt3s.marketing_program.config.type.icon',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control initiative-type-icon-select'], 'attr' => ['class' => 'form-control program-type-icon-select'],
'choices' => Pictograms::getChoices(), 'choices' => Pictograms::getChoices(),
'choice_attr' => fn (?string $icon): array => ['data-icon' => (string) $icon], 'choice_attr' => fn (?string $icon): array => ['data-icon' => (string) $icon],
'placeholder' => 'mautic.program.config.type.icon.none', 'placeholder' => 'mt3s.marketing_program.config.type.icon.none',
'required' => false, 'required' => false,
]); ]);
} }
@@ -104,6 +104,6 @@ class ItemTypeConfigType extends AbstractType
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'program_item_type_config'; return 'mt3s_marketing_program_item_type_config';
} }
} }
+4 -4
View File
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Mautic\CoreBundle\Form\Type\FormButtonsType; use Mautic\CoreBundle\Form\Type\FormButtonsType;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\CollectionType;
@@ -52,7 +52,7 @@ class ItemTypesType extends AbstractType
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
// The POST data keys: program_item_types[<parameter>][<index>][…]. // The POST data keys: mt3s_marketing_program_item_types[<parameter>][<index>][…].
return 'program_item_types'; return 'mt3s_marketing_program_item_types';
} }
} }
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use MauticPlugin\ProgramBundle\Entity\InitiativeAllocationItem; use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramAllocationItem;
use MauticPlugin\ProgramBundle\Service\CurrencyProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider; 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\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -17,14 +17,14 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
/** /**
* One row of the allocation items collection in InitiativeType: type, name, description, planned cost and * One row of the allocation items collection in ProgramType: type, name, description, planned cost and
* real cost (both in the general currency). Works like InitiativeDescriptionItemType (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/program.js). * Assets/js/mt3s-mp-program.js).
* *
* @extends AbstractType<InitiativeAllocationItem> * @extends AbstractType<ProgramAllocationItem>
*/ */
class InitiativeAllocationItemType extends AbstractType class ProgramAllocationItemType extends AbstractType
{ {
public function __construct( public function __construct(
private ItemTypeProvider $typeProvider, private ItemTypeProvider $typeProvider,
@@ -37,11 +37,11 @@ class InitiativeAllocationItemType extends AbstractType
$kind = ItemTypeProvider::KIND_ALLOCATION; $kind = ItemTypeProvider::KIND_ALLOCATION;
$builder->add('type', ChoiceType::class, [ $builder->add('type', ChoiceType::class, [
'label' => 'mautic.program.allocation_item.field.type', 'label' => 'mt3s.marketing_program.allocation_item.field.type',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control initiative-item-type'], 'attr' => ['class' => 'form-control program-item-type'],
'choices' => $this->typeProvider->getChoices($kind), 'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by program.js. // The type's description and pictogram, shown next to the dropdown by mt3s-mp-program.js.
'choice_attr' => fn (?string $key): array => [ 'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key), 'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key), 'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -51,23 +51,23 @@ class InitiativeAllocationItemType extends AbstractType
]); ]);
$builder->add('name', TextType::class, [ $builder->add('name', TextType::class, [
'label' => 'mautic.program.allocation_item.field.name', 'label' => 'mt3s.marketing_program.allocation_item.field.name',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 255], 'attr' => ['class' => 'form-control', 'maxlength' => 255],
'required' => false, 'required' => false,
]); ]);
$builder->add('description', TextareaType::class, [ $builder->add('description', TextareaType::class, [
'label' => 'mautic.program.allocation_item.field.description', 'label' => 'mt3s.marketing_program.allocation_item.field.description',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3], 'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false, 'required' => false,
]); ]);
// Costs are in the general currency (Settings > Configuration > Initiative Settings), shown next to the field. // Costs are in the general currency (Settings > Configuration > Program Settings), shown next to the field.
foreach (['planned', 'real'] as $cost) { foreach (['planned', 'real'] as $cost) {
$builder->add($cost.'Cost', NumberType::class, [ $builder->add($cost.'Cost', NumberType::class, [
'label' => 'mautic.program.allocation_item.field.'.$cost.'_cost', 'label' => 'mt3s.marketing_program.allocation_item.field.'.$cost.'_cost',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'postaddon_text' => $this->currencyProvider->getCurrency()], 'attr' => ['class' => 'form-control', 'postaddon_text' => $this->currencyProvider->getCurrency()],
'input' => 'string', 'input' => 'string',
@@ -77,19 +77,19 @@ class InitiativeAllocationItemType extends AbstractType
} }
$builder->add('position', HiddenType::class, [ $builder->add('position', HiddenType::class, [
'attr' => ['class' => 'initiative-row-position'], 'attr' => ['class' => 'program-row-position'],
]); ]);
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => InitiativeAllocationItem::class, 'data_class' => ProgramAllocationItem::class,
]); ]);
} }
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'program_allocation_item'; return 'mt3s_marketing_program_allocation_item';
} }
} }
@@ -2,12 +2,12 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use MauticPlugin\ProgramBundle\Entity\Audience; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\AudiencePriority; use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudiencePriority;
use MauticPlugin\ProgramBundle\Entity\InitiativeAudience; use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramAudience;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType; use Symfony\Component\Form\Extension\Core\Type\EnumType;
@@ -17,18 +17,18 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
/** /**
* One row of the audiences collection in InitiativeType: 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 initiative-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/program.js. * message. The position field is hidden and kept in display order by Assets/js/mt3s-mp-program.js.
* *
* @extends AbstractType<InitiativeAudience> * @extends AbstractType<ProgramAudience>
*/ */
class InitiativeAudienceType extends AbstractType class ProgramAudienceType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder->add('audience', EntityType::class, [ $builder->add('audience', EntityType::class, [
'label' => 'mautic.program.audience.field.name', 'label' => 'mt3s.marketing_program.audience.field.name',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => Audience::class, 'class' => Audience::class,
@@ -43,7 +43,7 @@ class InitiativeAudienceType extends AbstractType
// Dropdown in the order of the AudiencePriority cases. // Dropdown in the order of the AudiencePriority cases.
$builder->add('priority', EnumType::class, [ $builder->add('priority', EnumType::class, [
'label' => 'mautic.program.audience.field.priority', 'label' => 'mt3s.marketing_program.audience.field.priority',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => AudiencePriority::class, 'class' => AudiencePriority::class,
@@ -51,26 +51,26 @@ class InitiativeAudienceType extends AbstractType
]); ]);
$builder->add('valueProposition', TextareaType::class, [ $builder->add('valueProposition', TextareaType::class, [
'label' => 'mautic.program.audience.field.value_proposition', 'label' => 'mt3s.marketing_program.audience.field.value_proposition',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2], 'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false, 'required' => false,
]); ]);
$builder->add('position', HiddenType::class, [ $builder->add('position', HiddenType::class, [
'attr' => ['class' => 'initiative-row-position'], 'attr' => ['class' => 'program-row-position'],
]); ]);
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => InitiativeAudience::class, 'data_class' => ProgramAudience::class,
]); ]);
} }
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'program_initiative_audience'; return 'mt3s_marketing_program_program_audience';
} }
} }
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use MauticPlugin\ProgramBundle\Entity\InitiativeDescriptionItem; use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramDescriptionItem;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider; 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\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -14,14 +14,14 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
/** /**
* One row of the description items collection in InitiativeType. The type dropdown lists the description item * One row of the description items collection in ProgramType. The type dropdown lists the description item
* types set up in Settings > Configuration > Initiative; 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/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
* program.js. * mt3s-mp-program.js.
* *
* @extends AbstractType<InitiativeDescriptionItem> * @extends AbstractType<ProgramDescriptionItem>
*/ */
class InitiativeDescriptionItemType extends AbstractType class ProgramDescriptionItemType extends AbstractType
{ {
public function __construct( public function __construct(
private ItemTypeProvider $typeProvider, private ItemTypeProvider $typeProvider,
@@ -33,11 +33,11 @@ class InitiativeDescriptionItemType extends AbstractType
$kind = ItemTypeProvider::KIND_DESCRIPTION; $kind = ItemTypeProvider::KIND_DESCRIPTION;
$builder->add('type', ChoiceType::class, [ $builder->add('type', ChoiceType::class, [
'label' => 'mautic.program.description_item.field.type', 'label' => 'mt3s.marketing_program.description_item.field.type',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control initiative-item-type'], 'attr' => ['class' => 'form-control program-item-type'],
'choices' => $this->typeProvider->getChoices($kind), 'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by program.js. // The type's description and pictogram, shown next to the dropdown by mt3s-mp-program.js.
'choice_attr' => fn (?string $key): array => [ 'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key), 'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key), 'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -47,26 +47,26 @@ class InitiativeDescriptionItemType extends AbstractType
]); ]);
$builder->add('description', TextareaType::class, [ $builder->add('description', TextareaType::class, [
'label' => 'mautic.program.description_item.field.description', 'label' => 'mt3s.marketing_program.description_item.field.description',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 5], 'attr' => ['class' => 'form-control', 'rows' => 5],
'required' => false, 'required' => false,
]); ]);
$builder->add('position', HiddenType::class, [ $builder->add('position', HiddenType::class, [
'attr' => ['class' => 'initiative-row-position'], 'attr' => ['class' => 'program-row-position'],
]); ]);
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => InitiativeDescriptionItem::class, 'data_class' => ProgramDescriptionItem::class,
]); ]);
} }
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'program_description_item'; return 'mt3s_marketing_program_description_item';
} }
} }
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use MauticPlugin\ProgramBundle\Entity\InitiativeObjective; use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramObjective;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -17,13 +17,13 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
/** /**
* One row of the objectives collection in InitiativeType: 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 InitiativeDescriptionItemType (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/program.js). * next to it, hidden position kept in display order by Assets/js/mt3s-mp-program.js).
* *
* @extends AbstractType<InitiativeObjective> * @extends AbstractType<ProgramObjective>
*/ */
class InitiativeObjectiveType extends AbstractType class ProgramObjectiveType extends AbstractType
{ {
public function __construct( public function __construct(
private ItemTypeProvider $typeProvider, private ItemTypeProvider $typeProvider,
@@ -35,11 +35,11 @@ class InitiativeObjectiveType extends AbstractType
$kind = ItemTypeProvider::KIND_OBJECTIVE; $kind = ItemTypeProvider::KIND_OBJECTIVE;
$builder->add('type', ChoiceType::class, [ $builder->add('type', ChoiceType::class, [
'label' => 'mautic.program.objective.field.type', 'label' => 'mt3s.marketing_program.objective.field.type',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control initiative-item-type'], 'attr' => ['class' => 'form-control program-item-type'],
'choices' => $this->typeProvider->getChoices($kind), 'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by program.js. // The type's description and pictogram, shown next to the dropdown by mt3s-mp-program.js.
'choice_attr' => fn (?string $key): array => [ 'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key), 'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key), 'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -49,36 +49,36 @@ class InitiativeObjectiveType extends AbstractType
]); ]);
$builder->add('title', TextType::class, [ $builder->add('title', TextType::class, [
'label' => 'mautic.program.objective.field.title', 'label' => 'mt3s.marketing_program.objective.field.title',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 255], 'attr' => ['class' => 'form-control', 'maxlength' => 255],
]); ]);
$builder->add('priority', IntegerType::class, [ $builder->add('priority', IntegerType::class, [
'label' => 'mautic.program.objective.field.priority', 'label' => 'mt3s.marketing_program.objective.field.priority',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'invalid_message' => 'mautic.program.objective.priority.range', 'invalid_message' => 'mt3s.marketing_program.objective.priority.range',
'attr' => [ 'attr' => [
'class' => 'form-control', 'class' => 'form-control',
'min' => InitiativeObjective::PRIORITY_MIN, 'min' => ProgramObjective::PRIORITY_MIN,
'max' => InitiativeObjective::PRIORITY_MAX, 'max' => ProgramObjective::PRIORITY_MAX,
'step' => 1, 'step' => 1,
], ],
]); ]);
$builder->add('description', TextareaType::class, [ $builder->add('description', TextareaType::class, [
'label' => 'mautic.program.objective.field.description', 'label' => 'mt3s.marketing_program.objective.field.description',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2], 'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false, 'required' => false,
]); ]);
$builder->add('position', HiddenType::class, [ $builder->add('position', HiddenType::class, [
'attr' => ['class' => 'initiative-row-position'], 'attr' => ['class' => 'program-row-position'],
]); ]);
$builder->add('isAchieved', CheckboxType::class, [ $builder->add('isAchieved', CheckboxType::class, [
'label' => 'mautic.program.objective.field.is_achieved', 'label' => 'mt3s.marketing_program.objective.field.is_achieved',
'required' => false, 'required' => false,
]); ]);
} }
@@ -86,12 +86,12 @@ class InitiativeObjectiveType extends AbstractType
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => InitiativeObjective::class, 'data_class' => ProgramObjective::class,
]); ]);
} }
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'program_objective'; return 'mt3s_marketing_program_objective';
} }
} }
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use MauticPlugin\ProgramBundle\Entity\InitiativeStakeholder; use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramStakeholder;
use MauticPlugin\ProgramBundle\Entity\Stakeholder; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Stakeholder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -15,18 +15,18 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
/** /**
* One row of the stakeholders collection in InitiativeType: 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/program.js. * kept in display order by Assets/js/mt3s-mp-program.js.
* *
* @extends AbstractType<InitiativeStakeholder> * @extends AbstractType<ProgramStakeholder>
*/ */
class InitiativeStakeholderType extends AbstractType class ProgramStakeholderType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder->add('stakeholder', EntityType::class, [ $builder->add('stakeholder', EntityType::class, [
'label' => 'mautic.program.stakeholder.field.name', 'label' => 'mt3s.marketing_program.stakeholder.field.name',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => Stakeholder::class, 'class' => Stakeholder::class,
@@ -39,27 +39,27 @@ class InitiativeStakeholderType extends AbstractType
'required' => true, 'required' => true,
]); ]);
$builder->add('roleInInitiative', TextType::class, [ $builder->add('roleInProgram', TextType::class, [
'label' => 'mautic.program.stakeholder.field.role_in_initiative', 'label' => 'mt3s.marketing_program.stakeholder.field.role_in_program',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191], 'attr' => ['class' => 'form-control', 'maxlength' => 191],
'required' => false, 'required' => false,
]); ]);
$builder->add('position', HiddenType::class, [ $builder->add('position', HiddenType::class, [
'attr' => ['class' => 'initiative-row-position'], 'attr' => ['class' => 'program-row-position'],
]); ]);
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => InitiativeStakeholder::class, 'data_class' => ProgramStakeholder::class,
]); ]);
} }
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'program_initiative_stakeholder'; return 'mt3s_marketing_program_program_stakeholder';
} }
} }
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Mautic\CategoryBundle\Form\Type\CategoryListType; use Mautic\CategoryBundle\Form\Type\CategoryListType;
@@ -13,11 +13,11 @@ use Mautic\CoreBundle\Form\Type\FormButtonsType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType; use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Mautic\UserBundle\Entity\User; use Mautic\UserBundle\Entity\User;
use Mautic\UserBundle\Form\Type\UserListType; use Mautic\UserBundle\Form\Type\UserListType;
use MauticPlugin\ProgramBundle\Entity\Initiative; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\ProgramBundle\Entity\InitiativeStatus; use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramStatus;
use MauticPlugin\ProgramBundle\Service\CurrencyProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\CurrencyProvider;
use MauticPlugin\ProgramBundle\Form\Type\InitiativeAudienceType; use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\ProgramAudienceType;
use MauticPlugin\ProgramBundle\Form\Type\InitiativeStakeholderType; 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;
@@ -28,9 +28,9 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
/** /**
* @extends AbstractType<Initiative> * @extends AbstractType<Program>
*/ */
class InitiativeType extends AbstractType class ProgramType extends AbstractType
{ {
public function __construct( public function __construct(
private CurrencyProvider $currencyProvider, private CurrencyProvider $currencyProvider,
@@ -47,15 +47,15 @@ class InitiativeType extends AbstractType
$builder->addEventSubscriber(new CleanFormSubscriber(['name' => 'filter'])); $builder->addEventSubscriber(new CleanFormSubscriber(['name' => 'filter']));
$builder->add('name', TextType::class, [ $builder->add('name', TextType::class, [
'label' => 'mautic.program.field.name', 'label' => 'mt3s.marketing_program.field.name',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
]); ]);
// The Description tab. by_reference false: Symfony calls Initiative::addDescriptionItem()/removeDescriptionItem(). // The Description tab. by_reference false: Symfony calls Program::addDescriptionItem()/removeDescriptionItem().
$builder->add('descriptionItems', CollectionType::class, [ $builder->add('descriptionItems', CollectionType::class, [
'label' => 'mautic.program.field.description_items', 'label' => 'mt3s.marketing_program.field.description_items',
'entry_type' => InitiativeDescriptionItemType::class, 'entry_type' => ProgramDescriptionItemType::class,
'entry_options' => ['label' => false], 'entry_options' => ['label' => false],
'allow_add' => true, 'allow_add' => true,
'allow_delete' => true, 'allow_delete' => true,
@@ -67,8 +67,8 @@ class InitiativeType extends AbstractType
// The Allocations tab's cost lines, in the general currency. // The Allocations tab's cost lines, in the general currency.
$builder->add('allocationItems', CollectionType::class, [ $builder->add('allocationItems', CollectionType::class, [
'label' => 'mautic.program.field.allocation_items', 'label' => 'mt3s.marketing_program.field.allocation_items',
'entry_type' => InitiativeAllocationItemType::class, 'entry_type' => ProgramAllocationItemType::class,
'entry_options' => ['label' => false], 'entry_options' => ['label' => false],
'allow_add' => true, 'allow_add' => true,
'allow_delete' => true, 'allow_delete' => true,
@@ -79,10 +79,10 @@ class InitiativeType 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
// Initiative::addAudience()/removeAudience(). // Program::addAudience()/removeAudience().
$builder->add('audiences', CollectionType::class, [ $builder->add('audiences', CollectionType::class, [
'label' => 'mautic.program.field.audiences', 'label' => 'mt3s.marketing_program.field.audiences',
'entry_type' => InitiativeAudienceType::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,
@@ -93,10 +93,10 @@ class InitiativeType extends AbstractType
]); ]);
// 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
// Initiative::addStakeholder()/removeStakeholder(). // Program::addStakeholder()/removeStakeholder().
$builder->add('stakeholders', CollectionType::class, [ $builder->add('stakeholders', CollectionType::class, [
'label' => 'mautic.program.field.stakeholders', 'label' => 'mt3s.marketing_program.field.stakeholders',
'entry_type' => InitiativeStakeholderType::class, 'entry_type' => ProgramStakeholderType::class,
'entry_options' => ['label' => false], 'entry_options' => ['label' => false],
'allow_add' => true, 'allow_add' => true,
'allow_delete' => true, 'allow_delete' => true,
@@ -107,21 +107,21 @@ class InitiativeType extends AbstractType
]); ]);
$builder->add('version', IntegerType::class, [ $builder->add('version', IntegerType::class, [
'label' => 'mautic.program.field.version', 'label' => 'mt3s.marketing_program.field.version',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'invalid_message' => 'mautic.program.version.range', 'invalid_message' => 'mt3s.marketing_program.version.range',
'attr' => [ 'attr' => [
'class' => 'form-control', 'class' => 'form-control',
'min' => Initiative::VERSION_MIN, 'min' => Program::VERSION_MIN,
'max' => Initiative::VERSION_MAX, 'max' => Program::VERSION_MAX,
'step' => 1, 'step' => 1,
], ],
]); ]);
// by_reference false: Symfony calls Initiative::addObjective()/removeObjective(), which keep both sides in sync. // by_reference false: Symfony calls Program::addObjective()/removeObjective(), which keep both sides in sync.
$builder->add('objectives', CollectionType::class, [ $builder->add('objectives', CollectionType::class, [
'label' => 'mautic.program.field.objectives', 'label' => 'mt3s.marketing_program.field.objectives',
'entry_type' => InitiativeObjectiveType::class, 'entry_type' => ProgramObjectiveType::class,
'entry_options' => ['label' => false], 'entry_options' => ['label' => false],
'allow_add' => true, 'allow_add' => true,
'allow_delete' => true, 'allow_delete' => true,
@@ -132,9 +132,9 @@ class InitiativeType extends AbstractType
]); ]);
$builder->add('status', EnumType::class, [ $builder->add('status', EnumType::class, [
'class' => InitiativeStatus::class, 'class' => ProgramStatus::class,
'choice_label' => fn (InitiativeStatus $status): string => $status->getLabelKey(), 'choice_label' => fn (ProgramStatus $status): string => $status->getLabelKey(),
'label' => 'mautic.program.field.status', 'label' => 'mt3s.marketing_program.field.status',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
]); ]);
@@ -142,7 +142,7 @@ class InitiativeType extends AbstractType
// Required here; the column is nullable only because of onDelete SET NULL. // Required here; the column is nullable only because of onDelete SET NULL.
$builder->add( $builder->add(
$builder->create('owner', UserListType::class, [ $builder->create('owner', UserListType::class, [
'label' => 'mautic.program.field.owner', 'label' => 'mt3s.marketing_program.field.owner',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'required' => true, 'required' => true,
@@ -151,16 +151,16 @@ class InitiativeType extends AbstractType
); );
$builder->add('startDate', DatePickerType::class, [ $builder->add('startDate', DatePickerType::class, [
'label' => 'mautic.program.field.start_date', 'label' => 'mt3s.marketing_program.field.start_date',
]); ]);
$builder->add('endDate', DatePickerType::class, [ $builder->add('endDate', DatePickerType::class, [
'label' => 'mautic.program.field.end_date', 'label' => 'mt3s.marketing_program.field.end_date',
]); ]);
// In the general currency (Settings > Configuration > Initiative Settings), shown next to the field. // In the general currency (Settings > Configuration > Program Settings), shown next to the field.
$builder->add('budgetPlanned', NumberType::class, [ $builder->add('budgetPlanned', NumberType::class, [
'label' => 'mautic.program.field.budget_planned', 'label' => 'mt3s.marketing_program.field.budget_planned',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'postaddon_text' => $this->currencyProvider->getCurrency()], 'attr' => ['class' => 'form-control', 'postaddon_text' => $this->currencyProvider->getCurrency()],
'input' => 'string', 'input' => 'string',
@@ -169,7 +169,7 @@ class InitiativeType extends AbstractType
]); ]);
$builder->add('category', CategoryListType::class, [ $builder->add('category', CategoryListType::class, [
'bundle' => 'initiative', 'bundle' => 'program',
]); ]);
$builder->add('isPublished', YesNoButtonGroupType::class, [ $builder->add('isPublished', YesNoButtonGroupType::class, [
@@ -186,12 +186,12 @@ class InitiativeType extends AbstractType
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => Initiative::class, 'data_class' => Program::class,
]); ]);
} }
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'initiative'; return 'program';
} }
} }
+12 -12
View File
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use MauticPlugin\ProgramBundle\Entity\Stakeholder; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider; 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 Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
@@ -33,38 +33,38 @@ class StakeholderType extends AbstractType
$kind = ItemTypeProvider::KIND_STAKEHOLDER; $kind = ItemTypeProvider::KIND_STAKEHOLDER;
$builder->add('name', TextType::class, [ $builder->add('name', TextType::class, [
'label' => 'mautic.program.stakeholder.field.name', 'label' => 'mt3s.marketing_program.stakeholder.field.name',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191], 'attr' => ['class' => 'form-control', 'maxlength' => 191],
]); ]);
$builder->add('email', EmailType::class, [ $builder->add('email', EmailType::class, [
'label' => 'mautic.program.stakeholder.field.email', 'label' => 'mt3s.marketing_program.stakeholder.field.email',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191], 'attr' => ['class' => 'form-control', 'maxlength' => 191],
'required' => false, 'required' => false,
]); ]);
$builder->add('phone', TelType::class, [ $builder->add('phone', TelType::class, [
'label' => 'mautic.program.stakeholder.field.phone', 'label' => 'mt3s.marketing_program.stakeholder.field.phone',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 50], 'attr' => ['class' => 'form-control', 'maxlength' => 50],
'required' => false, 'required' => false,
]); ]);
$builder->add('role', TextType::class, [ $builder->add('role', TextType::class, [
'label' => 'mautic.program.stakeholder.field.role', 'label' => 'mt3s.marketing_program.stakeholder.field.role',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191], 'attr' => ['class' => 'form-control', 'maxlength' => 191],
'required' => false, 'required' => false,
]); ]);
$builder->add('type', ChoiceType::class, [ $builder->add('type', ChoiceType::class, [
'label' => 'mautic.program.stakeholder.field.type', 'label' => 'mt3s.marketing_program.stakeholder.field.type',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control initiative-item-type'], 'attr' => ['class' => 'form-control program-item-type'],
'choices' => $this->typeProvider->getChoices($kind), 'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by program.js. // The type's description and pictogram, shown next to the dropdown by mt3s-mp-program.js.
'choice_attr' => fn (?string $key): array => [ 'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key), 'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key), 'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -74,7 +74,7 @@ class StakeholderType extends AbstractType
]); ]);
$builder->add('isPublished', YesNoButtonGroupType::class, [ $builder->add('isPublished', YesNoButtonGroupType::class, [
'label' => 'mautic.program.stakeholder.field.active', 'label' => 'mt3s.marketing_program.stakeholder.field.active',
]); ]);
$builder->add('buttons', FormButtonsType::class); $builder->add('buttons', FormButtonsType::class);
@@ -93,6 +93,6 @@ class StakeholderType extends AbstractType
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'program_stakeholder'; return 'mt3s_marketing_program_stakeholder';
} }
} }
+18 -18
View File
@@ -2,13 +2,13 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use MauticPlugin\ProgramBundle\Entity\DependencyType; use MauticPlugin\MT3SMarketingProgramBundle\Entity\DependencyType;
use MauticPlugin\ProgramBundle\Entity\Initiative; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\ProgramBundle\Entity\Task; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskDependency; use MauticPlugin\MT3SMarketingProgramBundle\Entity\TaskDependency;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType; use Symfony\Component\Form\Extension\Core\Type\EnumType;
@@ -18,7 +18,7 @@ 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 initiative 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> * @extends AbstractType<TaskDependency>
@@ -27,23 +27,23 @@ class TaskDependencyType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
/** @var Initiative|null $initiative */ /** @var Program|null $program */
$initiative = $options['initiative']; $program = $options['program'];
/** @var Task|null $task */ /** @var Task|null $task */
$task = $options['task']; $task = $options['task'];
$builder->add('dependsOn', EntityType::class, [ $builder->add('dependsOn', EntityType::class, [
'label' => 'mautic.program.task.dependency.field.depends_on', 'label' => 'mt3s.marketing_program.task.dependency.field.depends_on',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => Task::class, 'class' => Task::class,
'choice_label' => 'name', 'choice_label' => 'name',
'query_builder' => function (EntityRepository $er) use ($initiative, $task) { 'query_builder' => function (EntityRepository $er) use ($program, $task) {
$qb = $er->createQueryBuilder('t') $qb = $er->createQueryBuilder('t')
->orderBy('t.name', 'ASC'); ->orderBy('t.name', 'ASC');
if (null !== $initiative) { if (null !== $program) {
$qb->andWhere('t.initiative = :initiative')->setParameter('initiative', $initiative); $qb->andWhere('t.program = :program')->setParameter('program', $program);
} }
if (null !== $task?->getId()) { if (null !== $task?->getId()) {
@@ -57,16 +57,16 @@ class TaskDependencyType extends AbstractType
]); ]);
$builder->add('dependencyType', EnumType::class, [ $builder->add('dependencyType', EnumType::class, [
'label' => 'mautic.program.task.dependency.field.type', 'label' => 'mt3s.marketing_program.task.dependency.field.type',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => DependencyType::class, 'class' => DependencyType::class,
'choice_label' => fn (DependencyType $type): string => $type->getLabelKey(), 'choice_label' => fn (DependencyType $type): string => $type->getLabelKey(),
]); ]);
// The row's order in the collection, rewritten by program.js after each change. // The row's order in the collection, rewritten by mt3s-mp-program.js after each change.
$builder->add('position', HiddenType::class, [ $builder->add('position', HiddenType::class, [
'attr' => ['class' => 'initiative-row-position'], 'attr' => ['class' => 'program-row-position'],
]); ]);
} }
@@ -75,13 +75,13 @@ class TaskDependencyType extends AbstractType
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => TaskDependency::class, 'data_class' => TaskDependency::class,
]); ]);
$resolver->setDefined(['initiative', 'task']); $resolver->setDefined(['program', 'task']);
$resolver->setAllowedTypes('initiative', [Initiative::class, 'null']); $resolver->setAllowedTypes('program', [Program::class, 'null']);
$resolver->setAllowedTypes('task', [Task::class, 'null']); $resolver->setAllowedTypes('task', [Task::class, 'null']);
} }
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'program_task_dependency'; return 'mt3s_marketing_program_task_dependency';
} }
} }
+21 -21
View File
@@ -2,13 +2,13 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use MauticPlugin\ProgramBundle\Entity\Initiative; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\ProgramBundle\Entity\RaciRole; use MauticPlugin\MT3SMarketingProgramBundle\Entity\RaciRole;
use MauticPlugin\ProgramBundle\Entity\Stakeholder; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Entity\TaskRaci; use MauticPlugin\MT3SMarketingProgramBundle\Entity\TaskRaci;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType; use Symfony\Component\Form\Extension\Core\Type\EnumType;
@@ -18,7 +18,7 @@ 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 initiative'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> * @extends AbstractType<TaskRaci>
*/ */
@@ -26,11 +26,11 @@ class TaskRaciType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
/** @var Initiative|null $initiative */ /** @var Program|null $program */
$initiative = $options['initiative']; $program = $options['program'];
$builder->add('role', EnumType::class, [ $builder->add('role', EnumType::class, [
'label' => 'mautic.program.task.raci.field.role', 'label' => 'mt3s.marketing_program.task.raci.field.role',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => RaciRole::class, 'class' => RaciRole::class,
@@ -38,20 +38,20 @@ class TaskRaciType extends AbstractType
]); ]);
$builder->add('stakeholders', EntityType::class, [ $builder->add('stakeholders', EntityType::class, [
'label' => 'mautic.program.task.raci.field.stakeholders', 'label' => 'mt3s.marketing_program.task.raci.field.stakeholders',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => Stakeholder::class, 'class' => Stakeholder::class,
'choice_label' => 'name', 'choice_label' => 'name',
'query_builder' => function (EntityRepository $er) use ($initiative) { 'query_builder' => function (EntityRepository $er) use ($program) {
$qb = $er->createQueryBuilder('s') $qb = $er->createQueryBuilder('s')
->orderBy('s.name', 'ASC'); ->orderBy('s.name', 'ASC');
// The initiative's assigned stakeholders, when the initiative is known. // The program's assigned stakeholders, when the program is known.
if (null !== $initiative) { if (null !== $program) {
$qb->join('s.initiativeLinks', 'l') $qb->join('s.programLinks', 'l')
->andWhere('l.initiative = :initiative') ->andWhere('l.program = :program')
->setParameter('initiative', $initiative); ->setParameter('program', $program);
} }
return $qb; return $qb;
@@ -61,9 +61,9 @@ class TaskRaciType extends AbstractType
'required' => false, 'required' => false,
]); ]);
// The row's order in the collection, rewritten by program.js after each change. // The row's order in the collection, rewritten by mt3s-mp-program.js after each change.
$builder->add('position', HiddenType::class, [ $builder->add('position', HiddenType::class, [
'attr' => ['class' => 'initiative-row-position'], 'attr' => ['class' => 'program-row-position'],
]); ]);
} }
@@ -72,12 +72,12 @@ class TaskRaciType extends AbstractType
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => TaskRaci::class, 'data_class' => TaskRaci::class,
]); ]);
$resolver->setDefined(['initiative']); $resolver->setDefined(['program']);
$resolver->setAllowedTypes('initiative', [Initiative::class, 'null']); $resolver->setAllowedTypes('program', [Program::class, 'null']);
} }
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'program_task_raci'; return 'mt3s_marketing_program_task_raci';
} }
} }
+28 -28
View File
@@ -2,16 +2,16 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type; namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Mautic\CoreBundle\Form\EventListener\CleanFormSubscriber; use Mautic\CoreBundle\Form\EventListener\CleanFormSubscriber;
use Mautic\CoreBundle\Form\Type\FormButtonsType; use Mautic\CoreBundle\Form\Type\FormButtonsType;
use MauticPlugin\ProgramBundle\Entity\Initiative; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\ProgramBundle\Entity\Task; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskKind; use MauticPlugin\MT3SMarketingProgramBundle\Entity\TaskKind;
use MauticPlugin\ProgramBundle\Entity\TaskStatus; use MauticPlugin\MT3SMarketingProgramBundle\Entity\TaskStatus;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider; use MauticPlugin\MT3SMarketingProgramBundle\Service\ItemTypeProvider;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
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;
@@ -46,7 +46,7 @@ class TaskType extends AbstractType
/** @var Task $task */ /** @var Task $task */
$task = $options['data']; $task = $options['data'];
$initiative = $task->getInitiative(); $program = $task->getProgram();
$kind = ItemTypeProvider::KIND_TASK; $kind = ItemTypeProvider::KIND_TASK;
@@ -54,7 +54,7 @@ class TaskType extends AbstractType
$taskKind = $task->getTaskKind(); $taskKind = $task->getTaskKind();
$builder->add('taskKind', EnumType::class, [ $builder->add('taskKind', EnumType::class, [
'label' => 'mautic.program.task.field.kind', 'label' => 'mt3s.marketing_program.task.field.kind',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => TaskKind::class, 'class' => TaskKind::class,
@@ -62,11 +62,11 @@ class TaskType extends AbstractType
]); ]);
$builder->add('type', ChoiceType::class, [ $builder->add('type', ChoiceType::class, [
'label' => 'mautic.program.task.field.type', 'label' => 'mt3s.marketing_program.task.field.type',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control initiative-item-type'], 'attr' => ['class' => 'form-control program-item-type'],
'choices' => $this->typeProvider->getChoices($kind), 'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by program.js. // The type's description and pictogram, shown next to the dropdown by mt3s-mp-program.js.
'choice_attr' => fn (?string $key): array => [ 'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key), 'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key), 'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -76,23 +76,23 @@ class TaskType extends AbstractType
]); ]);
$builder->add('name', TextType::class, [ $builder->add('name', TextType::class, [
'label' => 'mautic.program.task.field.name', 'label' => 'mt3s.marketing_program.task.field.name',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 255], 'attr' => ['class' => 'form-control', 'maxlength' => 255],
]); ]);
$builder->add('description', TextareaType::class, [ $builder->add('description', TextareaType::class, [
'label' => 'mautic.program.task.field.description', 'label' => 'mt3s.marketing_program.task.field.description',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 6], 'attr' => ['class' => 'form-control', 'rows' => 6],
'required' => false, 'required' => false,
]); ]);
$builder->add('initiative', EntityType::class, [ $builder->add('program', EntityType::class, [
'label' => 'mautic.program.task.field.initiative', 'label' => 'mt3s.marketing_program.task.field.program',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => Initiative::class, 'class' => Program::class,
'choice_label' => 'name', 'choice_label' => 'name',
'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('p')->orderBy('p.name', 'ASC'), 'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('p')->orderBy('p.name', 'ASC'),
'placeholder' => 'mautic.core.form.chooseone', 'placeholder' => 'mautic.core.form.chooseone',
@@ -101,7 +101,7 @@ class TaskType extends AbstractType
// Simple dates, no time (the columns are DATE since 0.13.0). // Simple dates, no time (the columns are DATE since 0.13.0).
$builder->add('startDate', DateType::class, [ $builder->add('startDate', DateType::class, [
'label' => 'mautic.program.task.field.start_date', 'label' => 'mt3s.marketing_program.task.field.start_date',
'widget' => 'single_text', 'widget' => 'single_text',
'format' => 'yyyy-MM-dd', 'format' => 'yyyy-MM-dd',
'html5' => true, 'html5' => true,
@@ -112,7 +112,7 @@ class TaskType extends AbstractType
$isMilestone = TaskKind::Milestone === $task->getTaskKind(); $isMilestone = TaskKind::Milestone === $task->getTaskKind();
$isPhase = TaskKind::Phase === $task->getTaskKind(); $isPhase = TaskKind::Phase === $task->getTaskKind();
$builder->add('endDate', DateType::class, [ $builder->add('endDate', DateType::class, [
'label' => 'mautic.program.task.field.end_date', 'label' => 'mt3s.marketing_program.task.field.end_date',
'widget' => 'single_text', 'widget' => 'single_text',
'format' => 'yyyy-MM-dd', 'format' => 'yyyy-MM-dd',
'html5' => true, 'html5' => true,
@@ -123,7 +123,7 @@ class TaskType extends AbstractType
// Status: a phase has none of its own — it comes from its tasks. // Status: a phase has none of its own — it comes from its tasks.
if (!$isPhase) { if (!$isPhase) {
$builder->add('status', EnumType::class, [ $builder->add('status', EnumType::class, [
'label' => 'mautic.program.task.field.status', 'label' => 'mt3s.marketing_program.task.field.status',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'], 'attr' => ['class' => 'form-control'],
'class' => TaskStatus::class, 'class' => TaskStatus::class,
@@ -132,26 +132,26 @@ class TaskType extends AbstractType
} }
$builder->add('definitionOfDone', TextareaType::class, [ $builder->add('definitionOfDone', TextareaType::class, [
'label' => 'mautic.program.task.field.definition_of_done', 'label' => 'mt3s.marketing_program.task.field.definition_of_done',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3], 'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false, 'required' => false,
]); ]);
$builder->add('plannedWork', IntegerType::class, [ $builder->add('plannedWork', IntegerType::class, [
'label' => 'mautic.program.task.field.planned_work', 'label' => 'mt3s.marketing_program.task.field.planned_work',
'label_attr' => ['class' => 'control-label'], 'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'min' => 0, 'step' => 1, 'postaddon_text' => 'h'], 'attr' => ['class' => 'form-control', 'min' => 0, 'step' => 1, 'postaddon_text' => 'h'],
'required' => false, 'required' => false,
]); ]);
// Dependencies: several edges, each another task of the initiative with the relation type. The // Dependencies: several edges, each another task of the program with the relation type. The
// rows are added and removed by the form template; cycles and self-edges are refused by // rows are added and removed by the form template; cycles and self-edges are refused by
// ValidTaskDependency. // ValidTaskDependency.
$builder->add('dependencies', CollectionType::class, [ $builder->add('dependencies', CollectionType::class, [
'label' => 'mautic.program.task.field.dependencies', 'label' => 'mt3s.marketing_program.task.field.dependencies',
'entry_type' => TaskDependencyType::class, 'entry_type' => TaskDependencyType::class,
'entry_options' => ['label' => false, 'initiative' => $initiative, 'task' => $task], 'entry_options' => ['label' => false, 'program' => $program, 'task' => $task],
'allow_add' => true, 'allow_add' => true,
'allow_delete' => true, 'allow_delete' => true,
'by_reference' => false, 'by_reference' => false,
@@ -160,11 +160,11 @@ class TaskType extends AbstractType
'required' => false, 'required' => false,
]); ]);
// RACI: one row per role, several stakeholders per role, picked from the initiative's stakeholders. // RACI: one row per role, several stakeholders per role, picked from the program's stakeholders.
$builder->add('raci', CollectionType::class, [ $builder->add('raci', CollectionType::class, [
'label' => 'mautic.program.task.field.raci', 'label' => 'mt3s.marketing_program.task.field.raci',
'entry_type' => TaskRaciType::class, 'entry_type' => TaskRaciType::class,
'entry_options' => ['label' => false, 'initiative' => $initiative], 'entry_options' => ['label' => false, 'program' => $program],
'allow_add' => true, 'allow_add' => true,
'allow_delete' => true, 'allow_delete' => true,
'by_reference' => false, 'by_reference' => false,
@@ -189,6 +189,6 @@ class TaskType extends AbstractType
public function getBlockPrefix(): string public function getBlockPrefix(): string
{ {
return 'program_task'; return 'mt3s_marketing_program_task';
} }
} }
@@ -2,18 +2,18 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Integration; namespace MauticPlugin\MT3SMarketingProgramBundle\Integration;
use Mautic\IntegrationsBundle\Integration\BasicIntegration; use Mautic\IntegrationsBundle\Integration\BasicIntegration;
use Mautic\IntegrationsBundle\Integration\ConfigurationTrait; use Mautic\IntegrationsBundle\Integration\ConfigurationTrait;
use Mautic\IntegrationsBundle\Integration\Interfaces\BasicInterface; use Mautic\IntegrationsBundle\Integration\Interfaces\BasicInterface;
class ProgramIntegration extends BasicIntegration implements BasicInterface class MT3SMarketingProgramIntegration extends BasicIntegration implements BasicInterface
{ {
use ConfigurationTrait; use ConfigurationTrait;
public const NAME = 'Program'; public const NAME = 'MT3SMarketingProgram';
public const DISPLAY_NAME = 'Program'; public const DISPLAY_NAME = 'Marketing Programs';
public function getName(): string public function getName(): string
{ {
@@ -27,6 +27,6 @@ class ProgramIntegration extends BasicIntegration implements BasicInterface
public function getIcon(): string public function getIcon(): string
{ {
return 'plugins/ProgramBundle/Assets/img/icon.svg'; return 'plugins/MT3SMarketingProgramBundle/Assets/img/mt3s-mp-icon.svg';
} }
} }
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Integration\Support;
use Mautic\IntegrationsBundle\Integration\DefaultConfigFormTrait;
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormInterface;
use MauticPlugin\MT3SMarketingProgramBundle\Integration\MT3SMarketingProgramIntegration;
class MT3SMarketingProgramConfigSupport extends MT3SMarketingProgramIntegration implements ConfigFormInterface
{
use DefaultConfigFormTrait;
}
@@ -1,14 +0,0 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Integration\Support;
use Mautic\IntegrationsBundle\Integration\DefaultConfigFormTrait;
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormInterface;
use MauticPlugin\ProgramBundle\Integration\ProgramIntegration;
class ProgramConfigSupport extends ProgramIntegration implements ConfigFormInterface
{
use DefaultConfigFormTrait;
}
+11
View File
@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle;
use Mautic\IntegrationsBundle\Bundle\AbstractPluginBundle;
class MT3SMarketingProgramBundle extends AbstractPluginBundle
{
}
+3 -5
View File
@@ -2,12 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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\ProgramBundle\Entity\InitiativeObjective;
/** /**
* 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
@@ -28,11 +26,11 @@ class Version_0_10_0 extends AbstractMigration
protected function up(): void protected function up(): void
{ {
$objectives = $this->concatPrefix(InitiativeObjective::TABLE_NAME); $objectives = $this->concatPrefix('initiative_objectives');
$table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($objectives); $table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($objectives);
if (!$table->hasColumn('type')) { if (!$table->hasColumn('type')) {
$this->addSql(sprintf('ALTER TABLE %s ADD type VARCHAR(%d) DEFAULT NULL', $objectives, InitiativeObjective::TYPE_MAX_LENGTH)); $this->addSql(sprintf('ALTER TABLE %s ADD type VARCHAR(%d) DEFAULT NULL', $objectives, 64));
} }
} }
} }
+3 -5
View File
@@ -2,12 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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\ProgramBundle\Entity\InitiativeObjective;
/** /**
* 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
@@ -26,14 +24,14 @@ class Version_0_10_1 extends AbstractMigration
protected function up(): void protected function up(): void
{ {
$objectives = $this->concatPrefix(InitiativeObjective::TABLE_NAME); $objectives = $this->concatPrefix('initiative_objectives');
$table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($objectives); $table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($objectives);
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,
InitiativeObjective::PRIORITY_MIN 1
)); ));
} }
} }
+9 -11
View File
@@ -2,15 +2,13 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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;
use MauticPlugin\ProgramBundle\Entity\Audience; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\AudienceType as AudienceTypeEnum; use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceType as AudienceTypeEnum;
use MauticPlugin\ProgramBundle\Entity\Initiative;
/** /**
* 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
@@ -53,8 +51,8 @@ class Version_0_11_0 extends AbstractMigration
// An install created before 0.11.0 that somehow never got the tables: create the current // An install created before 0.11.0 that somehow never got the tables: create the current
// (0.15.0) ones from the entity mapping directly. // (0.15.0) ones from the entity mapping directly.
if (!$schema->hasTable($this->concatPrefix(Audience::TABLE_NAME))) { if (!$schema->hasTable($this->concatPrefix('initiative_audiences'))) {
$this->addSql($this->getCreateTableSql(Audience::TABLE_NAME)); $this->addSql($this->getCreateTableSql('initiative_audiences'));
} }
if (!$schema->hasTable($this->concatPrefix('initiative_audiences_stages')) if (!$schema->hasTable($this->concatPrefix('initiative_audiences_stages'))
@@ -65,7 +63,7 @@ class Version_0_11_0 extends AbstractMigration
foreach ($this->getColumnsToRename($schema) as $field => $column) { foreach ($this->getColumnsToRename($schema) as $field => $column) {
$this->addSql(sprintf( $this->addSql(sprintf(
'ALTER TABLE %s CHANGE %s %s', 'ALTER TABLE %s CHANGE %s %s',
$this->concatPrefix(Audience::TABLE_NAME), $this->concatPrefix('initiative_audiences'),
$field, $field,
$this->getColumnDefinition($field, $column) $this->getColumnDefinition($field, $column)
)); ));
@@ -77,11 +75,11 @@ class Version_0_11_0 extends AbstractMigration
*/ */
private function getColumnsToRename(Schema $schema): array private function getColumnsToRename(Schema $schema): array
{ {
if (!$schema->hasTable($this->concatPrefix(Audience::TABLE_NAME))) { if (!$schema->hasTable($this->concatPrefix('initiative_audiences'))) {
return []; return [];
} }
$table = $schema->getTable($this->concatPrefix(Audience::TABLE_NAME)); $table = $schema->getTable($this->concatPrefix('initiative_audiences'));
$rename = []; $rename = [];
foreach (self::COLUMNS as $field => $column) { foreach (self::COLUMNS as $field => $column) {
@@ -95,7 +93,7 @@ class Version_0_11_0 extends AbstractMigration
private function hasForeignKeys(Schema $schema): bool private function hasForeignKeys(Schema $schema): bool
{ {
$audiences = $this->concatPrefix(Audience::TABLE_NAME); $audiences = $this->concatPrefix('initiative_audiences');
if (!$schema->hasTable($audiences)) { if (!$schema->hasTable($audiences)) {
return false; return false;
+11 -13
View File
@@ -2,14 +2,12 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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;
use MauticPlugin\ProgramBundle\Entity\Initiative; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Entity\InitiativeStakeholder;
use MauticPlugin\ProgramBundle\Entity\Stakeholder;
/** /**
* Since 0.12.0 planning has a global stakeholder directory (table initiative_stakeholders), and each plan * Since 0.12.0 planning has a global stakeholder directory (table initiative_stakeholders), and each plan
@@ -33,26 +31,26 @@ class Version_0_12_0 extends AbstractMigration
{ {
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema(); $schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
if (!$schema->hasTable($this->concatPrefix(Stakeholder::TABLE_NAME))) { if (!$schema->hasTable($this->concatPrefix('initiative_stakeholders'))) {
$this->addSql($this->getCreateTableSql(Stakeholder::class, Stakeholder::TABLE_NAME)); $this->addSql($this->getCreateTableSql(Stakeholder::class, 'initiative_stakeholders'));
} }
if (!$schema->hasTable($this->concatPrefix(InitiativeStakeholder::TABLE_NAME))) { if (!$schema->hasTable($this->concatPrefix('initiative_stakeholders_initiative'))) {
$this->addSql($this->getCreateTableSql(InitiativeStakeholder::class, InitiativeStakeholder::TABLE_NAME)); $this->addSql($this->getCreateTableSql(InitiativeStakeholder::class, 'initiative_stakeholders_initiative'));
} }
if (!$this->hasForeignKeys($schema)) { if (!$this->hasForeignKeys($schema)) {
$this->addSql($this->generateAlterTableForeignKeyStatement( $this->addSql($this->generateAlterTableForeignKeyStatement(
InitiativeStakeholder::TABLE_NAME, 'initiative_stakeholders_initiative',
['plan_id'], ['plan_id'],
Initiative::TABLE_NAME, 'initiatives',
['id'], ['id'],
'ON DELETE CASCADE' 'ON DELETE CASCADE'
)); ));
$this->addSql($this->generateAlterTableForeignKeyStatement( $this->addSql($this->generateAlterTableForeignKeyStatement(
InitiativeStakeholder::TABLE_NAME, 'initiative_stakeholders_initiative',
['stakeholder_id'], ['stakeholder_id'],
Stakeholder::TABLE_NAME, 'initiative_stakeholders',
['id'], ['id'],
'ON DELETE CASCADE' 'ON DELETE CASCADE'
)); ));
@@ -64,7 +62,7 @@ class Version_0_12_0 extends AbstractMigration
*/ */
private function hasForeignKeys(Schema $schema): bool private function hasForeignKeys(Schema $schema): bool
{ {
$links = $this->concatPrefix(InitiativeStakeholder::TABLE_NAME); $links = $this->concatPrefix('initiative_stakeholders_initiative');
if (!$schema->hasTable($links)) { if (!$schema->hasTable($links)) {
return false; return false;
+12 -12
View File
@@ -2,14 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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;
use MauticPlugin\ProgramBundle\Entity\Task; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskDependency; use MauticPlugin\MT3SMarketingProgramBundle\Entity\TaskDependency;
use MauticPlugin\ProgramBundle\Entity\TaskRaci; use MauticPlugin\MT3SMarketingProgramBundle\Entity\TaskRaci;
/** /**
* Since 0.13.0 tasks are reworked: * Since 0.13.0 tasks are reworked:
@@ -35,7 +35,7 @@ class Version_0_13_0 extends AbstractMigration
protected function up(): void protected function up(): void
{ {
$tasks = $this->concatPrefix(Task::TABLE_NAME); $tasks = $this->concatPrefix('initiative_tasks');
$table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($tasks); $table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($tasks);
// New columns. // New columns.
@@ -43,7 +43,7 @@ class Version_0_13_0 extends AbstractMigration
$this->addSql(sprintf( $this->addSql(sprintf(
"ALTER TABLE %s ADD task_kind VARCHAR(20) NOT NULL DEFAULT '%s'", "ALTER TABLE %s ADD task_kind VARCHAR(20) NOT NULL DEFAULT '%s'",
$tasks, $tasks,
\MauticPlugin\ProgramBundle\Entity\TaskKind::Task->value \MauticPlugin\MT3SMarketingProgramBundle\Entity\TaskKind::Task->value
)); ));
} }
if (!$table->hasColumn('definition_of_done')) { if (!$table->hasColumn('definition_of_done')) {
@@ -71,20 +71,20 @@ class Version_0_13_0 extends AbstractMigration
} }
// New tables. Each is created when missing on its own, so a partial earlier run is repaired. // New tables. Each is created when missing on its own, so a partial earlier run is repaired.
if (!$this->introspectSchema()->hasTable($this->concatPrefix(TaskDependency::TABLE_NAME))) { if (!$this->introspectSchema()->hasTable($this->concatPrefix('initiative_task_dependencies'))) {
foreach ($this->getCreateTableSqls(TaskDependency::class, TaskDependency::TABLE_NAME) as $sql) { foreach ($this->getCreateTableSqls(TaskDependency::class, 'initiative_task_dependencies') as $sql) {
$this->addSql($sql); $this->addSql($sql);
} }
} }
if (!$this->introspectSchema()->hasTable($this->concatPrefix(TaskRaci::TABLE_NAME))) { if (!$this->introspectSchema()->hasTable($this->concatPrefix('initiative_task_raci'))) {
foreach ($this->getCreateTableSqls(TaskRaci::class, TaskRaci::TABLE_NAME) as $sql) { foreach ($this->getCreateTableSqls(TaskRaci::class, 'initiative_task_raci') as $sql) {
$this->addSql($sql); $this->addSql($sql);
} }
} }
// The RACI join table comes with the TaskRaci entity's SQL (CREATE TABLE initiative_task_raci_stakeholders), // The RACI join table comes with the TaskRaci entity's SQL (CREATE TABLE initiative_task_raci_stakeholders),
// but it may be missing while initiative_task_raci exists (a partial earlier run). // but it may be missing while initiative_task_raci exists (a partial earlier run).
if (!$this->introspectSchema()->hasTable($this->concatPrefix(TaskRaci::JOIN_TABLE_NAME))) { if (!$this->introspectSchema()->hasTable($this->concatPrefix('initiative_task_raci_stakeholders'))) {
foreach ($this->getCreateTableSqls(TaskRaci::class, TaskRaci::JOIN_TABLE_NAME) as $sql) { foreach ($this->getCreateTableSqls(TaskRaci::class, 'initiative_task_raci_stakeholders') as $sql) {
$this->addSql($sql); $this->addSql($sql);
} }
} }
+6 -9
View File
@@ -2,14 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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\ProgramBundle\Entity\Audience; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeAudience;
/** /**
* 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:
@@ -147,9 +144,9 @@ class Version_0_14_0 extends AbstractMigration
// core tables, such as plans, at install time). // core tables, such as plans, at install time).
if (!$this->hasForeignKeys($schema)) { if (!$this->hasForeignKeys($schema)) {
$this->addSql($this->generateAlterTableForeignKeyStatement( $this->addSql($this->generateAlterTableForeignKeyStatement(
$oldNaming ? 'initiative_audiences_initiative' : InitiativeAudience::TABLE_NAME, $oldNaming ? 'initiative_audiences_initiative' : 'initiative_audiences_initiative',
['plan_id'], ['plan_id'],
Initiative::TABLE_NAME, 'initiatives',
['id'], ['id'],
'ON DELETE CASCADE' 'ON DELETE CASCADE'
)); ));
@@ -166,7 +163,7 @@ class Version_0_14_0 extends AbstractMigration
private function getTableNames(Schema $schema): ?array private function getTableNames(Schema $schema): ?array
{ {
foreach ([ foreach ([
[Audience::TABLE_NAME, InitiativeAudience::TABLE_NAME], ['initiative_audiences', 'initiative_audiences_initiative'],
['initiative_audiences', 'initiative_audiences_initiative'], ['initiative_audiences', 'initiative_audiences_initiative'],
] as [$directory, $links]) { ] as [$directory, $links]) {
if ($schema->hasTable($this->concatPrefix($directory))) { if ($schema->hasTable($this->concatPrefix($directory))) {
@@ -184,7 +181,7 @@ class Version_0_14_0 extends AbstractMigration
*/ */
private function hasForeignKeys(Schema $schema): bool private function hasForeignKeys(Schema $schema): bool
{ {
foreach (['initiative_audiences_initiative', InitiativeAudience::TABLE_NAME] as $links) { foreach (['initiative_audiences_initiative', 'initiative_audiences_initiative'] as $links) {
$links = $this->concatPrefix($links); $links = $this->concatPrefix($links);
if (!$schema->hasTable($links)) { if (!$schema->hasTable($links)) {
+3 -5
View File
@@ -2,13 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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\ProgramBundle\Entity\Audience; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\Initiative;
/** /**
* 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),
@@ -23,7 +21,7 @@ class Version_0_15_0 extends AbstractMigration
{ {
protected function isApplicable(Schema $schema): bool protected function isApplicable(Schema $schema): bool
{ {
if (!$schema->hasTable($this->concatPrefix(Initiative::TABLE_NAME)) if (!$schema->hasTable($this->concatPrefix('initiatives'))
&& !$schema->hasTable($this->concatPrefix('plans'))) { && !$schema->hasTable($this->concatPrefix('plans'))) {
return false; return false;
} }
+2 -3
View File
@@ -2,14 +2,13 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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\ProgramBundle\Entity\Initiative;
/** /**
* Since 0.16.0 the PlanBundle is the ProgramBundle, and a plan is an initiative: the Planning * Since 0.16.0 the PlanBundle is the MT3SMarketingProgramBundle, and a plan is an initiative: the Planning
* menu is Programs, the Plans page is Initiatives. The database follows: * menu is Programs, the Plans page is Initiatives. The database follows:
* - plans becomes initiatives; * - plans becomes initiatives;
* - plan_objectives, plan_description_items, plan_allocation_items become initiative_*; * - plan_objectives, plan_description_items, plan_allocation_items become initiative_*;
+218
View File
@@ -0,0 +1,218 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
/**
* Since 0.17.0 the ProgramBundle is the MT3SMarketingProgramBundle, and an initiative is a marketing
* program: the Programs menu is Marketing Programs. The database follows:
* - initiatives becomes mt3s_mp_programs;
* - initiative_objectives, initiative_description_items, initiative_allocation_items become
* mt3s_mp_program_*;
* - initiative_tasks, initiative_task_dependencies, initiative_task_raci,
* initiative_task_raci_stakeholders become mt3s_mp_program_task_*;
* - initiative_stakeholders, initiative_stakeholders_initiative become mt3s_mp_program_stakeholders
* and mt3s_mp_program_stakeholders_program;
* - initiative_audiences, initiative_audiences_initiative, initiative_audiences_segments,
* initiative_audiences_stages become mt3s_mp_program_audiences*;
* - the link tables' initiative_id columns become program_id; the stakeholders link's
* role_in_initiative becomes role_in_program.
*
* The rows the rename orphans follow too: the plugins row (bundle ProgramBundle, kept as an update
* so the installer does not treat the plugin as new), the role permission rows (bundle program,
* name initiatives), the categories rows (bundle plan from before 0.16.0 or initiative since), and
* the audit log rows (bundle PlanBundle/ProgramBundle).
*
* Every statement runs immediately and re-reads the schema first, so the migration picks up again
* wherever an earlier run stopped (MySQL auto-commits DDL, so a failing batch of addSql() can
* leave the renames half done). A fresh install created by the plugin installer already uses the
* new names from the entity mapping.
*/
class Version_0_17_0 extends AbstractMigration
{
/**
* Old table name => new table name, in dependency order.
*/
private const TABLES = [
'initiatives' => 'mt3s_mp_programs',
'initiative_objectives' => 'mt3s_mp_program_objectives',
'initiative_description_items' => 'mt3s_mp_program_description_items',
'initiative_allocation_items' => 'mt3s_mp_program_allocation_items',
'initiative_tasks' => 'mt3s_mp_program_tasks',
'initiative_task_dependencies' => 'mt3s_mp_program_task_dependencies',
'initiative_task_raci' => 'mt3s_mp_program_task_raci',
'initiative_task_raci_stakeholders' => 'mt3s_mp_program_task_raci_stakeholders',
'initiative_stakeholders' => 'mt3s_mp_program_stakeholders',
'initiative_stakeholders_initiative' => 'mt3s_mp_program_stakeholders_program',
'initiative_audiences' => 'mt3s_mp_program_audiences',
'initiative_audiences_initiative' => 'mt3s_mp_program_audiences_program',
'initiative_audiences_segments' => 'mt3s_mp_program_audiences_segments',
'initiative_audiences_stages' => 'mt3s_mp_program_audiences_stages',
];
/**
* Table (any of its names) => [old column => new column, definition].
*/
private const COLUMNS = [
['initiative_objectives', 'mt3s_mp_program_objectives', 'initiative_id', 'program_id', 'INT UNSIGNED NOT NULL'],
['initiative_description_items', 'mt3s_mp_program_description_items', 'initiative_id', 'program_id', 'INT UNSIGNED NOT NULL'],
['initiative_allocation_items', 'mt3s_mp_program_allocation_items', 'initiative_id', 'program_id', 'INT UNSIGNED NOT NULL'],
['initiative_tasks', 'mt3s_mp_program_tasks', 'initiative_id', 'program_id', 'INT UNSIGNED NOT NULL'],
['initiative_stakeholders_initiative', 'mt3s_mp_program_stakeholders_program', 'initiative_id', 'program_id', 'INT UNSIGNED NOT NULL'],
['initiative_stakeholders_initiative', 'mt3s_mp_program_stakeholders_program', 'role_in_initiative', 'role_in_program', 'VARCHAR(191) DEFAULT NULL'],
['initiative_audiences_initiative', 'mt3s_mp_program_audiences_program', 'initiative_id', 'program_id', 'INT UNSIGNED NOT NULL'],
];
protected function isApplicable(Schema $schema): bool
{
foreach (self::TABLES as $from => $to) {
if ($schema->hasTable($this->concatPrefix($from))) {
return true;
}
}
foreach (self::COLUMNS as [$fromTable, $toTable, $fromColumn]) {
$table = $this->getTableName($schema, [$fromTable, $toTable]);
if (null !== $table) {
foreach ($schema->getTable($table)->getColumns() as $name => $column) {
if (strtolower($name) === strtolower($fromColumn)) {
return true;
}
}
}
}
// The pre-rename plugins row: the update target of an installed 0.16.0.
try {
$row = $this->entityManager->getConnection()->fetchOne(
sprintf("SELECT id FROM %s WHERE bundle = 'ProgramBundle'", $this->concatPrefix('plugins'))
);
} catch (\Throwable) {
$row = false;
}
return false !== $row;
}
protected function up(): void
{
// Tables, one rename at a time; stable database names unique.
foreach (self::TABLES as $from => $to) {
$this->renameTableIfExists($from, $to);
}
// Columns, resolving each table to whichever name it has now.
foreach (self::COLUMNS as [$fromTable, $toTable, $fromColumn, $toColumn, $definition]) {
$this->renameColumnIfExists([$fromTable, $toTable], $fromColumn, $toColumn, $definition);
}
$this->carryRowsOver();
}
/**
* The rows the rename orphans: the plugin's own, the roles' permissions, the categories and
* the audit log.
*/
private function carryRowsOver(): void
{
$connection = $this->entityManager->getConnection();
// The plugins row: keep the install an update of the same plugin, not a new one.
$oldBundle = $connection->fetchOne(
sprintf("SELECT id FROM %s WHERE bundle = 'ProgramBundle'", $this->concatPrefix('plugins'))
);
if (false !== $oldBundle) {
$connection->executeStatement(sprintf(
"UPDATE %s SET bundle = 'MT3SMarketingProgramBundle', name = 'MT3S Marketing Program' WHERE bundle = 'ProgramBundle'",
$this->concatPrefix('plugins')
));
}
// The roles' permission rows: the permission base follows the bundle name, and
// initiatives became programs (the 0.16.0 rename missed these).
$connection->executeStatement(sprintf(
"UPDATE %s SET name = 'programs' WHERE bundle = 'program' AND name = 'initiatives'",
$this->concatPrefix('permissions')
));
$connection->executeStatement(sprintf(
"UPDATE %s SET bundle = 'mt3smarketingprogram' WHERE bundle = 'program'",
$this->concatPrefix('permissions')
));
// The categories of the program category type (bundle column), plan-era rows included:
// the 0.16.0 rename left those behind too.
$connection->executeStatement(sprintf(
"UPDATE %s SET bundle = 'program' WHERE bundle IN ('plan', 'initiative')",
$this->concatPrefix('categories')
));
// The audit log rows about this plugin's entities.
$connection->executeStatement(sprintf(
"UPDATE %s SET bundle = 'MT3SMarketingProgramBundle' WHERE bundle IN ('PlanBundle', 'ProgramBundle')",
$this->concatPrefix('audit_logs')
));
}
/**
* Renames a table when the old name still exists and the new one doesn't.
*/
private function renameTableIfExists(string $from, string $to): void
{
$connection = $this->entityManager->getConnection();
if ($this->getTableName($connection->createSchemaManager()->introspectSchema(), [$from, $to]) === $this->concatPrefix($from)) {
$connection->executeStatement(sprintf(
'RENAME TABLE %1$s TO %2$s',
$this->concatPrefix($from),
$this->concatPrefix($to)
));
}
}
/**
* @param list<string> $tables the table's possible names, oldest first: the first that exists is used
*/
private function renameColumnIfExists(array $tables, string $fromColumn, string $toColumn, string $definition): void
{
$connection = $this->entityManager->getConnection();
$table = $this->getTableName($connection->createSchemaManager()->introspectSchema(), $tables);
if (null === $table) {
return;
}
foreach ($connection->createSchemaManager()->introspectTable($table)->getColumns() as $name => $column) {
if (strtolower($name) === strtolower($fromColumn)) {
$connection->executeStatement(sprintf(
'ALTER TABLE %s CHANGE %s %s %s',
$table,
$name,
$toColumn,
$definition
));
return;
}
}
}
/**
* The first of the given table names that exists, prefixed.
*
* @param list<string> $tables
*/
private function getTableName(Schema $schema, array $tables): ?string
{
foreach ($tables as $table) {
if ($schema->hasTable($this->concatPrefix($table))) {
return $this->concatPrefix($table);
}
}
return null;
}
}
+4 -6
View File
@@ -2,13 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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;
use MauticPlugin\ProgramBundle\Entity\Initiative;
/** /**
* Brings the plans table in line with the entity mapping. * Brings the plans table in line with the entity mapping.
* *
@@ -50,14 +48,14 @@ class Version_0_2_0 extends AbstractMigration
if ($this->statusNeedsResize($table)) { if ($this->statusNeedsResize($table)) {
$this->addSql(sprintf( $this->addSql(sprintf(
'ALTER TABLE %s MODIFY status VARCHAR(%d) NOT NULL', 'ALTER TABLE %s MODIFY status VARCHAR(%d) NOT NULL',
$this->concatPrefix(Initiative::TABLE_NAME), $this->concatPrefix('initiatives'),
self::STATUS_LENGTH self::STATUS_LENGTH
)); ));
} }
foreach ($this->getMissingForeignKeys($table) as $column => $referenceTable) { foreach ($this->getMissingForeignKeys($table) as $column => $referenceTable) {
$this->addSql($this->generateAlterTableForeignKeyStatement( $this->addSql($this->generateAlterTableForeignKeyStatement(
Initiative::TABLE_NAME, 'initiatives',
[$column], [$column],
$referenceTable, $referenceTable,
['id'], ['id'],
@@ -68,7 +66,7 @@ class Version_0_2_0 extends AbstractMigration
private function getTable(Schema $schema): ?Table private function getTable(Schema $schema): ?Table
{ {
$name = $this->concatPrefix(Initiative::TABLE_NAME); $name = $this->concatPrefix('initiatives');
return $schema->hasTable($name) ? $schema->getTable($name) : null; return $schema->hasTable($name) ? $schema->getTable($name) : null;
} }
+5 -8
View File
@@ -2,13 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeObjective;
/** /**
* 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.
* *
@@ -28,16 +25,16 @@ class Version_0_3_0 extends AbstractMigration
protected function up(): void protected function up(): void
{ {
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema(); $schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
$plans = $this->concatPrefix(Initiative::TABLE_NAME); $plans = $this->concatPrefix('initiatives');
$objectives = $this->concatPrefix(InitiativeObjective::TABLE_NAME); $objectives = $this->concatPrefix('initiative_objectives');
if (!$schema->getTable($plans)->hasColumn('version')) { if (!$schema->getTable($plans)->hasColumn('version')) {
$this->addSql("ALTER TABLE {$plans} ADD version SMALLINT UNSIGNED DEFAULT 1 NOT NULL"); $this->addSql("ALTER TABLE {$plans} ADD version SMALLINT UNSIGNED DEFAULT 1 NOT NULL");
} }
if (!$schema->hasTable($objectives)) { if (!$schema->hasTable($objectives)) {
$index = $this->generatePropertyName(InitiativeObjective::TABLE_NAME, 'idx', ['plan_id']); $index = $this->generatePropertyName('initiative_objectives', 'idx', ['plan_id']);
$foreignKey = $this->generatePropertyName(InitiativeObjective::TABLE_NAME, 'fk', ['plan_id']); $foreignKey = $this->generatePropertyName('initiative_objectives', 'fk', ['plan_id']);
$this->addSql("CREATE TABLE {$objectives} ( $this->addSql("CREATE TABLE {$objectives} (
id INT UNSIGNED AUTO_INCREMENT NOT NULL, id INT UNSIGNED AUTO_INCREMENT NOT NULL,
+7 -8
View File
@@ -2,14 +2,13 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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 Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\SchemaTool;
use Mautic\IntegrationsBundle\Migration\AbstractMigration; use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\ProgramBundle\Entity\Initiative; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\Task;
/** /**
* Adds the initiative_tasks table and its foreign keys to installs created before 0.4.0. * Adds the initiative_tasks table and its foreign keys to installs created before 0.4.0.
@@ -31,7 +30,7 @@ class Version_0_4_0 extends AbstractMigration
* so only plan_id is repaired here. * so only plan_id is repaired here.
*/ */
private const FOREIGN_KEYS = [ private const FOREIGN_KEYS = [
'plan_id' => [Initiative::TABLE_NAME, 'CASCADE'], 'plan_id' => ['initiatives', 'CASCADE'],
]; ];
protected function isApplicable(Schema $schema): bool protected function isApplicable(Schema $schema): bool
@@ -46,7 +45,7 @@ class Version_0_4_0 extends AbstractMigration
protected function up(): void protected function up(): void
{ {
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema(); $schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
$tasks = $this->concatPrefix(Task::TABLE_NAME); $tasks = $this->concatPrefix('initiative_tasks');
$missingFk = self::FOREIGN_KEYS; $missingFk = self::FOREIGN_KEYS;
if (!$schema->hasTable($tasks)) { if (!$schema->hasTable($tasks)) {
@@ -57,7 +56,7 @@ class Version_0_4_0 extends AbstractMigration
foreach ($missingFk as $column => [$referenceTable, $onDelete]) { foreach ($missingFk as $column => [$referenceTable, $onDelete]) {
$this->addSql($this->generateAlterTableForeignKeyStatement( $this->addSql($this->generateAlterTableForeignKeyStatement(
Task::TABLE_NAME, 'initiative_tasks',
[$column], [$column],
$referenceTable, $referenceTable,
['id'], ['id'],
@@ -69,7 +68,7 @@ class Version_0_4_0 extends AbstractMigration
private function getCreateTableSql(): string private function getCreateTableSql(): string
{ {
$schemaTool = new SchemaTool($this->entityManager); $schemaTool = new SchemaTool($this->entityManager);
$prefix = 'CREATE TABLE '.$this->concatPrefix(Task::TABLE_NAME).' '; $prefix = 'CREATE TABLE '.$this->concatPrefix('initiative_tasks').' ';
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(Task::class)]) as $sql) { foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(Task::class)]) as $sql) {
if (str_starts_with($sql, $prefix)) { if (str_starts_with($sql, $prefix)) {
@@ -77,7 +76,7 @@ class Version_0_4_0 extends AbstractMigration
} }
} }
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.Task::TABLE_NAME.'.'); throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.'initiative_tasks'.'.');
} }
/** /**
+4 -4
View File
@@ -2,12 +2,12 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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\ProgramBundle\Entity\Task; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskStatus; use MauticPlugin\MT3SMarketingProgramBundle\Entity\TaskStatus;
/** /**
* Adds start_date, end_date and status (default "new", indexed) to initiative_tasks, for installs created * Adds start_date, end_date and status (default "new", indexed) to initiative_tasks, for installs created
@@ -28,7 +28,7 @@ class Version_0_5_0 extends AbstractMigration
protected function up(): void protected function up(): void
{ {
$tasks = $this->concatPrefix(Task::TABLE_NAME); $tasks = $this->concatPrefix('initiative_tasks');
$table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($tasks); $table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($tasks);
if (!$table->hasColumn('start_date')) { if (!$table->hasColumn('start_date')) {
+8 -11
View File
@@ -2,14 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeDescriptionItem;
/** /**
* 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);
@@ -33,8 +30,8 @@ class Version_0_6_0 extends AbstractMigration
protected function up(): void protected function up(): void
{ {
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema(); $schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
$plans = $this->concatPrefix(Initiative::TABLE_NAME); $plans = $this->concatPrefix('initiatives');
$items = $this->concatPrefix(InitiativeDescriptionItem::TABLE_NAME); $items = $this->concatPrefix('initiative_description_items');
if (!$schema->hasTable($items)) { if (!$schema->hasTable($items)) {
$this->addSql($this->getCreateTableSql()); $this->addSql($this->getCreateTableSql());
@@ -42,9 +39,9 @@ class Version_0_6_0 extends AbstractMigration
if (!$schema->hasTable($items) || !$this->hasPlanForeignKey($schema)) { if (!$schema->hasTable($items) || !$this->hasPlanForeignKey($schema)) {
$this->addSql($this->generateAlterTableForeignKeyStatement( $this->addSql($this->generateAlterTableForeignKeyStatement(
InitiativeDescriptionItem::TABLE_NAME, 'initiative_description_items',
['plan_id'], ['plan_id'],
Initiative::TABLE_NAME, 'initiatives',
['id'], ['id'],
'ON DELETE CASCADE' 'ON DELETE CASCADE'
)); ));
@@ -57,7 +54,7 @@ class Version_0_6_0 extends AbstractMigration
private function hasPlanForeignKey(Schema $schema): bool private function hasPlanForeignKey(Schema $schema): bool
{ {
$items = $this->concatPrefix(InitiativeDescriptionItem::TABLE_NAME); $items = $this->concatPrefix('initiative_description_items');
if (!$schema->hasTable($items)) { if (!$schema->hasTable($items)) {
return false; return false;
@@ -75,7 +72,7 @@ class Version_0_6_0 extends AbstractMigration
private function getCreateTableSql(): string private function getCreateTableSql(): string
{ {
$schemaTool = new SchemaTool($this->entityManager); $schemaTool = new SchemaTool($this->entityManager);
$prefix = 'CREATE TABLE '.$this->concatPrefix(InitiativeDescriptionItem::TABLE_NAME).' '; $prefix = 'CREATE TABLE '.$this->concatPrefix('initiative_description_items').' ';
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(InitiativeDescriptionItem::class)]) as $sql) { foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(InitiativeDescriptionItem::class)]) as $sql) {
if (str_starts_with($sql, $prefix)) { if (str_starts_with($sql, $prefix)) {
@@ -83,6 +80,6 @@ class Version_0_6_0 extends AbstractMigration
} }
} }
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.InitiativeDescriptionItem::TABLE_NAME.'.'); throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.'initiative_description_items'.'.');
} }
} }
+7 -10
View File
@@ -2,14 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeAllocationItem;
/** /**
* 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
@@ -29,7 +26,7 @@ class Version_0_7_0 extends AbstractMigration
protected function up(): void protected function up(): void
{ {
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema(); $schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
$items = $this->concatPrefix(InitiativeAllocationItem::TABLE_NAME); $items = $this->concatPrefix('initiative_allocation_items');
if (!$schema->hasTable($items)) { if (!$schema->hasTable($items)) {
$this->addSql($this->getCreateTableSql()); $this->addSql($this->getCreateTableSql());
@@ -37,9 +34,9 @@ class Version_0_7_0 extends AbstractMigration
if (!$this->hasPlanForeignKey($schema)) { if (!$this->hasPlanForeignKey($schema)) {
$this->addSql($this->generateAlterTableForeignKeyStatement( $this->addSql($this->generateAlterTableForeignKeyStatement(
InitiativeAllocationItem::TABLE_NAME, 'initiative_allocation_items',
['plan_id'], ['plan_id'],
Initiative::TABLE_NAME, 'initiatives',
['id'], ['id'],
'ON DELETE CASCADE' 'ON DELETE CASCADE'
)); ));
@@ -48,7 +45,7 @@ class Version_0_7_0 extends AbstractMigration
private function hasPlanForeignKey(Schema $schema): bool private function hasPlanForeignKey(Schema $schema): bool
{ {
$items = $this->concatPrefix(InitiativeAllocationItem::TABLE_NAME); $items = $this->concatPrefix('initiative_allocation_items');
if (!$schema->hasTable($items)) { if (!$schema->hasTable($items)) {
return false; return false;
@@ -66,7 +63,7 @@ class Version_0_7_0 extends AbstractMigration
private function getCreateTableSql(): string private function getCreateTableSql(): string
{ {
$schemaTool = new SchemaTool($this->entityManager); $schemaTool = new SchemaTool($this->entityManager);
$prefix = 'CREATE TABLE '.$this->concatPrefix(InitiativeAllocationItem::TABLE_NAME).' '; $prefix = 'CREATE TABLE '.$this->concatPrefix('initiative_allocation_items').' ';
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(InitiativeAllocationItem::class)]) as $sql) { foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(InitiativeAllocationItem::class)]) as $sql) {
if (str_starts_with($sql, $prefix)) { if (str_starts_with($sql, $prefix)) {
@@ -74,6 +71,6 @@ class Version_0_7_0 extends AbstractMigration
} }
} }
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.InitiativeAllocationItem::TABLE_NAME.'.'); throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.'initiative_allocation_items'.'.');
} }
} }
+3 -6
View File
@@ -2,13 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeAllocationItem;
/** /**
* 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,
@@ -21,8 +18,8 @@ class Version_0_8_0 extends AbstractMigration
* Table => columns to drop. * Table => columns to drop.
*/ */
private const COLUMNS = [ private const COLUMNS = [
Initiative::TABLE_NAME => ['currency'], 'initiatives' => ['currency'],
InitiativeAllocationItem::TABLE_NAME => ['planned_currency', 'real_currency'], 'initiative_allocation_items' => ['planned_currency', 'real_currency'],
]; ];
protected function isApplicable(Schema $schema): bool protected function isApplicable(Schema $schema): bool
+3 -3
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations; 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\ProgramBundle\Entity\Task; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Task;
/** /**
* Since 0.9.0 tasks have a type, the key of a task type set up in Settings > Configuration > Plan * Since 0.9.0 tasks have a type, the key of a task type set up in Settings > Configuration > Plan
@@ -27,7 +27,7 @@ class Version_0_9_0 extends AbstractMigration
protected function up(): void protected function up(): void
{ {
$tasks = $this->concatPrefix(Task::TABLE_NAME); $tasks = $this->concatPrefix('initiative_tasks');
$table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($tasks); $table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($tasks);
if (!$table->hasColumn('type')) { if (!$table->hasColumn('type')) {
+8 -8
View File
@@ -2,22 +2,22 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Model; namespace MauticPlugin\MT3SMarketingProgramBundle\Model;
use Mautic\CoreBundle\Model\FormModel; use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\ProgramBundle\Entity\Audience; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\AudienceRepository; use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceRepository;
use MauticPlugin\ProgramBundle\Form\Type\AudienceType; use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\AudienceType;
use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/** /**
* Available as mautic.program.model.audience, or getModel('program.audience'). * Available as mt3s.marketing_program.model.audience, or getModel('mt3smp.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 InitiativeAudience (which carries the audience's priority in * them from their Audiences tab through ProgramAudience (which carries the audience's priority in
* that initiative). * that program).
*/ */
class AudienceModel extends FormModel class AudienceModel extends FormModel
{ {
@@ -31,7 +31,7 @@ class AudienceModel extends FormModel
public function getPermissionBase(): string public function getPermissionBase(): string
{ {
return 'program:audiences'; return 'mt3smarketingprogram:audiences';
} }
public function getEntity($id = null): ?Audience public function getEntity($id = null): ?Audience
-77
View File
@@ -1,77 +0,0 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Model;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeRepository;
use MauticPlugin\ProgramBundle\Form\Type\InitiativeType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* @extends FormModel<Initiative>
*/
class InitiativeModel extends FormModel
{
public function getRepository(): InitiativeRepository
{
$repository = $this->em->getRepository(Initiative::class);
\assert($repository instanceof InitiativeRepository);
return $repository;
}
public function getPermissionBase(): string
{
return 'program:initiatives';
}
/**
* With no ID, returns a new initiative with the current user as owner.
*/
public function getEntity($id = null): ?Initiative
{
if (null === $id) {
$initiative = new Initiative();
$initiative->setOwner($this->userHelper->getUser(true));
return $initiative;
}
$initiative = parent::getEntity($id);
return $initiative instanceof Initiative ? $initiative : null;
}
/**
* Keeps objective and description item positions contiguous (0..n-1) before saving.
*/
public function saveEntity($entity, $unlock = true): void
{
if ($entity instanceof Initiative) {
$entity->normalizePositions();
}
parent::saveEntity($entity, $unlock);
}
/**
* @param array<string, mixed> $options
*/
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
{
if (!$entity instanceof Initiative) {
throw new MethodNotAllowedHttpException(['Initiative']);
}
if (!empty($action)) {
$options['action'] = $action;
}
return $formFactory->create(InitiativeType::class, $entity, $options);
}
}
+113
View File
@@ -0,0 +1,113 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Model;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\ProgramRepository;
use MauticPlugin\MT3SMarketingProgramBundle\Event\MT3SMarketingProgramEvents;
use MauticPlugin\MT3SMarketingProgramBundle\Event\ProgramEvent;
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\ProgramType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* @extends FormModel<Program>
*/
class ProgramModel extends FormModel
{
public function getRepository(): ProgramRepository
{
$repository = $this->em->getRepository(Program::class);
\assert($repository instanceof ProgramRepository);
return $repository;
}
public function getPermissionBase(): string
{
return 'mt3smarketingprogram:programs';
}
/**
* With no ID, returns a new program with the current user as owner.
*/
public function getEntity($id = null): ?Program
{
if (null === $id) {
$program = new Program();
$program->setOwner($this->userHelper->getUser(true));
return $program;
}
$program = parent::getEntity($id);
return $program instanceof Program ? $program : null;
}
/**
* Keeps objective and description item positions contiguous (0..n-1) before saving, and
* dispatches the plugin's pre/post save events (created vs updated by the entity's ID).
*/
public function saveEntity($entity, $unlock = true): void
{
if ($entity instanceof Program) {
$isNew = null === $entity->getId();
$this->dispatcher->dispatch(new ProgramEvent($entity, $isNew), MT3SMarketingProgramEvents::PROGRAM_PRE_SAVE);
$entity->normalizePositions();
parent::saveEntity($entity, $unlock);
$this->dispatcher->dispatch(new ProgramEvent($entity, $isNew), MT3SMarketingProgramEvents::PROGRAM_POST_SAVE);
$this->dispatcher->dispatch(
new ProgramEvent($entity, $isNew),
$isNew ? MT3SMarketingProgramEvents::PROGRAM_CREATED : MT3SMarketingProgramEvents::PROGRAM_UPDATED
);
return;
}
parent::saveEntity($entity, $unlock);
}
/**
* Dispatches the plugin's delete events around the removal.
*/
public function deleteEntity($entity): void
{
if ($entity instanceof Program) {
$this->dispatcher->dispatch(new ProgramEvent($entity, false), MT3SMarketingProgramEvents::PROGRAM_PRE_DELETE);
parent::deleteEntity($entity);
$this->dispatcher->dispatch(new ProgramEvent($entity, false), MT3SMarketingProgramEvents::PROGRAM_POST_DELETE);
$this->dispatcher->dispatch(new ProgramEvent($entity, false), MT3SMarketingProgramEvents::PROGRAM_DELETED);
return;
}
parent::deleteEntity($entity);
}
/**
* @param array<string, mixed> $options
*/
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
{
if (!$entity instanceof Program) {
throw new MethodNotAllowedHttpException(['Program']);
}
if (!empty($action)) {
$options['action'] = $action;
}
return $formFactory->create(ProgramType::class, $entity, $options);
}
}
+8 -8
View File
@@ -2,24 +2,24 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Model; namespace MauticPlugin\MT3SMarketingProgramBundle\Model;
use libphonenumber\NumberParseException; use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumberFormat; use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberUtil; use libphonenumber\PhoneNumberUtil;
use Mautic\CoreBundle\Model\FormModel; use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\ProgramBundle\Entity\Stakeholder; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Entity\StakeholderRepository; use MauticPlugin\MT3SMarketingProgramBundle\Entity\StakeholderRepository;
use MauticPlugin\ProgramBundle\Form\Type\StakeholderType; use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\StakeholderType;
use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/** /**
* Available as mautic.program.model.stakeholder, or getModel('program.stakeholder'). * Available as mt3s.marketing_program.model.stakeholder, or getModel('mt3smp.stakeholder').
* *
* On save, the phone number is normalized to E.164 using the default region from Settings > * On save, the phone number is normalized to E.164 using the default region from Settings >
* Configuration > Initiative Settings (parameter program_stakeholder_phone_region, FR by default). A number that * Configuration > Program Settings (parameter mt3s_marketing_program_stakeholder_phone_region, FR by default). A number that
* doesn't parse (free input, extensions…) is kept exactly as typed: the save is never blocked. * doesn't parse (free input, extensions…) is kept exactly as typed: the save is never blocked.
*/ */
class StakeholderModel extends FormModel class StakeholderModel extends FormModel
@@ -27,7 +27,7 @@ class StakeholderModel extends FormModel
/** /**
* local.php parameter: default region for phone numbers typed without a country prefix. * local.php parameter: default region for phone numbers typed without a country prefix.
*/ */
public const PHONE_REGION_PARAMETER = 'program_stakeholder_phone_region'; public const PHONE_REGION_PARAMETER = 'mt3s_marketing_program_stakeholder_phone_region';
public const DEFAULT_PHONE_REGION = 'FR'; public const DEFAULT_PHONE_REGION = 'FR';
@@ -41,7 +41,7 @@ class StakeholderModel extends FormModel
public function getPermissionBase(): string public function getPermissionBase(): string
{ {
return 'program:stakeholders'; return 'mt3smarketingprogram:stakeholders';
} }
public function getEntity($id = null): ?Stakeholder public function getEntity($id = null): ?Stakeholder
+10 -10
View File
@@ -2,19 +2,19 @@
declare(strict_types=1); declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Model; namespace MauticPlugin\MT3SMarketingProgramBundle\Model;
use Mautic\CoreBundle\Model\FormModel; use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\ProgramBundle\Entity\Initiative; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Program;
use MauticPlugin\ProgramBundle\Entity\Task; use MauticPlugin\MT3SMarketingProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskRepository; use MauticPlugin\MT3SMarketingProgramBundle\Entity\TaskRepository;
use MauticPlugin\ProgramBundle\Form\Type\TaskType; use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\TaskType;
use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/** /**
* Available as mautic.program.model.task, or getModel('program.task'). * Available as mt3s.marketing_program.model.task, or getModel('mt3smp.task').
* *
* @extends FormModel<Task> * @extends FormModel<Task>
*/ */
@@ -30,7 +30,7 @@ class TaskModel extends FormModel
public function getPermissionBase(): string public function getPermissionBase(): string
{ {
return 'program:tasks'; return 'mt3smarketingprogram:tasks';
} }
public function getEntity($id = null): ?Task public function getEntity($id = null): ?Task
@@ -45,16 +45,16 @@ class TaskModel extends FormModel
} }
/** /**
* The plan's tasks as rows for the initiative's Tasks tab: the tasks ordered by name, each with its * The plan's tasks as rows for the program's Tasks tab: the tasks ordered by name, each with its
* dependencies and RACI rows loaded. The former parent/child tree is gone; the tab lists the * dependencies and RACI rows loaded. The former parent/child tree is gone; the tab lists the
* tasks flat, and the dependencies are shown per task. * tasks flat, and the dependencies are shown per task.
* *
* @return array<int, array{task: Task, depth: int}> * @return array<int, array{task: Task, depth: int}>
*/ */
public function getTaskTree(Initiative $initiative): array public function getTaskTree(Program $program): array
{ {
$rows = []; $rows = [];
foreach ($this->getRepository()->findByInitiative($initiative) as $task) { foreach ($this->getRepository()->findByProgram($program) as $task) {
$rows[] = ['task' => $task, 'depth' => 0]; $rows[] = ['task' => $task, 'depth' => 0];
} }
-11
View File
@@ -1,11 +0,0 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle;
use Mautic\IntegrationsBundle\Bundle\AbstractPluginBundle;
class ProgramBundle extends AbstractPluginBundle
{
}
+43 -43
View File
@@ -1,18 +1,18 @@
{% extends '@MauticCore/Default/content.html.twig' %} {% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}programAudience{% endblock %} {% block mauticContent %}mt3sMpProgramAudience{% endblock %}
{% block preHeader %} {% block preHeader %}
<div class="pull-right"> <div class="pull-right">
{{ include('@MauticCore/Helper/page_actions.html.twig', { {{ include('@MauticCore/Helper/page_actions.html.twig', {
'item': item, 'item': item,
'templateButtons': { 'templateButtons': {
'edit': securityHasEntityAccess(permissions['program:audiences:editown'], permissions['program:audiences:editother'], item.createdBy), 'edit': securityHasEntityAccess(permissions['mt3smarketingprogram:audiences:editown'], permissions['mt3smarketingprogram:audiences:editother'], item.createdBy),
'delete': securityHasEntityAccess(permissions['program:audiences:deleteown'], permissions['program:audiences:deleteother'], item.createdBy), 'delete': securityHasEntityAccess(permissions['mt3smarketingprogram:audiences:deleteown'], permissions['mt3smarketingprogram:audiences:deleteother'], item.createdBy),
}, },
'actionRoute': 'initiative_audience_action', 'actionRoute': 'mt3s_marketing_program_audience_action',
'indexRoute': 'initiative_audience_index', 'indexRoute': 'mt3s_marketing_program_audience_index',
'langVar': 'initiative.audience', 'langVar': 'program.audience',
}) }} }) }}
</div> </div>
{% endblock %} {% endblock %}
@@ -22,103 +22,103 @@
{% block publishStatus %} {% block publishStatus %}
<div class="col-xs-0 col-sm-3 text-right pr-0"> <div class="col-xs-0 col-sm-3 text-right pr-0">
<span class="label {{ item.isPublished ? 'label-success' : 'label-gray' }}"> <span class="label {{ item.isPublished ? 'label-success' : 'label-gray' }}">
{{ (item.isPublished ? 'mautic.program.audience.active' : 'mautic.program.audience.inactive')|trans }} {{ (item.isPublished ? 'mt3s.marketing_program.audience.active' : 'mt3s.marketing_program.audience.inactive')|trans }}
</span> </span>
</div> </div>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="pa-md"> <div class="pa-md">
<table class="table table-hover mb-md initiative-audience-details"> <table class="table table-hover mb-md program-audience-details">
<tbody> <tbody>
<tr> <tr>
<td class="col-md-3 text-muted" style="width: 30%;">{{ 'mautic.program.audience.field.type'|trans }}</td> <td class="col-md-3 text-muted" style="width: 30%;">{{ 'mt3s.marketing_program.audience.field.type'|trans }}</td>
<td> <td>
<i class="{{ item.audienceType.icon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i> <i class="{{ item.audienceType.icon }} program-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>
{{ item.audienceType.labelKey|trans }} {{ item.audienceType.labelKey|trans }}
</td> </td>
</tr> </tr>
{% if item.segments is not empty %} {% if item.segments is not empty %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.segments'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.segments'|trans }}</td>
<td> <td>
{% for segment in item.segments %} {% for segment in item.segments %}
<span class="label label-info">{{ segment.name }} ({{ program_audience_segment_count(segment.id) }})</span>{% if not loop.last %} {% endif %} <span class="label label-info">{{ segment.name }} ({{ mt3s_marketing_program_audience_segment_count(segment.id) }})</span>{% if not loop.last %} {% endif %}
{% endfor %} {% endfor %}
</td> </td>
</tr> </tr>
{% endif %} {% endif %}
{% if item.tagline %} {% if item.tagline %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.tagline'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.tagline'|trans }}</td>
<td>{{ item.tagline|program_linkify }}</td> <td>{{ item.tagline|mt3s_marketing_program_linkify }}</td>
</tr> </tr>
{% endif %} {% endif %}
{% if item.profileCriteria %} {% if item.profileCriteria %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.profile_criteria'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.profile_criteria'|trans }}</td>
<td style="white-space: pre-wrap;">{{ item.profileCriteria|program_linkify }}</td> <td style="white-space: pre-wrap;">{{ item.profileCriteria|mt3s_marketing_program_linkify }}</td>
</tr> </tr>
{% endif %} {% endif %}
{% if item.motivations %} {% if item.motivations %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.motivations'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.motivations'|trans }}</td>
<td style="white-space: pre-wrap;">{{ item.motivations|program_linkify }}</td> <td style="white-space: pre-wrap;">{{ item.motivations|mt3s_marketing_program_linkify }}</td>
</tr> </tr>
{% endif %} {% endif %}
{% if item.barriers %} {% if item.barriers %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.barriers'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.barriers'|trans }}</td>
<td style="white-space: pre-wrap;">{{ item.barriers|program_linkify }}</td> <td style="white-space: pre-wrap;">{{ item.barriers|mt3s_marketing_program_linkify }}</td>
</tr> </tr>
{% endif %} {% endif %}
{% if item.frustrations %} {% if item.frustrations %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.frustrations'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.frustrations'|trans }}</td>
<td style="white-space: pre-wrap;">{{ item.frustrations|program_linkify }}</td> <td style="white-space: pre-wrap;">{{ item.frustrations|mt3s_marketing_program_linkify }}</td>
</tr> </tr>
{% endif %} {% endif %}
{% if item.triggers %} {% if item.triggers %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.triggers'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.triggers'|trans }}</td>
<td style="white-space: pre-wrap;">{{ item.triggers|program_linkify }}</td> <td style="white-space: pre-wrap;">{{ item.triggers|mt3s_marketing_program_linkify }}</td>
</tr> </tr>
{% endif %} {% endif %}
{% if item.decisionRole %} {% if item.decisionRole %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.decision_role'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.decision_role'|trans }}</td>
<td>{{ program_audience_decision_role_label(item.decisionRole) ?? item.decisionRole }}</td> <td>{{ mt3s_marketing_program_audience_decision_role_label(item.decisionRole) ?? item.decisionRole }}</td>
</tr> </tr>
{% endif %} {% endif %}
{% if item.preferredTones is not empty %} {% if item.preferredTones is not empty %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.preferred_tones'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.preferred_tones'|trans }}</td>
<td> <td>
{% for tone in item.preferredTones %} {% for tone in item.preferredTones %}
<span class="label label-default">{{ program_audience_tone_label(tone) ?? tone }}</span> <span class="label label-default">{{ mt3s_marketing_program_audience_tone_label(tone) ?? tone }}</span>
{% endfor %} {% endfor %}
</td> </td>
</tr> </tr>
{% endif %} {% endif %}
{% if item.preferredChannels is not empty %} {% if item.preferredChannels is not empty %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.preferred_channels'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.preferred_channels'|trans }}</td>
<td> <td>
{% for channel in item.preferredChannels %} {% for channel in item.preferredChannels %}
<span class="label label-default">{{ program_audience_channel_label(channel)|trans }}</span> <span class="label label-default">{{ mt3s_marketing_program_audience_channel_label(channel)|trans }}</span>
{% endfor %} {% endfor %}
</td> </td>
</tr> </tr>
{% endif %} {% endif %}
{% if item.stages is not empty %} {% if item.stages is not empty %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.stages'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.stages'|trans }}</td>
<td>{{ item.stages|map(stage => stage.name)|join(', ') }}</td> <td>{{ item.stages|map(stage => stage.name)|join(', ') }}</td>
</tr> </tr>
{% endif %} {% endif %}
{% if item.estimatedSize %} {% if item.estimatedSize %}
<tr> <tr>
<td class="text-muted">{{ 'mautic.program.audience.field.estimated_size'|trans }}</td> <td class="text-muted">{{ 'mt3s.marketing_program.audience.field.estimated_size'|trans }}</td>
<td>{{ item.estimatedSize }}</td> <td>{{ item.estimatedSize }}</td>
</tr> </tr>
{% endif %} {% endif %}
@@ -133,27 +133,27 @@
</tbody> </tbody>
</table> </table>
<h4 class="mb-sm">{{ 'mautic.program.audience.field.plans'|trans }}</h4> <h4 class="mb-sm">{{ 'mt3s.marketing_program.audience.field.plans'|trans }}</h4>
{% if item.initiativeLinks is empty %} {% if item.programLinks is empty %}
<p class="text-muted">{{ 'mautic.program.audience.no_plans'|trans }}</p> <p class="text-muted">{{ 'mt3s.marketing_program.audience.no_plans'|trans }}</p>
{% else %} {% else %}
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover initiative-audience-initiatives-view"> <table class="table table-hover program-audience-programs-view">
<thead> <thead>
<tr> <tr>
<th>{{ 'mautic.program.field.name'|trans }}</th> <th>{{ 'mt3s.marketing_program.field.name'|trans }}</th>
<th>{{ 'mautic.program.audience.field.priority'|trans }}</th> <th>{{ 'mt3s.marketing_program.audience.field.priority'|trans }}</th>
<th>{{ 'mautic.program.audience.field.value_proposition'|trans }}</th> <th>{{ 'mt3s.marketing_program.audience.field.value_proposition'|trans }}</th>
<th>{{ 'mautic.program.field.status'|trans }}</th> <th>{{ 'mt3s.marketing_program.field.status'|trans }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for link in item.initiativeLinks %} {% for link in item.programLinks %}
<tr> <tr>
<td><a href="{{ path('initiative_action', {'objectAction': 'view', 'objectId': link.initiative.id}) }}" data-toggle="ajax">{{ link.initiative.name }}</a></td> <td><a href="{{ path('mt3s_marketing_program_action', {'objectAction': 'view', 'objectId': link.program.id}) }}" data-toggle="ajax">{{ link.program.name }}</a></td>
<td><span class="label {{ link.priority.labelClass }}">{{ link.priority.labelKey|trans }}</span></td> <td><span class="label {{ link.priority.labelClass }}">{{ link.priority.labelKey|trans }}</span></td>
<td class="text-muted">{{ link.valueProposition|default('—') }}</td> <td class="text-muted">{{ link.valueProposition|default('—') }}</td>
<td><span class="label {{ link.initiative.status.labelClass }}">{{ link.initiative.status.labelKey|trans }}</span></td> <td><span class="label {{ link.program.status.labelClass }}">{{ link.program.status.labelKey|trans }}</span></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
+8 -8
View File
@@ -1,12 +1,12 @@
{% extends '@MauticCore/Default/content.html.twig' %} {% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}programAudience{% endblock %} {% block mauticContent %}mt3sMpProgramAudience{% endblock %}
{% block headerTitle %} {% block headerTitle %}
{% if entity.id %} {% if entity.id %}
{{ 'mautic.program.audience.header.edit'|trans({'%name%': entity.name}) }} {{ 'mt3s.marketing_program.audience.header.edit'|trans({'%name%': entity.name}) }}
{% else %} {% else %}
{{ 'mautic.program.audience.header.new'|trans }} {{ 'mt3s.marketing_program.audience.header.new'|trans }}
{% endif %} {% endif %}
{% endblock %} {% endblock %}
@@ -17,18 +17,18 @@
<div class="pa-md"> <div class="pa-md">
{{ form_row(form.name) }} {{ form_row(form.name) }}
<div class="row"> <div class="row">
{# The selected type's pictogram, fixed per type; programAudienceOnLoad updates it {# The selected type's pictogram, fixed per type; mt3sMpProgramAudienceOnLoad updates it
when the dropdown changes. A new form defaults to Persona. #} when the dropdown changes. A new form defaults to Persona. #}
<div class="col-xs-1 text-center pt-lg"> <div class="col-xs-1 text-center pt-lg">
<i class="{{ (entity.audienceType ?? constant('MauticPlugin\\ProgramBundle\\Entity\\AudienceType::Persona'))|program_audience_type_icon }} initiative-item-type-icon" style="font-size: 28px;" aria-hidden="true"></i> <i class="{{ (entity.audienceType ?? constant('MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\AudienceType::Persona'))|mt3s_marketing_program_audience_type_icon }} program-item-type-icon" style="font-size: 28px;" aria-hidden="true"></i>
</div> </div>
<div class="col-xs-11"> <div class="col-xs-11">
{{ form_row(form.audienceType) }} {{ form_row(form.audienceType) }}
<p class="text-muted small">{{ 'mautic.program.audience.type.fixed_note'|trans }}</p> <p class="text-muted small">{{ 'mt3s.marketing_program.audience.type.fixed_note'|trans }}</p>
</div> </div>
</div> </div>
{{ form_row(form.segments) }} {{ form_row(form.segments) }}
<p class="text-muted small">{{ 'mautic.program.audience.segments.note'|trans }}</p> <p class="text-muted small">{{ 'mt3s.marketing_program.audience.segments.note'|trans }}</p>
{% if form.tagline is defined %}{{ form_row(form.tagline) }}{% endif %} {% if form.tagline is defined %}{{ form_row(form.tagline) }}{% endif %}
{% if form.profileCriteria is defined %}{{ form_row(form.profileCriteria) }}{% endif %} {% if form.profileCriteria is defined %}{{ form_row(form.profileCriteria) }}{% endif %}
{% if form.motivations is defined %}{{ form_row(form.motivations) }}{% endif %} {% if form.motivations is defined %}{{ form_row(form.motivations) }}{% endif %}
@@ -45,7 +45,7 @@
<div class="col-md-3 height-auto"> <div class="col-md-3 height-auto">
<div class="pr-lg pl-lg pt-md pb-md"> <div class="pr-lg pl-lg pt-md pb-md">
{{ form_row(form.isPublished) }} {{ form_row(form.isPublished) }}
<p class="text-muted small">{{ 'mautic.program.audience.active.help'|trans }}</p> <p class="text-muted small">{{ 'mt3s.marketing_program.audience.active.help'|trans }}</p>
</div> </div>
</div> </div>
</div> </div>
+48 -48
View File
@@ -2,110 +2,110 @@
{% set tmpl = 'list' %} {% set tmpl = 'list' %}
{% extends isIndex ? '@MauticCore/Default/content.html.twig' : '@MauticCore/Default/raw_output.html.twig' %} {% extends isIndex ? '@MauticCore/Default/content.html.twig' : '@MauticCore/Default/raw_output.html.twig' %}
{% block mauticContent %}programAudience{% endblock %} {% block mauticContent %}mt3sMpProgramAudience{% endblock %}
{% block headerTitle %}{{ 'mautic.program.audience.header.index'|trans }}{% endblock %} {% block headerTitle %}{{ 'mt3s.marketing_program.audience.header.index'|trans }}{% endblock %}
{% block content %} {% block content %}
{% set segmentCounts = program_audience_segment_counts(items) %} {% set segmentCounts = mt3s_marketing_program_audience_segment_counts(items) %}
<div id="page-list-wrapper" class="{% if items|length > 0 or searchValue is not empty %}panel {% endif %}panel-default"> <div id="page-list-wrapper" class="{% if items|length > 0 or searchValue is not empty %}panel {% endif %}panel-default">
{{- include('@MauticCore/Helper/list_toolbar.html.twig', { {{- include('@MauticCore/Helper/list_toolbar.html.twig', {
'searchValue': searchValue, 'searchValue': searchValue,
'action': currentRoute, 'action': currentRoute,
'page_actions': { 'page_actions': {
'templateButtons': { 'templateButtons': {
'new': permissions['program:audiences:create'], 'new': permissions['mt3smarketingprogram:audiences:create'],
}, },
'langVar': 'initiative.audience', 'langVar': 'program.audience',
}, },
'bulk_actions': { 'bulk_actions': {
'langVar': 'initiative.audience', 'langVar': 'program.audience',
'templateButtons': { 'templateButtons': {
'delete': permissions['program:audiences:deleteown'] or permissions['program:audiences:deleteother'], 'delete': permissions['mt3smarketingprogram:audiences:deleteown'] or permissions['mt3smarketingprogram:audiences:deleteother'],
}, },
}, },
}) -}} }) -}}
<div class="page-list"> <div class="page-list">
{% if items is defined and items is not empty %} {% if items is defined and items is not empty %}
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover" id="programAudienceTable"> <table class="table table-hover" id="mt3sMpProgramAudienceTable">
<thead> <thead>
<tr> <tr>
{{ include('@MauticCore/Helper/tableheader.html.twig', { {{ include('@MauticCore/Helper/tableheader.html.twig', {
'checkall': 'true', 'checkall': 'true',
'target': '#programAudienceTable', 'target': '#mt3sMpProgramAudienceTable',
}) }} }) }}
{# Columns: ID, Pictogram, Type, Name (+ tagline), Segments (with contact {# Columns: ID, Pictogram, Type, Name (+ tagline), Segments (with contact
counts), Estimated size, Active, Assigned initiatives. #} counts), Estimated size, Active, Assigned programs. #}
{{ include('@MauticCore/Helper/tableheader.html.twig', { {{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience', 'sessionVar': 'program.audience',
'orderBy': 't.id', 'orderBy': 't.id',
'text': 'mautic.core.id', 'text': 'mautic.core.id',
'class': 'col-initiative-audience-id', 'class': 'col-program-audience-id',
}) }} }) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', { {{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience', 'sessionVar': 'program.audience',
'text': 'mautic.program.audience.field.pictogram', 'text': 'mt3s.marketing_program.audience.field.pictogram',
'class': 'col-initiative-audience-pictogram', 'class': 'col-program-audience-pictogram',
}) }} }) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', { {{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience', 'sessionVar': 'program.audience',
'orderBy': 't.audienceType', 'orderBy': 't.audienceType',
'text': 'mautic.program.audience.field.type', 'text': 'mt3s.marketing_program.audience.field.type',
'class': 'col-initiative-audience-type', 'class': 'col-program-audience-type',
}) }} }) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', { {{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience', 'sessionVar': 'program.audience',
'orderBy': 't.name', 'orderBy': 't.name',
'text': 'mautic.program.audience.field.name', 'text': 'mt3s.marketing_program.audience.field.name',
'class': 'col-initiative-audience-name', 'class': 'col-program-audience-name',
'default': true, 'default': true,
}) }} }) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', { {{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience', 'sessionVar': 'program.audience',
'text': 'mautic.program.audience.field.segments', 'text': 'mt3s.marketing_program.audience.field.segments',
'class': 'visible-md visible-lg col-initiative-audience-segments', 'class': 'visible-md visible-lg col-program-audience-segments',
}) }} }) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', { {{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience', 'sessionVar': 'program.audience',
'text': 'mautic.program.audience.field.estimated_size', 'text': 'mt3s.marketing_program.audience.field.estimated_size',
'class': 'visible-md visible-lg col-initiative-audience-size', 'class': 'visible-md visible-lg col-program-audience-size',
}) }} }) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', { {{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience', 'sessionVar': 'program.audience',
'orderBy': 't.isPublished', 'orderBy': 't.isPublished',
'text': 'mautic.program.audience.field.active', 'text': 'mt3s.marketing_program.audience.field.active',
'class': 'col-initiative-audience-active', 'class': 'col-program-audience-active',
}) }} }) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', { {{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience', 'sessionVar': 'program.audience',
'text': 'mautic.program.audience.field.plans', 'text': 'mt3s.marketing_program.audience.field.plans',
'class': 'visible-md visible-lg col-initiative-audience-initiatives', 'class': 'visible-md visible-lg col-program-audience-programs',
}) }} }) }}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for item in items %} {% for item in items %}
{% set canEdit = securityHasEntityAccess(permissions['program:audiences:editown'], permissions['program:audiences:editother'], item.createdBy) %} {% set canEdit = securityHasEntityAccess(permissions['mt3smarketingprogram:audiences:editown'], permissions['mt3smarketingprogram:audiences:editother'], item.createdBy) %}
<tr> <tr>
<td> <td>
{{- include('@MauticCore/Helper/list_actions.html.twig', { {{- include('@MauticCore/Helper/list_actions.html.twig', {
'item': item, 'item': item,
'templateButtons': { 'templateButtons': {
'edit': canEdit, 'edit': canEdit,
'delete': securityHasEntityAccess(permissions['program:audiences:deleteown'], permissions['program:audiences:deleteother'], item.createdBy), 'delete': securityHasEntityAccess(permissions['mt3smarketingprogram:audiences:deleteown'], permissions['mt3smarketingprogram:audiences:deleteother'], item.createdBy),
}, },
'langVar': 'initiative.audience', 'langVar': 'program.audience',
}) -}} }) -}}
</td> </td>
<td>{{ item.id }}</td> <td>{{ item.id }}</td>
<td class="text-center"> <td class="text-center">
<i class="{{ item.audienceType.icon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i> <i class="{{ item.audienceType.icon }} program-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>
</td> </td>
<td>{{ item.audienceType.labelKey|trans }}</td> <td>{{ item.audienceType.labelKey|trans }}</td>
<td> <td>
{% if canEdit %} {% if canEdit %}
<a href="{{ path('initiative_audience_action', {'objectAction': 'edit', 'objectId': item.id}) }}" data-toggle="ajax">{% if item.tagline %}{{ item.name }} <span class="text-muted small font-lato">— {{ item.tagline }}</span>{% else %}{{ item.name }}{% endif %}</a> <a href="{{ path('mt3s_marketing_program_audience_action', {'objectAction': 'edit', 'objectId': item.id}) }}" data-toggle="ajax">{% if item.tagline %}{{ item.name }} <span class="text-muted small font-lato">— {{ item.tagline }}</span>{% else %}{{ item.name }}{% endif %}</a>
{% else %} {% else %}
{{ item.name }}{% if item.tagline %} <span class="text-muted small font-lato">— {{ item.tagline }}</span>{% endif %} {{ item.name }}{% if item.tagline %} <span class="text-muted small font-lato">— {{ item.tagline }}</span>{% endif %}
{% endif %} {% endif %}
@@ -123,16 +123,16 @@
<td class="visible-md visible-lg text-right text-nowrap">{{ item.estimatedSize }}</td> <td class="visible-md visible-lg text-right text-nowrap">{{ item.estimatedSize }}</td>
<td> <td>
<span class="label {{ item.isPublished ? 'label-success' : 'label-gray' }}"> <span class="label {{ item.isPublished ? 'label-success' : 'label-gray' }}">
{{ (item.isPublished ? 'mautic.program.audience.active' : 'mautic.program.audience.inactive')|trans }} {{ (item.isPublished ? 'mt3s.marketing_program.audience.active' : 'mt3s.marketing_program.audience.inactive')|trans }}
</span> </span>
</td> </td>
<td class="visible-md visible-lg"> <td class="visible-md visible-lg">
{# The initiatives this audience is assigned to, through their Audiences tab. #} {# The programs this audience is assigned to, through their Audiences tab. #}
{% set links = item.initiativeLinks|default([]) %} {% set links = item.programLinks|default([]) %}
{% for link in links %} {% for link in links %}
<a href="{{ path('initiative_action', {'objectAction': 'view', 'objectId': link.initiative.id}) }}" data-toggle="ajax">{{ link.initiative.name }}</a>{% if link.valueProposition %} <span class="text-muted small">({{ link.valueProposition }})</span>{% endif %}{% if not loop.last %}, {% endif %} <a href="{{ path('mt3s_marketing_program_action', {'objectAction': 'view', 'objectId': link.program.id}) }}" data-toggle="ajax">{{ link.program.name }}</a>{% if link.valueProposition %} <span class="text-muted small">({{ link.valueProposition }})</span>{% endif %}{% if not loop.last %}, {% endif %}
{% else %} {% else %}
<span class="text-muted">{{ 'mautic.program.audience.no_plans'|trans }}</span> <span class="text-muted">{{ 'mt3s.marketing_program.audience.no_plans'|trans }}</span>
{% endfor %} {% endfor %}
</td> </td>
</tr> </tr>
@@ -144,8 +144,8 @@
'totalItems': totalItems, 'totalItems': totalItems,
'page': page, 'page': page,
'limit': limit, 'limit': limit,
'baseUrl': path('initiative_audience_index'), 'baseUrl': path('mt3s_marketing_program_audience_index'),
'sessionVar': 'initiative.audience', 'sessionVar': 'program.audience',
}) -}} }) -}}
</div> </div>
</div> </div>
@@ -154,9 +154,9 @@
{% else %} {% else %}
<div class="mt-80 col-md-offset-2 col-lg-offset-3 col-md-8 col-lg-5 height-auto"> <div class="mt-80 col-md-offset-2 col-lg-offset-3 col-md-8 col-lg-5 height-auto">
{{ include('@MauticCore/Components/content-block.html.twig', { {{ include('@MauticCore/Components/content-block.html.twig', {
'heading': 'mautic.program.audience.onboarding.heading', 'heading': 'mt3s.marketing_program.audience.onboarding.heading',
'subheading': 'mautic.program.audience.onboarding.subheading', 'subheading': 'mt3s.marketing_program.audience.onboarding.subheading',
'copy': 'mautic.program.audience.onboarding.copy', 'copy': 'mt3s.marketing_program.audience.onboarding.copy',
}) }} }) }}
</div> </div>
{% endif %} {% endif %}
@@ -0,0 +1,24 @@
{#
# Settings > Configuration > Program Settings: the plugin's general settings only — the currency,
# the stakeholder phone region, and the audience attribute toggles. The item type lists moved to
# their own page under Programs (ItemTypesController, Resources/views/ItemTypes/form.html.twig).
#}
{% block _config_mt3smarketingprogramconfig_widget %}
<div class="text-muted small pb-md">{{ 'mt3s.marketing_program.config.description'|trans }}</div>
<h4 class="fw-sb mb-xs">{{ 'mt3s.marketing_program.config.section.general'|trans }}</h4>
<div class="row">
<div class="col-md-6">{{ form_row(form.children.mt3s_marketing_program_currency) }}</div>
<div class="col-md-6">{{ form_row(form.children.mt3s_marketing_program_stakeholder_phone_region) }}</div>
</div>
<p class="text-muted small">{{ 'mt3s.marketing_program.config.currency.help'|trans }}</p>
<h4 class="fw-sb mt-lg mb-xs">{{ 'mt3s.marketing_program.config.section.audience_attributes'|trans }}</h4>
<p class="text-muted small">{{ 'mt3s.marketing_program.config.section.audience_attributes.help'|trans }}</p>
<div class="program-config-audience-attributes">
{% for attribute in mt3s_marketing_program_audience_attributes() %}
{{ form_row(form.children[mt3s_marketing_program_audience_attribute_toggle(attribute)]) }}
{% endfor %}
</div>
{% endblock %}
@@ -1,24 +0,0 @@
{#
# Settings > Configuration > Program Settings: the plugin's general settings only — the currency,
# the stakeholder phone region, and the audience attribute toggles. The item type lists moved to
# their own page under Programs (ItemTypesController, Resources/views/ItemTypes/form.html.twig).
#}
{% block _config_programconfig_widget %}
<div class="text-muted small pb-md">{{ 'mautic.program.config.description'|trans }}</div>
<h4 class="fw-sb mb-xs">{{ 'mautic.program.config.section.general'|trans }}</h4>
<div class="row">
<div class="col-md-6">{{ form_row(form.children.program_currency) }}</div>
<div class="col-md-6">{{ form_row(form.children.program_stakeholder_phone_region) }}</div>
</div>
<p class="text-muted small">{{ 'mautic.program.config.currency.help'|trans }}</p>
<h4 class="fw-sb mt-lg mb-xs">{{ 'mautic.program.config.section.audience_attributes'|trans }}</h4>
<p class="text-muted small">{{ 'mautic.program.config.section.audience_attributes.help'|trans }}</p>
<div class="program-config-audience-attributes">
{% for attribute in program_audience_attributes() %}
{{ form_row(form.children[program_audience_attribute_toggle(attribute)]) }}
{% endfor %}
</div>
{% endblock %}
@@ -1,11 +0,0 @@
{#
# The filter box of an initiative tab table (Description, Objectives, Allocation, Tasks) and the switch that
# shows the "no match" message. Filtering and sorting are handled by Assets/js/program.js
# (Mautic.programInitTabTable), on any table with the data-initiative-tab-table attribute.
#}
<div class="initiative-tab-table-filter input-group input-group-sm mb-xs" style="max-width: 300px;">
<span class="input-group-addon"><i class="ri-search-line"></i></span>
<input type="text" class="form-control initiative-tab-table-filter-input"
placeholder="{{ 'mautic.program.filter.placeholder'|trans }}" aria-label="{{ 'mautic.program.filter.placeholder'|trans }}">
</div>
<p class="text-muted initiative-tab-table-nomatch hide">{{ 'mautic.program.filter.no_match'|trans }}</p>
@@ -1,32 +0,0 @@
{#
# Tab bar shared by the initiative form and the initiative detail page.
#
# Parameters:
# initiativeId: the initiative's id (null for a new initiative)
# counts (optional): tab id => number shown next to the tab name
#
# The tab panes use the ids initiative-tab-<id>. Assets/js/program.js reopens the tab last used for this plan
# (so Edit, Save and Cancel keep the same tab), and on the form marks the tabs whose pane contains a
# validation error and opens the first of them.
#}
{% set initiativeTabs = {
'details': 'mautic.program.tab.details',
'description': 'mautic.program.tab.description',
'objectives': 'mautic.program.tab.objectives',
'allocation': 'mautic.program.tab.allocations',
'audiences': 'mautic.program.tab.audiences',
'stakeholders': 'mautic.program.tab.stakeholders',
'tasks': 'mautic.program.tab.tasks',
} %}
<ul class="nav nav-tabs nav-tabs-contained tabs-horizontal initiative-tabs" role="tablist" data-initiative-id="{{ initiativeId|default('') }}">
{% for id, label in initiativeTabs %}
<li class="{{ loop.first ? 'active' : '' }}" data-tab-id="initiative-tab-{{ id }}">
<a href="#initiative-tab-{{ id }}" role="tab" data-toggle="tab">
<span>{{ label|trans }}</span>
{% if counts is defined and counts[id] is defined %}
<span class="badge">{{ counts[id] }}</span>
{% endif %}
</a>
</li>
{% endfor %}
</ul>
@@ -1,93 +0,0 @@
{#
# The initiative's tasks, for the Tasks tab of the initiative detail page and form. Same harmonized columns as the
# other tabs: Pictogram (no label), Type, Name, Description, Start date, End date, Status (last). No ID
# column. Rows are in tree order: each task is followed by its sub-tasks, indented under it.
#
# Parameters:
# initiative: the Initiative
# taskTree: rows from TaskModel::getTaskTree(): {task, depth}, in display order
# readOnly: true on the initiative form: no links, no filter, so that following one can't drop unsaved changes
# taskPermissions: program:tasks:* permissions (create, editown, editother), when not read-only
#
# Links carry returnTo=initiative, so that Save and Cancel on the task form come back to this initiative page
# (see TaskController). Opened from Programs > Tasks, the task form goes back to the task list.
#}
{% set readOnly = readOnly|default(false) %}
{% set taskPermissions = taskPermissions|default({}) %}
{% set canCreate = not readOnly and initiative.id and taskPermissions['program:tasks:create']|default(false) %}
{% if canCreate %}
<div class="mb-md">
<a class="btn btn-ghost initiative-task-add" href="{{ path('initiative_task_action', {'objectAction': 'new', 'initiative': initiative.id, 'returnTo': 'initiative'}) }}" data-toggle="ajax">
<i class="ri-add-line"></i> {{ 'mautic.program.task.add'|trans }}
</a>
</div>
{% endif %}
{% if not initiative.id %}
<p class="text-muted">{{ 'mautic.program.task.save_initiative_first'|trans }}</p>
{% elseif taskTree is empty %}
<p class="text-muted">{{ 'mautic.program.task.empty'|trans }}</p>
{% else %}
{% if not readOnly %}
{# Filter + click-to-sort on the detail page (program.js). The form's read-only copy stays plain. #}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
{% endif %}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-task-table{% if not readOnly %}" data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}{% endif %}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.task.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.task.field.type'|trans }}</th>
<th class="initiative-col-name">{{ 'mautic.program.task.field.name'|trans }}</th>
<th class="initiative-col-description">{{ 'mautic.program.task.field.description'|trans }}</th>
<th class="initiative-col-date">{{ 'mautic.program.task.field.start_date'|trans }}</th>
<th class="initiative-col-date">{{ 'mautic.program.task.field.end_date'|trans }}</th>
<th class="initiative-col-status">{{ 'mautic.program.task.field.status'|trans }}</th>
</tr>
</thead>
<tbody>
{% for row in taskTree %}
{% set task = row.task %}
{% set canEdit = not readOnly and securityHasEntityAccess(taskPermissions['program:tasks:editown']|default(false), taskPermissions['program:tasks:editother']|default(false), task.createdBy) %}
<tr class="initiative-task" data-task-id="{{ task.id }}">
<td class="initiative-col-pictogram text-center">
{% set taskTypeIcon = program_item_type_icon('task', task.type) %}
{% if taskTypeIcon %}<i class="{{ taskTypeIcon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="initiative-col-type"{% if program_item_type_description('task', task.type) %} title="{{ program_item_type_description('task', task.type) }}" data-toggle="tooltip"{% endif %}>
{{ program_item_type_name('task', task.type) ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': task.type}) }}
</td>
<td class="initiative-col-name">
{% if canEdit %}
<a href="{{ path('initiative_task_action', {'objectAction': 'edit', 'objectId': task.id, 'returnTo': 'initiative'}) }}" data-toggle="ajax">{{ task.name }}</a>
{% else %}
{{ task.name }}
{% endif %}
{% if task.taskKind == constant('MauticPlugin\\ProgramBundle\\Entity\\TaskKind::Milestone') %}
<span class="label label-success" title="{{ 'mautic.program.task.kind.milestone'|trans }}">{{ 'mautic.program.task.kind.milestone_short'|trans }}</span>
{% elseif task.taskKind == constant('MauticPlugin\\ProgramBundle\\Entity\\TaskKind::Phase') %}
<span class="label label-primary" title="{{ 'mautic.program.task.kind.phase'|trans }}">{{ 'mautic.program.task.kind.phase_short'|trans }}</span>
{% endif %}
</td>
<td class="initiative-col-description text-muted">
{# Same 10-line clamp and read-more as the Description tab; URLs become links. #}
{{ include('@Program/Initiative/_description_read_more.html.twig', {
'text': task.description|default('')|striptags,
'id': 'initiative-task-desc-' ~ task.id,
}) }}
</td>
<td class="initiative-col-date">{{ task.startDate ? task.startDate|date('Y-m-d') : '' }}</td>
<td class="initiative-col-date">{{ task.endDate ? task.endDate|date('Y-m-d') : '' }}</td>
<td class="initiative-col-status">
{# A phase has no status of its own — skip the column value. #}
{% if task.taskKind != constant('MauticPlugin\\ProgramBundle\\Entity\\TaskKind::Phase') %}
<span class="label {{ task.status.labelClass }}">{{ task.status.labelKey|trans }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
@@ -1,449 +0,0 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}program{% endblock %}
{#
# No routeBase on the page_actions includes: core would turn it into mautic_program_* route names.
# The buttons use actionRoute (initiative_action) from the controller, and the close button gets its URL here.
#}
{% block preHeader %}
{{- include('@MauticCore/Helper/page_actions.html.twig', {
'item': item,
'templateButtons': {
'close': true,
},
'closeUrl': path('initiative_index'),
'targetLabel': 'mautic.program.header.index'|trans,
}) -}}
{# Core's helper renders an empty pill when there is no category. #}
{% if item.category %}
{{ include('@MauticCore/Modules/category--inline.html.twig', {'category': item.category}) }}
{% endif %}
{% endblock %}
{% block headerTitle %}{{ item.name }}{% endblock %}
{#
# Under the title, as on an email's page: the plan status, then the total planned and real costs of the
# allocation items, in the general currency. A real total above the planned total is red, otherwise green.
#}
{% block publishStatus %}
{% set statusColors = {
'draft': 'warm-gray', 'planned': 'blue', 'active': 'green',
'paused': 'warning', 'completed': 'teal', 'archived': 'cool-gray',
} %}
{% include '@MauticCore/Helper/_tag.html.twig' with { tags: [{
color: statusColors[item.status.value]|default('gray'),
label: item.status.labelKey,
icon: 'ri-flag-line',
attributes: {'class': 'initiative-status-tag'},
}] } %}
{% set totals = item.allocationTotals %}
{% if totals.planned is not null or totals.real is not null %}
<div class="label__divider"></div>
{% set totalTags = [] %}
{% if totals.planned is not null %}
{% set totalTags = totalTags|merge([{
color: 'high-contrast',
icon: 'ri-wallet-3-line',
label: 'mautic.program.header.total_planned'|trans({'%amount%': program_money(totals.planned), '%currency%': program_currency()}),
attributes: {'class': 'initiative-total-planned', 'title': 'mautic.program.header.total_planned.tooltip'|trans, 'data-toggle': 'tooltip'},
}]) %}
{% endif %}
{% if totals.real is not null %}
{% set overPlan = totals.planned is not null and (totals.real + 0) > (totals.planned + 0) %}
{% set totalTags = totalTags|merge([{
color: overPlan ? 'red' : 'green',
icon: overPlan ? 'ri-error-warning-line' : 'ri-checkbox-circle-line',
label: 'mautic.program.header.total_real'|trans({'%amount%': program_money(totals.real), '%currency%': program_currency()}),
attributes: {'class': 'initiative-total-real', 'title': (overPlan ? 'mautic.program.header.total_real.over' : 'mautic.program.header.total_real.tooltip')|trans, 'data-toggle': 'tooltip'},
}]) %}
{% endif %}
{% include '@MauticCore/Helper/_tag.html.twig' with { tags: totalTags } %}
{% endif %}
{% endblock %}
{% block actions %}
{{- include('@MauticCore/Helper/page_actions.html.twig', {
'item': item,
'templateButtons': {
'edit': securityHasEntityAccess(permissions['program:initiatives:editown'], permissions['program:initiatives:editother'], item.createdBy),
'delete': securityHasEntityAccess(permissions['program:initiatives:deleteown'], permissions['program:initiatives:deleteother'], item.createdBy),
},
'langVar': 'initiative',
}) -}}
{% endblock %}
{% block content %}
{% set objectives = item.objectives %}
{% set achievedCount = objectives|filter(o => o.achieved)|length %}
{% set descriptionItems = item.descriptionItems %}
{% set allocationItems = item.allocationItems %}
{% set allocationTotals = item.allocationTotals %}
{{ include('@Program/Initiative/_tabs.html.twig', {'initiativeId': item.id, 'counts': {
'description': descriptionItems|length,
'objectives': objectives|length,
'allocation': allocationItems|length,
'audiences': item.audiences|length,
'stakeholders': item.stakeholders|length,
'tasks': taskTree|length,
}}) }}
<div class="tab-content pa-md">
{# Details #}
<div class="tab-pane active bdr-w-0" id="initiative-tab-details" role="tabpanel">
<table class="table table-hover mb-0 initiative-details">
<tbody>
<tr>
<td class="col-md-3 text-muted">{{ 'mautic.program.field.status'|trans }}</td>
<td>{{ item.status.labelKey|trans }}</td>
</tr>
{% if item.completedAt %}
<tr>
<td class="text-muted">{{ 'mautic.program.field.completed_at'|trans }}</td>
<td>{{ dateToFull(item.completedAt) }}</td>
</tr>
{% endif %}
<tr>
<td class="text-muted">{{ 'mautic.program.field.version'|trans }}</td>
<td>{{ item.version }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.program.field.owner'|trans }}</td>
<td>{{ item.owner ? item.owner.name : 'mautic.program.owner.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.program.field.start_date'|trans }}</td>
<td>{{ item.startDate ? dateToFull(item.startDate) : 'mautic.program.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.program.field.end_date'|trans }}</td>
<td>{{ item.endDate ? dateToFull(item.endDate) : 'mautic.program.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.category'|trans }}</td>
<td>{{ item.category ? item.category.title : 'mautic.program.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.form.available'|trans }}</td>
<td>{{ (item.isPublished ? 'mautic.core.form.yes' : 'mautic.core.form.no')|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.created'|trans }}</td>
<td>{{ item.dateAdded ? dateToFull(item.dateAdded) : '' }}{% if item.createdByUser %} ({{ item.createdByUser }}){% endif %}</td>
</tr>
{% if item.dateModified %}
<tr>
<td class="text-muted">{{ 'mautic.core.modified'|trans }}</td>
<td>{{ dateToFull(item.dateModified) }}{% if item.modifiedByUser %} ({{ item.modifiedByUser }}){% endif %}</td>
</tr>
{% endif %}
<tr>
<td class="text-muted">{{ 'mautic.core.id'|trans }}</td>
<td>{{ item.id }}</td>
</tr>
</tbody>
</table>
</div>
{# Description #}
<div class="tab-pane bdr-w-0" id="initiative-tab-description" role="tabpanel">
{% if descriptionItems is empty %}
<p class="text-muted">{{ 'mautic.program.description_item.empty'|trans }}</p>
{% else %}
{# Harmonized columns: Pictogram (no label), Type, Description. Description items have no
name of their own, so the Name column is left out here. Filter + click-to-sort (program.js). #}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-description-items-view"
data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.description_item.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.description_item.field.type'|trans }}</th>
<th class="initiative-col-description">{{ 'mautic.program.description_item.field.description'|trans }}</th>
</tr>
</thead>
<tbody>
{% for descriptionItem in descriptionItems %}
{% set typeName = program_item_type_name('description', descriptionItem.type) %}
{% set typeDescription = program_item_type_description('description', descriptionItem.type) %}
{% set typeIcon = program_item_type_icon('description', descriptionItem.type) %}
<tr>
<td class="initiative-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="initiative-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': descriptionItem.type}) }}
</td>
<td class="initiative-col-description">
{{ include('@Program/Initiative/_description_read_more.html.twig', {
'text': descriptionItem.description,
'id': 'initiative-desc-item-' ~ descriptionItem.id,
}) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Objectives #}
<div class="tab-pane bdr-w-0" id="initiative-tab-objectives" role="tabpanel">
{% if objectives is empty %}
<p class="text-muted">{{ 'mautic.program.objective.empty'|trans }}</p>
{% else %}
<p class="text-muted initiative-objectives-progress">
{{ 'mautic.program.objective.progress'|trans({'%achieved%': achievedCount, '%total%': objectives|length}) }}
</p>
{# Harmonized columns: Pictogram (no label), Type, Name (title), Description, Priority,
Status (achieved). Filter + click-to-sort (program.js). #}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-objectives-view"
data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.objective.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.objective.field.type'|trans }}</th>
<th class="initiative-col-name">{{ 'mautic.program.objective.field.name'|trans }}</th>
<th class="initiative-col-description">{{ 'mautic.program.objective.field.description'|trans }}</th>
<th class="initiative-col-priority">{{ 'mautic.program.objective.field.priority'|trans }}</th>
<th class="initiative-col-status">{{ 'mautic.program.objective.field.is_achieved'|trans }}</th>
</tr>
</thead>
<tbody>
{% for objective in objectives %}
{% set typeName = program_item_type_name('objective', objective.type) %}
{% set typeDescription = program_item_type_description('objective', objective.type) %}
{% set typeIcon = program_item_type_icon('objective', objective.type) %}
<tr>
<td class="initiative-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="initiative-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': objective.type}) }}
</td>
<td class="initiative-col-name">{{ objective.title }}</td>
<td class="initiative-col-description text-muted" style="white-space: pre-wrap;">{{ objective.description|program_linkify }}</td>
<td class="initiative-col-priority">{{ objective.priority ?? '—' }}</td>
<td class="initiative-col-status">
{% if objective.achieved %}
<span class="label label-success"><i class="ri-checkbox-circle-fill" title="{{ 'mautic.program.objective.achieved'|trans }}"></i> {{ 'mautic.program.objective.achieved'|trans }}</span>
{% else %}
<span class="label label-default"><i class="ri-checkbox-blank-circle-line" title="{{ 'mautic.program.objective.not_achieved'|trans }}"></i> {{ 'mautic.program.objective.not_achieved'|trans }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Allocation: the initiative's budget, then the allocation items (cost lines) with their totals. #}
<div class="tab-pane bdr-w-0" id="initiative-tab-allocation" role="tabpanel">
<table class="table table-hover mb-md initiative-allocation">
<tbody>
<tr>
<td class="col-md-3 text-muted">{{ 'mautic.program.field.budget_planned'|trans }}</td>
<td>
{% if item.budgetPlanned is not null %}
{{ program_money(item.budgetPlanned) }} {{ program_currency() }}
{% else %}
{{ 'mautic.program.value.none'|trans }}
{% endif %}
</td>
</tr>
</tbody>
</table>
<h4 class="mb-sm">{{ 'mautic.program.field.allocation_items'|trans }}</h4>
{% if allocationItems is empty %}
<p class="text-muted">{{ 'mautic.program.allocation_item.empty'|trans }}</p>
{% else %}
{# Harmonized columns: Pictogram (no label), Type, Name, Description, then the costs.
Filter + click-to-sort (program.js). #}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-allocation-items-view"
data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.allocation_item.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.allocation_item.field.type'|trans }}</th>
<th class="initiative-col-name">{{ 'mautic.program.allocation_item.field.name'|trans }}</th>
<th class="initiative-col-description">{{ 'mautic.program.allocation_item.field.description'|trans }}</th>
<th class="initiative-col-cost text-right">{{ 'mautic.program.allocation_item.field.planned_cost'|trans }}</th>
<th class="initiative-col-cost text-right">{{ 'mautic.program.allocation_item.field.real_cost'|trans }}</th>
</tr>
</thead>
<tbody>
{% for allocationItem in allocationItems %}
{% set typeName = program_item_type_name('allocation', allocationItem.type) %}
{% set typeDescription = program_item_type_description('allocation', allocationItem.type) %}
{% set typeIcon = program_item_type_icon('allocation', allocationItem.type) %}
<tr>
<td class="initiative-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="initiative-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': allocationItem.type}) }}
</td>
<td class="initiative-col-name">{{ allocationItem.name }}</td>
<td class="initiative-col-description text-muted" style="white-space: pre-wrap;">{{ allocationItem.description|program_linkify }}</td>
<td class="initiative-col-cost text-right text-nowrap">
{% if allocationItem.plannedCost is not null %}{{ program_money(allocationItem.plannedCost) }} {{ program_currency() }}{% endif %}
</td>
<td class="initiative-col-cost text-right text-nowrap">
{% if allocationItem.realCost is not null %}{{ program_money(allocationItem.realCost) }} {{ program_currency() }}{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr class="initiative-allocation-total">
<th colspan="4">{{ 'mautic.program.allocation.total'|trans }}</th>
<th class="initiative-col-cost text-right text-nowrap">
{% if allocationTotals.planned is not null %}{{ program_money(allocationTotals.planned) }} {{ program_currency() }}{% endif %}
</th>
<th class="initiative-col-cost text-right text-nowrap">
{% if allocationTotals.real is not null %}{{ program_money(allocationTotals.real) }} {{ program_currency() }}{% endif %}
</th>
</tr>
</tfoot>
</table>
</div>
{% endif %}
</div>
{# Stakeholders: the initiative's links to the global directory, harmonized like the other tabs. #}
<div class="tab-pane bdr-w-0" id="initiative-tab-stakeholders" role="tabpanel">
{% set stakeholders = item.stakeholders %}
{% if stakeholders is empty %}
<p class="text-muted">{{ 'mautic.program.stakeholder.empty'|trans }}</p>
{% else %}
{# Harmonized columns: Pictogram (no label), Type, Name, then the link's own fields.
Filter + click-to-sort (program.js). #}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-stakeholders-view"
data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.stakeholder.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.stakeholder.field.type'|trans }}</th>
<th class="initiative-col-name">{{ 'mautic.program.stakeholder.field.name'|trans }}</th>
<th class="initiative-col-role">{{ 'mautic.program.stakeholder.field.role_in_initiative'|trans }}</th>
<th class="initiative-col-role">{{ 'mautic.program.stakeholder.field.role'|trans }}</th>
<th class="initiative-col-email">{{ 'mautic.program.stakeholder.field.email'|trans }}</th>
<th class="initiative-col-phone">{{ 'mautic.program.stakeholder.field.phone'|trans }}</th>
<th class="initiative-col-active">{{ 'mautic.program.stakeholder.field.active'|trans }}</th>
</tr>
</thead>
<tbody>
{% for link in stakeholders %}
{% set stakeholder = link.stakeholder %}
<tr>
<td class="initiative-col-pictogram text-center">
{% set typeIcon = program_item_type_icon('stakeholder', stakeholder.type) %}
{% if typeIcon %}<i class="{{ typeIcon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="initiative-col-type"{% if program_item_type_description('stakeholder', stakeholder.type) %} title="{{ program_item_type_description('stakeholder', stakeholder.type) }}" data-toggle="tooltip"{% endif %}>
{{ program_item_type_name('stakeholder', stakeholder.type) ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': stakeholder.type}) }}
</td>
<td class="initiative-col-name">
<a href="{{ path('initiative_stakeholder_action', {'objectAction': 'view', 'objectId': stakeholder.id}) }}" data-toggle="ajax">{{ stakeholder.name }}</a>
</td>
<td class="initiative-col-role">{{ link.roleInInitiative }}</td>
<td class="initiative-col-role text-muted">{{ stakeholder.role }}</td>
<td class="initiative-col-email">
{% if stakeholder.email %}<a href="mailto:{{ stakeholder.email }}">{{ stakeholder.email }}</a>{% endif %}
</td>
<td class="initiative-col-phone text-nowrap">
{% if stakeholder.phone %}<a href="tel:{{ stakeholder.phone|replace({' ': ''}) }}">{{ stakeholder.phone }}</a>{% endif %}
</td>
<td class="initiative-col-active">
<span class="label {{ stakeholder.isPublished ? 'label-success' : 'label-gray' }}">
{{ (stakeholder.isPublished ? 'mautic.program.stakeholder.active' : 'mautic.program.stakeholder.inactive')|trans }}
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Audiences: the initiative's links to the global directory (Programs > Audiences), harmonized like
the other tabs: pictogram, Type, Name (link to the audience's page), priority in this plan,
then the audience's own attributes. Filter + click-to-sort (program.js). #}
<div class="tab-pane bdr-w-0" id="initiative-tab-audiences" role="tabpanel">
{% set audiences = item.audiences %}
{% if audiences is empty %}
<p class="text-muted">{{ 'mautic.program.audience.empty'|trans }}</p>
{% else %}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-audiences-view"
data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.audience.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.audience.field.type'|trans }}</th>
<th class="initiative-col-name">{{ 'mautic.program.audience.field.name'|trans }}</th>
<th class="initiative-col-priority">{{ 'mautic.program.audience.field.priority'|trans }}</th>
<th class="initiative-col-stages">{{ 'mautic.program.audience.field.stages'|trans }}</th>
<th class="initiative-col-size text-right">{{ 'mautic.program.audience.field.estimated_size'|trans }}</th>
<th class="initiative-col-description">{{ 'mautic.program.audience.field.value_proposition'|trans }}</th>
<th class="initiative-col-channels">{{ 'mautic.program.audience.field.preferred_channels'|trans }}</th>
</tr>
</thead>
<tbody>
{% for link in audiences %}
{% set audience = link.audience %}
<tr>
<td class="initiative-col-pictogram text-center">
<i class="{{ audience.audienceType.icon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>
</td>
<td class="initiative-col-type">{{ audience.audienceType.labelKey|trans }}</td>
<td class="initiative-col-name">
<a href="{{ path('initiative_audience_action', {'objectAction': 'view', 'objectId': audience.id}) }}" data-toggle="ajax">{{ audience.name }}</a>
</td>
<td class="initiative-col-priority">
<span class="label {{ link.priority.labelClass }}">{{ link.priority.labelKey|trans }}</span>
</td>
<td class="initiative-col-stages text-muted">
{{ audience.stages|map(stage => stage.name)|join(', ') }}
</td>
<td class="initiative-col-size text-right text-nowrap">{{ audience.estimatedSize }}</td>
<td class="initiative-col-description text-muted" style="white-space: pre-wrap;">{{ link.valueProposition }}</td>
<td class="initiative-col-channels">
{% for channel in audience.preferredChannels ?? [] %}
<span class="label label-default">{{ program_audience_channel_label(channel)|trans }}</span>
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Tasks: same columns as Programs > Tasks, in tree order. #}
<div class="tab-pane bdr-w-0" id="initiative-tab-tasks" role="tabpanel">
{{ include('@Program/Initiative/_task_table.html.twig', {
'initiative': item,
'taskTree': taskTree,
'taskPermissions': taskPermissions,
}) }}
</div>
</div>
{% endblock %}
+35 -35
View File
@@ -1,8 +1,8 @@
{% extends '@MauticCore/Default/content.html.twig' %} {% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}programItemTypes{% endblock %} {% block mauticContent %}mt3sMpProgramItemTypes{% endblock %}
{% block headerTitle %}{{ 'mautic.program.item_type.header.index'|trans }}{% endblock %} {% block headerTitle %}{{ 'mt3s.marketing_program.item_type.header.index'|trans }}{% endblock %}
{# {#
# The type lists of the plugin's items, formerly the type sections of Settings > Configuration > # The type lists of the plugin's items, formerly the type sections of Settings > Configuration >
@@ -10,7 +10,7 @@
# items), allocations, objectives, tasks, stakeholders, then the values offered for an # items), allocations, objectives, tasks, stakeholders, then the values offered for an
# audience's decision roles and tones. # audience's decision roles and tones.
# #
# Adding and removing types, and the pictogram preview, are handled by Assets/js/program.js # Adding and removing types, and the pictogram preview, are handled by Assets/js/mt3s-mp-program.js
# (delegated handlers on .program-config-types). # (delegated handlers on .program-config-types).
#} #}
@@ -23,7 +23,7 @@
{% set icon = type.children.icon.vars.value %} {% set icon = type.children.icon.vars.value %}
<div class="row mb-sm"> <div class="row mb-sm">
<div class="col-xs-1 text-center pt-lg"> <div class="col-xs-1 text-center pt-lg">
<i class="initiative-type-icon-preview {{ icon }}" style="font-size: 28px;" aria-hidden="true"></i> <i class="program-type-icon-preview {{ icon }}" style="font-size: 28px;" aria-hidden="true"></i>
</div> </div>
<div class="col-xs-5">{{ form_row(type.children.icon) }}</div> <div class="col-xs-5">{{ form_row(type.children.icon) }}</div>
</div> </div>
@@ -31,9 +31,9 @@
<table class="table table-condensed mb-0"> <table class="table table-condensed mb-0">
<thead> <thead>
<tr> <tr>
<th class="col-xs-2">{{ 'mautic.program.config.type.language'|trans }}</th> <th class="col-xs-2">{{ 'mt3s.marketing_program.config.type.language'|trans }}</th>
<th class="col-xs-4">{{ 'mautic.program.config.type.name'|trans }}</th> <th class="col-xs-4">{{ 'mt3s.marketing_program.config.type.name'|trans }}</th>
<th class="col-xs-6">{{ 'mautic.program.config.type.description'|trans }}</th> <th class="col-xs-6">{{ 'mt3s.marketing_program.config.type.description'|trans }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -57,7 +57,7 @@
</table> </table>
<div class="text-right mt-xs"> <div class="text-right mt-xs">
<button type="button" class="btn btn-ghost btn-sm program-config-type-remove"> <button type="button" class="btn btn-ghost btn-sm program-config-type-remove">
<i class="ri-delete-bin-line"></i> {{ 'mautic.program.config.type.remove'|trans }} <i class="ri-delete-bin-line"></i> {{ 'mt3s.marketing_program.config.type.remove'|trans }}
</button> </button>
</div> </div>
</div> </div>
@@ -71,7 +71,7 @@
{{ form_errors(types) }} {{ form_errors(types) }}
<div class="program-config-types" data-prototype="{{ cfg.type_row(types.vars.prototype)|e('html_attr') }}"> <div class="program-config-types" data-prototype="{{ cfg.type_row(types.vars.prototype)|e('html_attr') }}">
<p class="text-muted program-config-types-empty{% if types|length > 0 %} hide{% endif %}"> <p class="text-muted program-config-types-empty{% if types|length > 0 %} hide{% endif %}">
{{ 'mautic.program.config.types.empty'|trans }} {{ 'mt3s.marketing_program.config.types.empty'|trans }}
</p> </p>
<div class="program-config-types-list"> <div class="program-config-types-list">
{% for type in types %} {% for type in types %}
@@ -79,7 +79,7 @@
{% endfor %} {% endfor %}
</div> </div>
<button type="button" class="btn btn-ghost program-config-type-add"> <button type="button" class="btn btn-ghost program-config-type-add">
<i class="ri-add-line"></i> {{ 'mautic.program.config.type.add'|trans }} <i class="ri-add-line"></i> {{ 'mt3s.marketing_program.config.type.add'|trans }}
</button> </button>
</div> </div>
{% do types.setRendered %} {% do types.setRendered %}
@@ -91,41 +91,41 @@
{{ form_start(form) }} {{ form_start(form) }}
{# The root form's errors: the in-use guard adds its message here. #} {# The root form's errors: the in-use guard adds its message here. #}
{{ form_errors(form) }} {{ form_errors(form) }}
<div class="text-muted small pb-md">{{ 'mautic.program.item_type.page.description'|trans }}</div> <div class="text-muted small pb-md">{{ 'mt3s.marketing_program.item_type.page.description'|trans }}</div>
{% if not isWritable %} {% if not isWritable %}
<div class="alert alert-warning">{{ 'mautic.program.item_type.not_writable'|trans }}</div> <div class="alert alert-warning">{{ 'mt3s.marketing_program.item_type.not_writable'|trans }}</div>
{% endif %} {% endif %}
{{ cfg.type_section(form.children.program_description_item_types, {{ cfg.type_section(form.children.mt3s_marketing_program_description_item_types,
'mautic.program.config.section.description_item_types', 'mt3s.marketing_program.config.section.description_item_types',
'mautic.program.config.section.description_item_types.help') }} 'mt3s.marketing_program.config.section.description_item_types.help') }}
{{ cfg.type_section(form.children.program_allocation_item_types, {{ cfg.type_section(form.children.mt3s_marketing_program_allocation_item_types,
'mautic.program.config.section.allocation_item_types', 'mt3s.marketing_program.config.section.allocation_item_types',
'mautic.program.config.section.allocation_item_types.help') }} 'mt3s.marketing_program.config.section.allocation_item_types.help') }}
{{ cfg.type_section(form.children.program_objective_types, {{ cfg.type_section(form.children.mt3s_marketing_program_objective_types,
'mautic.program.config.section.objective_types', 'mt3s.marketing_program.config.section.objective_types',
'mautic.program.config.section.objective_types.help') }} 'mt3s.marketing_program.config.section.objective_types.help') }}
{{ cfg.type_section(form.children.program_task_types, {{ cfg.type_section(form.children.mt3s_marketing_program_task_types,
'mautic.program.config.section.task_types', 'mt3s.marketing_program.config.section.task_types',
'mautic.program.config.section.task_types.help') }} 'mt3s.marketing_program.config.section.task_types.help') }}
{{ cfg.type_section(form.children.program_stakeholder_types, {{ cfg.type_section(form.children.mt3s_marketing_program_stakeholder_types,
'mautic.program.config.section.stakeholder_types', 'mt3s.marketing_program.config.section.stakeholder_types',
'mautic.program.config.section.stakeholder_types.help') }} 'mt3s.marketing_program.config.section.stakeholder_types.help') }}
<h4 class="fw-sb mt-lg mb-xs">{{ 'mautic.program.config.section.audience_values'|trans }}</h4> <h4 class="fw-sb mt-lg mb-xs">{{ 'mt3s.marketing_program.config.section.audience_values'|trans }}</h4>
<p class="text-muted small">{{ 'mautic.program.config.section.audience_values.help'|trans }}</p> <p class="text-muted small">{{ 'mt3s.marketing_program.config.section.audience_values.help'|trans }}</p>
{{ cfg.type_section(form.children.program_audience_decision_roles, {{ cfg.type_section(form.children.mt3s_marketing_program_audience_decision_roles,
'mautic.program.config.section.audience_decision_roles', 'mt3s.marketing_program.config.section.audience_decision_roles',
'mautic.program.config.section.audience_decision_roles.help') }} 'mt3s.marketing_program.config.section.audience_decision_roles.help') }}
{{ cfg.type_section(form.children.program_audience_tones, {{ cfg.type_section(form.children.mt3s_marketing_program_audience_tones,
'mautic.program.config.section.audience_tones', 'mt3s.marketing_program.config.section.audience_tones',
'mautic.program.config.section.audience_tones.help') }} 'mt3s.marketing_program.config.section.audience_tones.help') }}
{{ form_row(form.children.buttons) }} {{ form_row(form.children.buttons) }}
{# render_rest is false, so the hidden CSRF token must be rendered explicitly. #} {# render_rest is false, so the hidden CSRF token must be rendered explicitly. #}
@@ -4,21 +4,21 @@
# display:-webkit-box); the button only toggles the class, so it also works without JS. # display:-webkit-box); the button only toggles the class, so it also works without JS.
# #
# Parameters: # Parameters:
# text: the text to show (may contain line breaks; URLs in it become links, see program_linkify) # text: the text to show (may contain line breaks; URLs in it become links, see mt3s_marketing_program_linkify)
# id: unique element id for this instance # id: unique element id for this instance
# lines: number of lines to clamp to (default 10) # lines: number of lines to clamp to (default 10)
#} #}
{% set lines = lines|default(10) %} {% set lines = lines|default(10) %}
{% if text|trim is not empty %} {% if text|trim is not empty %}
<div class="initiative-read-more" id="{{ id }}"> <div class="program-read-more" id="{{ id }}">
<div class="initiative-read-more-text" style="display: -webkit-box; -webkit-line-clamp: {{ lines }}; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap;">{{ text|program_linkify }}</div> <div class="program-read-more-text" style="display: -webkit-box; -webkit-line-clamp: {{ lines }}; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap;">{{ text|mt3s_marketing_program_linkify }}</div>
<button type="button" class="btn btn-link btn-xs p-0 initiative-read-more-toggle" <button type="button" class="btn btn-link btn-xs p-0 program-read-more-toggle"
data-target="{{ id }}" data-target="{{ id }}"
data-more-text="{{ 'mautic.program.read_more.more'|trans }}" data-more-text="{{ 'mt3s.marketing_program.read_more.more'|trans }}"
data-less-text="{{ 'mautic.program.read_more.less'|trans }}" data-less-text="{{ 'mt3s.marketing_program.read_more.less'|trans }}"
style="display: none; padding-left: 0;" style="display: none; padding-left: 0;"
aria-expanded="false"> aria-expanded="false">
{{ 'mautic.program.read_more.more'|trans }} <i class="ri-arrow-down-s-line"></i> {{ 'mt3s.marketing_program.read_more.more'|trans }} <i class="ri-arrow-down-s-line"></i>
</button> </button>
</div> </div>
{% endif %} {% endif %}
@@ -0,0 +1,11 @@
{#
# The filter box of an program tab table (Description, Objectives, Allocation, Tasks) and the switch that
# shows the "no match" message. Filtering and sorting are handled by Assets/js/mt3s-mp-program.js
# (Mautic.mt3sMpProgramInitTabTable), on any table with the data-program-tab-table attribute.
#}
<div class="program-tab-table-filter input-group input-group-sm mb-xs" style="max-width: 300px;">
<span class="input-group-addon"><i class="ri-search-line"></i></span>
<input type="text" class="form-control program-tab-table-filter-input"
placeholder="{{ 'mt3s.marketing_program.filter.placeholder'|trans }}" aria-label="{{ 'mt3s.marketing_program.filter.placeholder'|trans }}">
</div>
<p class="text-muted program-tab-table-nomatch hide">{{ 'mt3s.marketing_program.filter.no_match'|trans }}</p>
Loaded 100 of 131 files, more files were not shown because too many files have changed in this diff. Show more