refactor(plugin): rename Plan to Program and add audience/UTM routes
Rename the Plan bundle to Program across config, routes, menus, and controllers (Plan -> Initiative), bump version to 0.16.0, and introduce new audience and UTM taxonomy routes and permissions to support the expanded Programs feature set.
This commit is contained in:
1 parent
8268fad886
commit
71ff11390b
121 files changed
+5011
-2874
No files matched your search
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Service;
|
||||
|
||||
use Mautic\CoreBundle\Helper\CoreParametersHelper;
|
||||
|
||||
/**
|
||||
* Reads the Audience attributes set up in Settings > Configuration > Program Settings.
|
||||
*
|
||||
* Which attributes of an audience persona are offered on the forms is chosen there, one toggle per
|
||||
* attribute, so a b2b install and a b2c install define their personas differently. Each toggle is
|
||||
* a local.php parameter (default enabled; an admin turns off what they don't use):
|
||||
* - program_audience_attribute_tagline (Tagline)
|
||||
* - program_audience_attribute_profile (Profile criteria)
|
||||
* - program_audience_attribute_motivations (Motivations)
|
||||
* - program_audience_attribute_barriers (Barriers)
|
||||
* - program_audience_attribute_frustrations (Frustrations)
|
||||
* - program_audience_attribute_triggers (Triggers)
|
||||
* - program_audience_attribute_decision_role (Decision-making role; values program_audience_decision_roles)
|
||||
* - program_audience_attribute_tones (Preferred tones; values program_audience_tones)
|
||||
* - program_audience_attribute_channels (Preferred channels)
|
||||
* - program_audience_attribute_stages (Stages)
|
||||
* - program_audience_attribute_size (Estimated size)
|
||||
*
|
||||
* The values of the decision roles and the tones are lists edited in the same place, with a name
|
||||
* per language — read through ItemTypeProvider (kinds "audience_decision_role" and "audience_tone").
|
||||
*
|
||||
* The segments are NOT part of this: every audience offers them (always, purely informational).
|
||||
*/
|
||||
class AudienceAttributes
|
||||
{
|
||||
/**
|
||||
* Attribute key => form field name. The keys name the local.php toggle parameters; the values
|
||||
* are the Audience entity's fields. The order is the order of the forms and of the tables.
|
||||
*/
|
||||
public const ATTRIBUTES = [
|
||||
'tagline' => 'tagline',
|
||||
'profile' => 'profileCriteria',
|
||||
'motivations' => 'motivations',
|
||||
'barriers' => 'barriers',
|
||||
'frustrations' => 'frustrations',
|
||||
'triggers' => 'triggers',
|
||||
'decision_role' => 'decisionRole',
|
||||
'tones' => 'preferredTones',
|
||||
'channels' => 'preferredChannels',
|
||||
'stages' => 'stages',
|
||||
'size' => 'estimatedSize',
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private CoreParametersHelper $coreParametersHelper,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* True when an attribute is offered on the audience forms. The toggle defaults to enabled, so
|
||||
* an install that never touches the settings gets every attribute; turning it off stores false.
|
||||
*/
|
||||
public function isEnabled(string $attribute): bool
|
||||
{
|
||||
if (!isset(self::ATTRIBUTES[$attribute])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Null (parameter never set) and true both mean enabled; only an explicit false turns it off.
|
||||
return false !== $this->coreParametersHelper->get(self::toggleParameter($attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* The enabled attribute keys, in canonical order.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getEnabled(): array
|
||||
{
|
||||
$enabled = [];
|
||||
foreach (array_keys(self::ATTRIBUTES) as $attribute) {
|
||||
if ($this->isEnabled($attribute)) {
|
||||
$enabled[] = $attribute;
|
||||
}
|
||||
}
|
||||
|
||||
return $enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* The form field name of an attribute ('tagline', 'profileCriteria', …).
|
||||
*/
|
||||
public function getField(string $attribute): string
|
||||
{
|
||||
if (!isset(self::ATTRIBUTES[$attribute])) {
|
||||
throw new \InvalidArgumentException('Unknown audience attribute: '.$attribute);
|
||||
}
|
||||
|
||||
return self::ATTRIBUTES[$attribute];
|
||||
}
|
||||
|
||||
/**
|
||||
* The local.php parameter holding an attribute's toggle.
|
||||
*/
|
||||
public static function toggleParameter(string $attribute): string
|
||||
{
|
||||
return 'program_audience_attribute_'.$attribute;
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,22 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Service;
|
||||
namespace MauticPlugin\ProgramBundle\Service;
|
||||
|
||||
use Mautic\CoreBundle\Helper\CoreParametersHelper;
|
||||
use Symfony\Component\Intl\Currencies;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* The currency of all amounts in the plugin (plan budgets, allocation costs and totals).
|
||||
* The currency of all amounts in the plugin (initiative budgets, allocation costs and totals).
|
||||
*
|
||||
* It is a general setting, chosen by an administrator in Settings > Configuration > Plan Settings and
|
||||
* stored in the local.php parameter plan_currency; users don't pick a currency. Amounts aren't converted
|
||||
* It is a general setting, chosen by an administrator in Settings > Configuration > Program Settings and
|
||||
* stored in the local.php parameter program_currency; users don't pick a currency. Amounts aren't converted
|
||||
* when it changes: they are simply shown with the new currency.
|
||||
*/
|
||||
class CurrencyProvider
|
||||
{
|
||||
public const CONFIG_PARAMETER = 'plan_currency';
|
||||
public const CONFIG_PARAMETER = 'program_currency';
|
||||
|
||||
public const DEFAULT_CURRENCY = 'EUR';
|
||||
|
||||
|
||||
@@ -2,25 +2,28 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Service;
|
||||
namespace MauticPlugin\ProgramBundle\Service;
|
||||
|
||||
use Mautic\CoreBundle\Helper\CoreParametersHelper;
|
||||
use Mautic\CoreBundle\Helper\LanguageHelper;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* Reads the item types set up in Settings > Configuration > Plan. There is one list of types per kind:
|
||||
* - KIND_DESCRIPTION: types of description items (Description tab), parameter plan_description_item_types;
|
||||
* - KIND_ALLOCATION: types of allocation items (Allocation tab), parameter plan_allocation_item_types;
|
||||
* - KIND_OBJECTIVE: types of objectives (Objectives tab), parameter plan_objective_types;
|
||||
* - KIND_TASK: types of tasks (Planning > Tasks and the plan's Tasks tab), parameter plan_task_types;
|
||||
* - KIND_STAKEHOLDER: types of stakeholders (Planning > Stakeholders), parameter plan_stakeholder_types.
|
||||
* Reads the item types set up in Settings > Configuration > Program Settings. There is one list of types per kind:
|
||||
* - KIND_DESCRIPTION: types of description items (the Insights tab), parameter program_description_item_types;
|
||||
* - KIND_ALLOCATION: types of allocation items (Allocation tab), parameter program_allocation_item_types;
|
||||
* - KIND_OBJECTIVE: types of objectives (Objectives tab), parameter program_objective_types;
|
||||
* - KIND_TASK: types of tasks (Programs > Tasks and the initiative's Tasks tab), parameter program_task_types;
|
||||
* - KIND_STAKEHOLDER: types of stakeholders (Programs > Stakeholders), parameter program_stakeholder_types;
|
||||
* - KIND_AUDIENCE_DECISION_ROLE: values of an audience's "Decision-making role" attribute, parameter
|
||||
* program_audience_decision_roles (Settings > Configuration > Program Settings);
|
||||
* - KIND_AUDIENCE_TONE: values of an audience's "Preferred tone" attribute, parameter program_audience_tones.
|
||||
*
|
||||
* Each list is stored in local.php, in display order:
|
||||
*
|
||||
* [
|
||||
* ['key' => 'type_1a2b3c4d', 'names' => ['en_US' => 'Context', 'fr' => 'Contexte'],
|
||||
* 'descriptions' => ['en_US' => 'Why this plan exists', 'fr' => '…'], 'icon' => 'ri-lightbulb-line'],
|
||||
* 'descriptions' => ['en_US' => 'Why this initiative exists', 'fr' => '…'], 'icon' => 'ri-lightbulb-line'],
|
||||
* …
|
||||
* ]
|
||||
*
|
||||
@@ -35,16 +38,20 @@ class ItemTypeProvider
|
||||
public const KIND_OBJECTIVE = 'objective';
|
||||
public const KIND_TASK = 'task';
|
||||
public const KIND_STAKEHOLDER = 'stakeholder';
|
||||
public const KIND_AUDIENCE_DECISION_ROLE = 'audience_decision_role';
|
||||
public const KIND_AUDIENCE_TONE = 'audience_tone';
|
||||
|
||||
/**
|
||||
* Kind => local.php parameter.
|
||||
*/
|
||||
public const PARAMETERS = [
|
||||
self::KIND_DESCRIPTION => 'plan_description_item_types',
|
||||
self::KIND_ALLOCATION => 'plan_allocation_item_types',
|
||||
self::KIND_OBJECTIVE => 'plan_objective_types',
|
||||
self::KIND_TASK => 'plan_task_types',
|
||||
self::KIND_STAKEHOLDER => 'plan_stakeholder_types',
|
||||
self::KIND_DESCRIPTION => 'program_description_item_types',
|
||||
self::KIND_ALLOCATION => 'program_allocation_item_types',
|
||||
self::KIND_OBJECTIVE => 'program_objective_types',
|
||||
self::KIND_TASK => 'program_task_types',
|
||||
self::KIND_STAKEHOLDER => 'program_stakeholder_types',
|
||||
self::KIND_AUDIENCE_DECISION_ROLE => 'program_audience_decision_roles',
|
||||
self::KIND_AUDIENCE_TONE => 'program_audience_tones',
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Service;
|
||||
namespace MauticPlugin\ProgramBundle\Service;
|
||||
|
||||
/**
|
||||
* Pictograms an administrator can give to an item type — description or allocation (Settings >
|
||||
* Configuration > Plan Settings). They are icons of the Remix Icon set that Mautic ships ("ri-*"
|
||||
* Configuration > Program Settings). They are icons of the Remix Icon set that Mautic ships ("ri-*"
|
||||
* classes); each one was checked against Mautic 7's icon stylesheet.
|
||||
*/
|
||||
final class Pictograms
|
||||
|
||||
Reference in new issue
Block a user