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
+259
-113
@@ -2,13 +2,15 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||
use Mautic\CoreBundle\Entity\FormEntity;
|
||||
use Mautic\LeadBundle\Entity\LeadList;
|
||||
use Mautic\StageBundle\Entity\Stage;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
@@ -16,50 +18,53 @@ use Symfony\Component\Validator\Constraints\PositiveOrZero;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* One audience of a plan's Targets tab: who the plan is aimed at, and how. Plan::$targets owns the
|
||||
* lifecycle: targets are saved and deleted with their plan, and are ordered by position.
|
||||
* 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,
|
||||
* which carries the audience's priority in that plan, and possibly a initiative-specific message.
|
||||
*
|
||||
* The stages are the Mautic stages (Settings > Stages) this target maps to; a target can have any
|
||||
* number of them, or none. Deleting a stage removes the link (join table row), not the target.
|
||||
* 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
|
||||
* 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
|
||||
* any number of them, or none. Deleting a stage removes the link (join table row), not the audience.
|
||||
*
|
||||
* The segments are the Mautic segments (LeadBundle lists) this audience maps to. They are purely
|
||||
* 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.
|
||||
*
|
||||
* isPublished (from FormEntity) means "active": an unpublished audience is hidden from the initiative
|
||||
* form's audience picker, but keeps its history on the initiatives it is already linked to.
|
||||
*/
|
||||
class Target
|
||||
class Audience extends FormEntity
|
||||
{
|
||||
public const TABLE_NAME = 'plan_targets';
|
||||
public const TABLE_NAME = 'initiative_audiences';
|
||||
|
||||
/**
|
||||
* Keys offered for preferredChannels, in display order.
|
||||
*/
|
||||
public const CHANNELS = [
|
||||
'email' => 'mautic.plan.target.channel.email',
|
||||
'sms' => 'mautic.plan.target.channel.sms',
|
||||
'web' => 'mautic.plan.target.channel.web',
|
||||
'social_organic' => 'mautic.plan.target.channel.social_organic',
|
||||
'paid_social' => 'mautic.plan.target.channel.paid_social',
|
||||
'paid_search' => 'mautic.plan.target.channel.paid_search',
|
||||
'events_webinar' => 'mautic.plan.target.channel.events_webinar',
|
||||
'outbound_sales' => 'mautic.plan.target.channel.outbound_sales',
|
||||
'partners' => 'mautic.plan.target.channel.partners',
|
||||
'email' => 'mautic.program.audience.channel.email',
|
||||
'sms' => 'mautic.program.audience.channel.sms',
|
||||
'web' => 'mautic.program.audience.channel.web',
|
||||
'social_organic' => 'mautic.program.audience.channel.social_organic',
|
||||
'paid_social' => 'mautic.program.audience.channel.paid_social',
|
||||
'paid_search' => 'mautic.program.audience.channel.paid_search',
|
||||
'events_webinar' => 'mautic.program.audience.channel.events_webinar',
|
||||
'outbound_sales' => 'mautic.program.audience.channel.outbound_sales',
|
||||
'partners' => 'mautic.program.audience.channel.partners',
|
||||
];
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
private ?Plan $plan = null;
|
||||
|
||||
private ?string $name = null;
|
||||
|
||||
private TargetType $targetType = TargetType::Persona;
|
||||
|
||||
private TargetPriority $priority = TargetPriority::Primary;
|
||||
private AudienceType $audienceType = AudienceType::Persona;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Stage>
|
||||
* One-line positioning statement ("The busy CFO who…").
|
||||
*/
|
||||
private Collection $stages;
|
||||
|
||||
/**
|
||||
* Estimated number of people or accounts, or null when unknown.
|
||||
*/
|
||||
private ?int $estimatedSize = null;
|
||||
private ?string $tagline = null;
|
||||
|
||||
/**
|
||||
* Demographics, firmographics, job titles, geography.
|
||||
@@ -67,37 +72,88 @@ class Target
|
||||
private ?string $profileCriteria = null;
|
||||
|
||||
/**
|
||||
* Problems, triggers, motivations.
|
||||
* What drives the audience.
|
||||
*/
|
||||
private ?string $painPoints = null;
|
||||
private ?string $motivations = null;
|
||||
|
||||
/**
|
||||
* Key message / hook for this target in this plan.
|
||||
* What holds the audience back from buying.
|
||||
*/
|
||||
private ?string $valueProposition = null;
|
||||
private ?string $barriers = null;
|
||||
|
||||
/**
|
||||
* Keys of self::CHANNELS the plan means to use for this target.
|
||||
* What annoys or blocks the audience day to day (formerly Pain points).
|
||||
*/
|
||||
private ?string $frustrations = null;
|
||||
|
||||
/**
|
||||
* What makes the audience act (content, season, event…).
|
||||
*/
|
||||
private ?string $triggers = null;
|
||||
|
||||
/**
|
||||
* Key of a decision role set up in Settings > Configuration > Initiative Settings
|
||||
* (parameter program_audience_decision_roles), or null when the attribute is unused.
|
||||
*/
|
||||
private ?string $decisionRole = null;
|
||||
|
||||
/**
|
||||
* Keys of tones set up in Settings > Configuration > Initiative Settings
|
||||
* (parameter program_audience_tones), or null/[] when the attribute is unused.
|
||||
*
|
||||
* @var list<string>|null
|
||||
*/
|
||||
private ?array $preferredTones = null;
|
||||
|
||||
/**
|
||||
* Keys of self::CHANNELS the initiative means to use for this audience.
|
||||
*
|
||||
* @var list<string>|null
|
||||
*/
|
||||
private ?array $preferredChannels = null;
|
||||
|
||||
/**
|
||||
* Display order within the plan, from 0. Set by drag and drop in the form.
|
||||
* The Mautic stages this audience maps to; any number, or none.
|
||||
*
|
||||
* @var Collection<int, Stage>
|
||||
*/
|
||||
private int $position = 0;
|
||||
private Collection $stages;
|
||||
|
||||
/**
|
||||
* The Mautic segments this audience maps to; any number, or none. Purely informational.
|
||||
*
|
||||
* @var Collection<int, LeadList>
|
||||
*/
|
||||
private Collection $segments;
|
||||
|
||||
/**
|
||||
* Estimated number of people or accounts, or null when unknown.
|
||||
*/
|
||||
private ?int $estimatedSize = null;
|
||||
|
||||
/**
|
||||
* The links to the initiatives this audience is assigned to. Inverse side, read-only from here: the
|
||||
* links are managed from the plans (Initiative::addAudience/removeAudience).
|
||||
*
|
||||
* @var Collection<int, InitiativeAudience>
|
||||
*/
|
||||
private Collection $initiativeLinks;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->stages = new ArrayCollection();
|
||||
$this->stages = new ArrayCollection();
|
||||
$this->segments = new ArrayCollection();
|
||||
$this->initiativeLinks = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->plan = null;
|
||||
$this->stages = new ArrayCollection();
|
||||
$this->id = null;
|
||||
$this->stages = new ArrayCollection();
|
||||
$this->segments = new ArrayCollection();
|
||||
$this->initiativeLinks = new ArrayCollection();
|
||||
|
||||
parent::__clone();
|
||||
}
|
||||
|
||||
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||
@@ -105,75 +161,88 @@ class Target
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable(self::TABLE_NAME)
|
||||
->setCustomRepositoryClass(TargetRepository::class);
|
||||
->setCustomRepositoryClass(AudienceRepository::class);
|
||||
|
||||
$builder->addId();
|
||||
|
||||
$builder->createManyToOne('plan', Plan::class)
|
||||
->inversedBy('targets')
|
||||
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
|
||||
$builder->createField('name', Types::STRING)
|
||||
->length(191)
|
||||
->build();
|
||||
|
||||
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191).
|
||||
$metadata->mapField([
|
||||
'fieldName' => 'name',
|
||||
'type' => Types::STRING,
|
||||
'length' => 191,
|
||||
]);
|
||||
|
||||
$metadata->mapField([
|
||||
'fieldName' => 'targetType',
|
||||
'columnName' => 'target_type',
|
||||
'fieldName' => 'audienceType',
|
||||
'columnName' => 'audience_type',
|
||||
'type' => Types::STRING,
|
||||
'length' => 30,
|
||||
'enumType' => TargetType::class,
|
||||
'options' => ['default' => TargetType::Persona->value],
|
||||
'enumType' => AudienceType::class,
|
||||
'options' => ['default' => AudienceType::Persona->value],
|
||||
]);
|
||||
|
||||
$metadata->mapField([
|
||||
'fieldName' => 'priority',
|
||||
'type' => Types::STRING,
|
||||
'length' => 20,
|
||||
'enumType' => TargetPriority::class,
|
||||
'options' => ['default' => TargetPriority::Primary->value],
|
||||
]);
|
||||
|
||||
foreach (['profileCriteria' => 'profile_criteria', 'painPoints' => 'pain_points', 'valueProposition' => 'value_proposition'] as $field => $column) {
|
||||
foreach ([
|
||||
'tagline' => 'tagline',
|
||||
'profileCriteria' => 'profile_criteria',
|
||||
'motivations' => 'motivations',
|
||||
'barriers' => 'barriers',
|
||||
'frustrations' => 'frustrations',
|
||||
'triggers' => 'triggers',
|
||||
] as $field => $column) {
|
||||
$metadata->mapField([
|
||||
'fieldName' => $field,
|
||||
'fieldName' => $field,
|
||||
'columnName' => $column,
|
||||
'type' => Types::TEXT,
|
||||
'nullable' => true,
|
||||
'type' => Types::TEXT,
|
||||
'nullable' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
// Key of a configured decision role; the attribute may be unused (null).
|
||||
$builder->createField('decisionRole', Types::STRING)
|
||||
->columnName('decision_role')
|
||||
->length(64)
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createField('preferredTones', Types::JSON)
|
||||
->columnName('preferred_tones')
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createField('preferredChannels', Types::JSON)
|
||||
->columnName('preferred_channels')
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createManyToMany('stages', Stage::class)
|
||||
->setJoinTable('plan_target_stages')
|
||||
->addJoinColumn('target_id', 'id', false, false, 'CASCADE')
|
||||
->setJoinTable('initiative_audiences_stages')
|
||||
->addJoinColumn('audience_id', 'id', false, false, 'CASCADE')
|
||||
->addInverseJoinColumn('stage_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createManyToMany('segments', LeadList::class)
|
||||
->setJoinTable('initiative_audiences_segments')
|
||||
->addJoinColumn('audience_id', 'id', false, false, 'CASCADE')
|
||||
->addInverseJoinColumn('leadlist_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createField('estimatedSize', Types::INTEGER)
|
||||
->columnName('estimated_size')
|
||||
->nullable()
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
|
||||
$builder->createField('preferredChannels', Types::JSON)
|
||||
->columnName('preferred_channels')
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createField('position', Types::INTEGER)
|
||||
->option('default', 0)
|
||||
// The links to the initiatives, managed from the initiatives.
|
||||
$builder->createOneToMany('initiativeLinks', InitiativeAudience::class)
|
||||
->mappedBy('audience')
|
||||
->fetchExtraLazy()
|
||||
->build();
|
||||
}
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.plan.target.name.required'));
|
||||
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.program.audience.name.required'));
|
||||
$metadata->addPropertyConstraint('name', new Length(max: 191));
|
||||
$metadata->addPropertyConstraint('estimatedSize', new PositiveOrZero(message: 'mautic.plan.target.estimated_size.invalid'));
|
||||
$metadata->addPropertyConstraint('estimatedSize', new PositiveOrZero(message: 'mautic.program.audience.estimated_size.invalid'));
|
||||
$metadata->addPropertyConstraint('decisionRole', new Length(max: 64));
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
@@ -181,18 +250,6 @@ class Target
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPlan(): ?Plan
|
||||
{
|
||||
return $this->plan;
|
||||
}
|
||||
|
||||
public function setPlan(?Plan $plan): static
|
||||
{
|
||||
$this->plan = $plan;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
@@ -200,31 +257,37 @@ class Target
|
||||
|
||||
public function setName(?string $name): static
|
||||
{
|
||||
$this->isChanged('name', $name);
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTargetType(): TargetType
|
||||
public function getAudienceType(): AudienceType
|
||||
{
|
||||
return $this->targetType;
|
||||
return $this->audienceType;
|
||||
}
|
||||
|
||||
public function setTargetType(TargetType $targetType): static
|
||||
public function setAudienceType(AudienceType $audienceType): static
|
||||
{
|
||||
$this->targetType = $targetType;
|
||||
if ($audienceType !== $this->audienceType) {
|
||||
// isChanged() can't log enums (they aren't stringable), so log the backing values.
|
||||
$this->addChange('audienceType', [$this->audienceType->value, $audienceType->value]);
|
||||
}
|
||||
$this->audienceType = $audienceType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPriority(): TargetPriority
|
||||
public function getTagline(): ?string
|
||||
{
|
||||
return $this->priority;
|
||||
return $this->tagline;
|
||||
}
|
||||
|
||||
public function setPriority(TargetPriority $priority): static
|
||||
public function setTagline(?string $tagline): static
|
||||
{
|
||||
$this->priority = $priority;
|
||||
$this->isChanged('tagline', $tagline);
|
||||
$this->tagline = $tagline;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -253,6 +316,30 @@ class Target
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, LeadList>
|
||||
*/
|
||||
public function getSegments(): Collection
|
||||
{
|
||||
return $this->segments;
|
||||
}
|
||||
|
||||
public function addSegment(LeadList $segment): static
|
||||
{
|
||||
if (!$this->segments->contains($segment)) {
|
||||
$this->segments->add($segment);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSegment(LeadList $segment): static
|
||||
{
|
||||
$this->segments->removeElement($segment);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEstimatedSize(): ?int
|
||||
{
|
||||
return $this->estimatedSize;
|
||||
@@ -260,6 +347,7 @@ class Target
|
||||
|
||||
public function setEstimatedSize(?int $estimatedSize): static
|
||||
{
|
||||
$this->isChanged('estimatedSize', $estimatedSize);
|
||||
$this->estimatedSize = $estimatedSize;
|
||||
|
||||
return $this;
|
||||
@@ -272,31 +360,92 @@ class Target
|
||||
|
||||
public function setProfileCriteria(?string $profileCriteria): static
|
||||
{
|
||||
$this->isChanged('profileCriteria', $profileCriteria);
|
||||
$this->profileCriteria = $profileCriteria;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPainPoints(): ?string
|
||||
public function getMotivations(): ?string
|
||||
{
|
||||
return $this->painPoints;
|
||||
return $this->motivations;
|
||||
}
|
||||
|
||||
public function setPainPoints(?string $painPoints): static
|
||||
public function setMotivations(?string $motivations): static
|
||||
{
|
||||
$this->painPoints = $painPoints;
|
||||
$this->isChanged('motivations', $motivations);
|
||||
$this->motivations = $motivations;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValueProposition(): ?string
|
||||
public function getBarriers(): ?string
|
||||
{
|
||||
return $this->valueProposition;
|
||||
return $this->barriers;
|
||||
}
|
||||
|
||||
public function setValueProposition(?string $valueProposition): static
|
||||
public function setBarriers(?string $barriers): static
|
||||
{
|
||||
$this->valueProposition = $valueProposition;
|
||||
$this->isChanged('barriers', $barriers);
|
||||
$this->barriers = $barriers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFrustrations(): ?string
|
||||
{
|
||||
return $this->frustrations;
|
||||
}
|
||||
|
||||
public function setFrustrations(?string $frustrations): static
|
||||
{
|
||||
$this->isChanged('frustrations', $frustrations);
|
||||
$this->frustrations = $frustrations;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTriggers(): ?string
|
||||
{
|
||||
return $this->triggers;
|
||||
}
|
||||
|
||||
public function setTriggers(?string $triggers): static
|
||||
{
|
||||
$this->isChanged('triggers', $triggers);
|
||||
$this->triggers = $triggers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDecisionRole(): ?string
|
||||
{
|
||||
return $this->decisionRole;
|
||||
}
|
||||
|
||||
public function setDecisionRole(?string $decisionRole): static
|
||||
{
|
||||
$this->isChanged('decisionRole', $decisionRole);
|
||||
$this->decisionRole = $decisionRole;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>|null
|
||||
*/
|
||||
public function getPreferredTones(): ?array
|
||||
{
|
||||
return $this->preferredTones;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string>|null $preferredTones
|
||||
*/
|
||||
public function setPreferredTones(?array $preferredTones): static
|
||||
{
|
||||
$this->isChanged('preferredTones', $preferredTones);
|
||||
$this->preferredTones = $preferredTones;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -314,20 +463,17 @@ class Target
|
||||
*/
|
||||
public function setPreferredChannels(?array $preferredChannels): static
|
||||
{
|
||||
$this->isChanged('preferredChannels', $preferredChannels);
|
||||
$this->preferredChannels = $preferredChannels;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPosition(): int
|
||||
/**
|
||||
* @return Collection<int, InitiativeAudience>
|
||||
*/
|
||||
public function getInitiativeLinks(): Collection
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function setPosition(?int $position): static
|
||||
{
|
||||
$this->position = $position ?? 0;
|
||||
|
||||
return $this;
|
||||
return $this->initiativeLinks;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user