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;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
/**
|
||||
* How important a plan's target is to the plan. The order of the cases is the order of the dropdown.
|
||||
* How important an initiative's audience is to the initiative. The order of the cases is the order of the dropdown.
|
||||
*/
|
||||
enum TargetPriority: string
|
||||
enum AudiencePriority: string
|
||||
{
|
||||
case Primary = 'primary';
|
||||
case Secondary = 'secondary';
|
||||
@@ -15,7 +15,7 @@ enum TargetPriority: string
|
||||
|
||||
public function getLabelKey(): string
|
||||
{
|
||||
return 'mautic.plan.target.priority.'.$this->value;
|
||||
return 'mautic.program.audience.priority.'.$this->value;
|
||||
}
|
||||
|
||||
public function getLabelClass(): string
|
||||
|
||||
@@ -2,17 +2,89 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
/**
|
||||
* @extends CommonRepository<Target>
|
||||
* @extends CommonRepository<Audience>
|
||||
*/
|
||||
class TargetRepository extends CommonRepository
|
||||
class AudienceRepository extends CommonRepository
|
||||
{
|
||||
public function getTableAlias(): string
|
||||
{
|
||||
return 'pt';
|
||||
return 'pa';
|
||||
}
|
||||
|
||||
/**
|
||||
* The contact count of one segment: lead_lists_leads rows with manually_removed = 0.
|
||||
*/
|
||||
public function getSegmentContactCount(int $leadlistId): int
|
||||
{
|
||||
$count = $this->getEntityManager()->getConnection()->fetchOne(
|
||||
'SELECT COUNT(ll.lead_id) FROM lead_lists_leads ll WHERE ll.leadlist_id = :leadlistId AND ll.manually_removed = 0',
|
||||
['leadlistId' => $leadlistId]
|
||||
);
|
||||
|
||||
return (int) $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contact counts (lead_lists_leads rows with manually_removed = 0) for the segments of one
|
||||
* audience, keyed by segment id. Used by the list view to show "Segment (123)".
|
||||
*
|
||||
* @return array<int, int> leadlist_id => contact count
|
||||
*/
|
||||
public function getSegmentContactCounts(int $audienceId): array
|
||||
{
|
||||
$rows = $this->getEntityManager()->getConnection()->fetchAllAssociative(
|
||||
'SELECT s.leadlist_id, COUNT(ll.lead_id) AS cnt
|
||||
FROM initiative_audiences_segments s
|
||||
JOIN lead_lists_leads ll ON ll.leadlist_id = s.leadlist_id AND ll.manually_removed = 0
|
||||
WHERE s.audience_id = :audienceId
|
||||
GROUP BY s.leadlist_id',
|
||||
['audienceId' => $audienceId]
|
||||
);
|
||||
|
||||
$counts = [];
|
||||
foreach ($rows as $row) {
|
||||
$counts[(int) $row['leadlist_id']] = (int) $row['cnt'];
|
||||
}
|
||||
|
||||
return $counts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contact counts for the segments of every audience in the list view, keyed by audience id then
|
||||
* segment id. One query for the whole page.
|
||||
*
|
||||
* @param list<int> $audienceIds
|
||||
*
|
||||
* @return array<int, array<int, int>> audience_id => (leadlist_id => contact count)
|
||||
*/
|
||||
public function getSegmentContactCountsForAudiences(array $audienceIds): array
|
||||
{
|
||||
if ([] === $audienceIds) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$connection = $this->getEntityManager()->getConnection();
|
||||
$rows = $connection->fetchAllAssociative(
|
||||
'SELECT s.audience_id, s.leadlist_id, COUNT(ll.lead_id) AS cnt
|
||||
FROM initiative_audiences_segments s
|
||||
JOIN lead_lists_leads ll ON ll.leadlist_id = s.leadlist_id AND ll.manually_removed = 0
|
||||
WHERE s.audience_id IN (:audienceIds)
|
||||
GROUP BY s.audience_id, s.leadlist_id',
|
||||
['audienceIds' => $audienceIds],
|
||||
['audienceIds' => Connection::PARAM_INT_ARRAY]
|
||||
);
|
||||
|
||||
$counts = [];
|
||||
foreach ($rows as $row) {
|
||||
$counts[(int) $row['audience_id']][(int) $row['leadlist_id']] = (int) $row['cnt'];
|
||||
}
|
||||
|
||||
return $counts;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
/**
|
||||
* The kind of audience a plan's target describes. The order of the cases is the order of the dropdown.
|
||||
* The kind of audience an initiative's audience entry describes. The order of the cases is the order of the dropdown.
|
||||
*/
|
||||
enum TargetType: string
|
||||
enum AudienceType: string
|
||||
{
|
||||
case Persona = 'persona';
|
||||
case Icp = 'icp';
|
||||
@@ -17,11 +17,11 @@ enum TargetType: string
|
||||
|
||||
public function getLabelKey(): string
|
||||
{
|
||||
return 'mautic.plan.target.type.'.$this->value;
|
||||
return 'mautic.program.audience.type.'.$this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* A fixed pictogram per type, for the unlabeled first column of the Targets tab (like the other
|
||||
* A fixed pictogram per type, for the unlabeled first column of the Audiences tab (like the other
|
||||
* tabs' pictograms, from the Remix Icon set Mautic ships).
|
||||
*/
|
||||
public function getIcon(): string
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
/**
|
||||
* For repositories of typed plan items (description items, allocation items, objectives, tasks).
|
||||
* For repositories of typed initiative items (description items, allocation items, objectives, tasks).
|
||||
*/
|
||||
trait CountsItemsByTypeTrait
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
/**
|
||||
* An object with an optional start and end date. Checked by the EndDateAfterStartDate constraint.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
return 'mautic.plan.task.dependency_type.'.$this->value;
|
||||
return 'mautic.program.task.dependency_type.'.$this->value;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
@@ -12,16 +12,16 @@ use Mautic\CategoryBundle\Entity\Category;
|
||||
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||
use Mautic\CoreBundle\Entity\FormEntity;
|
||||
use Mautic\UserBundle\Entity\User;
|
||||
use MauticPlugin\PlanBundle\Validator\Constraints\EndDateAfterStartDate;
|
||||
use MauticPlugin\ProgramBundle\Validator\Constraints\EndDateAfterStartDate;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\NotNull;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
use Symfony\Component\Validator\Constraints\Valid;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
class Plan extends FormEntity implements DateRangeInterface
|
||||
class Initiative extends FormEntity implements DateRangeInterface
|
||||
{
|
||||
public const TABLE_NAME = 'plans';
|
||||
public const TABLE_NAME = 'initiatives';
|
||||
|
||||
public const VERSION_MIN = 1;
|
||||
public const VERSION_MAX = 99;
|
||||
@@ -29,49 +29,51 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* Plan version, 1 to 99. Edited by hand; not related to Doctrine optimistic locking.
|
||||
* Initiative version, 1 to 99. Edited by hand; not related to Doctrine optimistic locking.
|
||||
*/
|
||||
private ?int $version = self::VERSION_MIN;
|
||||
|
||||
/**
|
||||
* @var Collection<int, PlanObjective>
|
||||
* @var Collection<int, InitiativeObjective>
|
||||
*/
|
||||
private Collection $objectives;
|
||||
|
||||
/**
|
||||
* The content of the Description tab. Each item has a type set up by the admin in
|
||||
* Settings > Configuration > Plan.
|
||||
* Settings > Configuration > Initiative.
|
||||
*
|
||||
* @var Collection<int, PlanDescriptionItem>
|
||||
* @var Collection<int, InitiativeDescriptionItem>
|
||||
*/
|
||||
private Collection $descriptionItems;
|
||||
|
||||
/**
|
||||
* The cost lines of the Allocations tab. Each item has a type set up by the admin in
|
||||
* Settings > Configuration > Plan.
|
||||
* Settings > Configuration > Initiative.
|
||||
*
|
||||
* @var Collection<int, PlanAllocationItem>
|
||||
* @var Collection<int, InitiativeAllocationItem>
|
||||
*/
|
||||
private Collection $allocationItems;
|
||||
|
||||
/**
|
||||
* The audiences of the Targets tab. Each target has a fixed type (persona, ICP, …), not an
|
||||
* admin-configured one.
|
||||
* 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
|
||||
* initiative-specific message. See InitiativeAudience.
|
||||
*
|
||||
* @var Collection<int, Target>
|
||||
* @var Collection<int, InitiativeAudience>
|
||||
*/
|
||||
private Collection $targets;
|
||||
private Collection $audiences;
|
||||
|
||||
/**
|
||||
* The links to the stakeholders of the global directory (Planning > Stakeholders), each with the
|
||||
* stakeholder's role in this plan. See PlanStakeholder.
|
||||
* The links to the stakeholders of the global directory (Programs > Stakeholders), each with the
|
||||
* stakeholder's role in this plan. See InitiativeStakeholder.
|
||||
*
|
||||
* @var Collection<int, PlanStakeholder>
|
||||
* @var Collection<int, InitiativeStakeholder>
|
||||
*/
|
||||
private Collection $stakeholders;
|
||||
|
||||
/**
|
||||
* Tasks are managed on their own pages (TaskController). Read-only from the plan: deleting a plan
|
||||
* Tasks are managed on their own pages (TaskController).
|
||||
* Read-only from the initiative: deleting an initiative
|
||||
* deletes its tasks through the database (ON DELETE CASCADE).
|
||||
*
|
||||
* @var Collection<int, Task>
|
||||
@@ -80,7 +82,7 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
|
||||
private ?string $name = null;
|
||||
|
||||
private PlanStatus $status = PlanStatus::Draft;
|
||||
private InitiativeStatus $status = InitiativeStatus::Draft;
|
||||
|
||||
/**
|
||||
* Required in the form. The column is nullable only so that deleting the user doesn't delete the plan (SET NULL).
|
||||
@@ -106,7 +108,7 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
$this->objectives = new ArrayCollection();
|
||||
$this->descriptionItems = new ArrayCollection();
|
||||
$this->allocationItems = new ArrayCollection();
|
||||
$this->targets = new ArrayCollection();
|
||||
$this->audiences = new ArrayCollection();
|
||||
$this->stakeholders = new ArrayCollection();
|
||||
$this->tasks = new ArrayCollection();
|
||||
}
|
||||
@@ -136,11 +138,11 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
$this->addAllocationItem(clone $allocationItem);
|
||||
}
|
||||
|
||||
// A clone gets its own copies of the targets. The stages are shared (ManyToMany), not cloned.
|
||||
$targets = $this->targets;
|
||||
$this->targets = new ArrayCollection();
|
||||
foreach ($targets as $target) {
|
||||
$this->addTarget(clone $target);
|
||||
// A clone keeps the same audiences (directory entries), with fresh links.
|
||||
$audiences = $this->audiences;
|
||||
$this->audiences = new ArrayCollection();
|
||||
foreach ($audiences as $audience) {
|
||||
$this->addAudience(clone $audience);
|
||||
}
|
||||
|
||||
// A clone keeps the same stakeholders (directory entries), with fresh links.
|
||||
@@ -158,8 +160,8 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable(self::TABLE_NAME)
|
||||
->setCustomRepositoryClass(PlanRepository::class)
|
||||
->addIndex(['status'], 'plan_status');
|
||||
->setCustomRepositoryClass(InitiativeRepository::class)
|
||||
->addIndex(['status'], 'program_status');
|
||||
|
||||
// id and name; no description column (replaced by description items).
|
||||
$builder->addIdColumns('name', false);
|
||||
@@ -169,7 +171,7 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
'fieldName' => 'status',
|
||||
'type' => Types::STRING,
|
||||
'length' => 20,
|
||||
'enumType' => PlanStatus::class,
|
||||
'enumType' => InitiativeStatus::class,
|
||||
]);
|
||||
|
||||
$builder->createManyToOne('owner', User::class)
|
||||
@@ -195,8 +197,8 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
->option('default', self::VERSION_MIN)
|
||||
->build();
|
||||
|
||||
$builder->createOneToMany('objectives', PlanObjective::class)
|
||||
->mappedBy('plan')
|
||||
$builder->createOneToMany('objectives', InitiativeObjective::class)
|
||||
->mappedBy('initiative')
|
||||
->cascadePersist()
|
||||
->cascadeRemove()
|
||||
->orphanRemoval()
|
||||
@@ -204,8 +206,8 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
->fetchExtraLazy()
|
||||
->build();
|
||||
|
||||
$builder->createOneToMany('descriptionItems', PlanDescriptionItem::class)
|
||||
->mappedBy('plan')
|
||||
$builder->createOneToMany('descriptionItems', InitiativeDescriptionItem::class)
|
||||
->mappedBy('initiative')
|
||||
->cascadePersist()
|
||||
->cascadeRemove()
|
||||
->orphanRemoval()
|
||||
@@ -213,8 +215,8 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
->fetchExtraLazy()
|
||||
->build();
|
||||
|
||||
$builder->createOneToMany('allocationItems', PlanAllocationItem::class)
|
||||
->mappedBy('plan')
|
||||
$builder->createOneToMany('allocationItems', InitiativeAllocationItem::class)
|
||||
->mappedBy('initiative')
|
||||
->cascadePersist()
|
||||
->cascadeRemove()
|
||||
->orphanRemoval()
|
||||
@@ -222,8 +224,8 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
->fetchExtraLazy()
|
||||
->build();
|
||||
|
||||
$builder->createOneToMany('targets', Target::class)
|
||||
->mappedBy('plan')
|
||||
$builder->createOneToMany('audiences', InitiativeAudience::class)
|
||||
->mappedBy('initiative')
|
||||
->cascadePersist()
|
||||
->cascadeRemove()
|
||||
->orphanRemoval()
|
||||
@@ -231,8 +233,8 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
->fetchExtraLazy()
|
||||
->build();
|
||||
|
||||
$builder->createOneToMany('stakeholders', PlanStakeholder::class)
|
||||
->mappedBy('plan')
|
||||
$builder->createOneToMany('stakeholders', InitiativeStakeholder::class)
|
||||
->mappedBy('initiative')
|
||||
->cascadePersist()
|
||||
->cascadeRemove()
|
||||
->orphanRemoval()
|
||||
@@ -241,7 +243,7 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
->build();
|
||||
|
||||
$builder->createOneToMany('tasks', Task::class)
|
||||
->mappedBy('plan')
|
||||
->mappedBy('initiative')
|
||||
->setOrderBy(['name' => 'ASC'])
|
||||
->fetchExtraLazy()
|
||||
->build();
|
||||
@@ -249,19 +251,19 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->addPropertyConstraint('version', new NotNull(message: 'mautic.plan.version.range'));
|
||||
$metadata->addPropertyConstraint('version', new NotNull(message: 'mautic.program.version.range'));
|
||||
$metadata->addPropertyConstraint('version', new Range(
|
||||
notInRangeMessage: 'mautic.plan.version.range',
|
||||
notInRangeMessage: 'mautic.program.version.range',
|
||||
min: self::VERSION_MIN,
|
||||
max: self::VERSION_MAX,
|
||||
));
|
||||
$metadata->addPropertyConstraint('objectives', new Valid());
|
||||
$metadata->addPropertyConstraint('descriptionItems', new Valid());
|
||||
$metadata->addPropertyConstraint('allocationItems', new Valid());
|
||||
$metadata->addPropertyConstraint('targets', new Valid());
|
||||
$metadata->addPropertyConstraint('audiences', new Valid());
|
||||
$metadata->addPropertyConstraint('stakeholders', new Valid());
|
||||
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required'));
|
||||
$metadata->addPropertyConstraint('owner', new NotBlank(message: 'mautic.plan.owner.required'));
|
||||
$metadata->addPropertyConstraint('owner', new NotBlank(message: 'mautic.program.owner.required'));
|
||||
$metadata->addConstraint(new EndDateAfterStartDate());
|
||||
}
|
||||
|
||||
@@ -293,12 +295,12 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
* 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.
|
||||
*
|
||||
* @return Collection<int, PlanObjective>
|
||||
* @return Collection<int, InitiativeObjective>
|
||||
*/
|
||||
public function getObjectives(): Collection
|
||||
{
|
||||
$objectives = self::sortedByPosition($this->objectives)->toArray();
|
||||
usort($objectives, function (PlanObjective $a, PlanObjective $b): int {
|
||||
usort($objectives, function (InitiativeObjective $a, InitiativeObjective $b): int {
|
||||
// An objective without a priority yet sorts last; ties keep the position order.
|
||||
$pa = $a->getPriority() ?? PHP_INT_MAX;
|
||||
$pb = $b->getPriority() ?? PHP_INT_MAX;
|
||||
@@ -318,31 +320,32 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The targets sorted by position, as a new collection; see getObjectives().
|
||||
* The audience links sorted by position, as a new collection; see getObjectives().
|
||||
*
|
||||
* @return Collection<int, Target>
|
||||
* @return Collection<int, InitiativeAudience>
|
||||
*/
|
||||
public function getTargets(): Collection
|
||||
public function getAudiences(): Collection
|
||||
{
|
||||
return self::sortedByPosition($this->targets);
|
||||
return self::sortedByPosition($this->audiences);
|
||||
}
|
||||
|
||||
public function addTarget(Target $target): static
|
||||
public function addAudience(InitiativeAudience $audience): static
|
||||
{
|
||||
if (!$this->targets->contains($target)) {
|
||||
$target->setPlan($this);
|
||||
$this->targets->add($target);
|
||||
if (!$this->audiences->contains($audience)) {
|
||||
$audience->setInitiative($this);
|
||||
$this->audiences->add($audience);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removing a target from the plan deletes it (orphanRemoval).
|
||||
* Removing an audience link from the plan deletes it (orphanRemoval). The audience itself stays
|
||||
* in the global directory.
|
||||
*/
|
||||
public function removeTarget(Target $target): static
|
||||
public function removeAudience(InitiativeAudience $audience): static
|
||||
{
|
||||
$this->targets->removeElement($target);
|
||||
$this->audiences->removeElement($audience);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -350,17 +353,17 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
/**
|
||||
* The stakeholder links sorted by position, as a new collection; see getObjectives().
|
||||
*
|
||||
* @return Collection<int, PlanStakeholder>
|
||||
* @return Collection<int, InitiativeStakeholder>
|
||||
*/
|
||||
public function getStakeholders(): Collection
|
||||
{
|
||||
return self::sortedByPosition($this->stakeholders);
|
||||
}
|
||||
|
||||
public function addStakeholder(PlanStakeholder $stakeholder): static
|
||||
public function addStakeholder(InitiativeStakeholder $stakeholder): static
|
||||
{
|
||||
if (!$this->stakeholders->contains($stakeholder)) {
|
||||
$stakeholder->setPlan($this);
|
||||
$stakeholder->setInitiative($this);
|
||||
$this->stakeholders->add($stakeholder);
|
||||
}
|
||||
|
||||
@@ -371,17 +374,17 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
* Removing a stakeholder link from the plan deletes it (orphanRemoval). The stakeholder itself
|
||||
* stays in the global directory.
|
||||
*/
|
||||
public function removeStakeholder(PlanStakeholder $stakeholder): static
|
||||
public function removeStakeholder(InitiativeStakeholder $stakeholder): static
|
||||
{
|
||||
$this->stakeholders->removeElement($stakeholder);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addObjective(PlanObjective $objective): static
|
||||
public function addObjective(InitiativeObjective $objective): static
|
||||
{
|
||||
if (!$this->objectives->contains($objective)) {
|
||||
$objective->setPlan($this);
|
||||
$objective->setInitiative($this);
|
||||
$this->objectives->add($objective);
|
||||
}
|
||||
|
||||
@@ -391,7 +394,7 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
/**
|
||||
* Removing an objective from the plan deletes it (orphanRemoval).
|
||||
*/
|
||||
public function removeObjective(PlanObjective $objective): static
|
||||
public function removeObjective(InitiativeObjective $objective): static
|
||||
{
|
||||
$this->objectives->removeElement($objective);
|
||||
|
||||
@@ -401,7 +404,7 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
/**
|
||||
* The description items sorted by position, as a new collection; see getObjectives().
|
||||
*
|
||||
* @return Collection<int, PlanDescriptionItem>
|
||||
* @return Collection<int, InitiativeDescriptionItem>
|
||||
*/
|
||||
public function getDescriptionItems(): Collection
|
||||
{
|
||||
@@ -411,17 +414,17 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
/**
|
||||
* The allocation items sorted by position, as a new collection; see getObjectives().
|
||||
*
|
||||
* @return Collection<int, PlanAllocationItem>
|
||||
* @return Collection<int, InitiativeAllocationItem>
|
||||
*/
|
||||
public function getAllocationItems(): Collection
|
||||
{
|
||||
return self::sortedByPosition($this->allocationItems);
|
||||
}
|
||||
|
||||
public function addAllocationItem(PlanAllocationItem $allocationItem): static
|
||||
public function addAllocationItem(InitiativeAllocationItem $allocationItem): static
|
||||
{
|
||||
if (!$this->allocationItems->contains($allocationItem)) {
|
||||
$allocationItem->setPlan($this);
|
||||
$allocationItem->setInitiative($this);
|
||||
$this->allocationItems->add($allocationItem);
|
||||
}
|
||||
|
||||
@@ -431,7 +434,7 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
/**
|
||||
* Removing an allocation item from the plan deletes it (orphanRemoval).
|
||||
*/
|
||||
public function removeAllocationItem(PlanAllocationItem $allocationItem): static
|
||||
public function removeAllocationItem(InitiativeAllocationItem $allocationItem): static
|
||||
{
|
||||
$this->allocationItems->removeElement($allocationItem);
|
||||
|
||||
@@ -465,7 +468,7 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T of PlanObjective|PlanDescriptionItem|PlanAllocationItem|Target|PlanStakeholder
|
||||
* @template T of InitiativeObjective|InitiativeDescriptionItem|InitiativeAllocationItem|Audience|InitiativeStakeholder
|
||||
*
|
||||
* @param Collection<int, T> $collection
|
||||
*
|
||||
@@ -479,10 +482,10 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
return new ArrayCollection($rows);
|
||||
}
|
||||
|
||||
public function addDescriptionItem(PlanDescriptionItem $descriptionItem): static
|
||||
public function addDescriptionItem(InitiativeDescriptionItem $descriptionItem): static
|
||||
{
|
||||
if (!$this->descriptionItems->contains($descriptionItem)) {
|
||||
$descriptionItem->setPlan($this);
|
||||
$descriptionItem->setInitiative($this);
|
||||
$this->descriptionItems->add($descriptionItem);
|
||||
}
|
||||
|
||||
@@ -492,7 +495,7 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
/**
|
||||
* Removing a description item from the plan deletes it (orphanRemoval).
|
||||
*/
|
||||
public function removeDescriptionItem(PlanDescriptionItem $descriptionItem): static
|
||||
public function removeDescriptionItem(InitiativeDescriptionItem $descriptionItem): static
|
||||
{
|
||||
$this->descriptionItems->removeElement($descriptionItem);
|
||||
|
||||
@@ -500,12 +503,12 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Renumbers objective, description item, allocation item and target positions 0..n-1 following their
|
||||
* Renumbers objective, description item, allocation item and audience positions 0..n-1 following their
|
||||
* current positions, so that the order stays contiguous after rows are added, removed or moved.
|
||||
*/
|
||||
public function normalizePositions(): void
|
||||
{
|
||||
foreach ([$this->objectives, $this->descriptionItems, $this->allocationItems, $this->targets, $this->stakeholders] as $collection) {
|
||||
foreach ([$this->objectives, $this->descriptionItems, $this->allocationItems, $this->audiences, $this->stakeholders] as $collection) {
|
||||
$rows = $collection->toArray();
|
||||
usort($rows, fn ($a, $b): int => $a->getPosition() <=> $b->getPosition());
|
||||
|
||||
@@ -528,7 +531,7 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStatus(): PlanStatus
|
||||
public function getStatus(): InitiativeStatus
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
@@ -537,7 +540,7 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
* Sets completedAt when the plan moves to "completed" from another status,
|
||||
* and clears it when the plan leaves "completed".
|
||||
*/
|
||||
public function setStatus(PlanStatus $status): static
|
||||
public function setStatus(InitiativeStatus $status): static
|
||||
{
|
||||
if ($status === $this->status) {
|
||||
return $this;
|
||||
@@ -546,9 +549,9 @@ class Plan extends FormEntity implements DateRangeInterface
|
||||
// isChanged() can't log enums (they aren't stringable), so log the backing values.
|
||||
$this->addChange('status', [$this->status->value, $status->value]);
|
||||
|
||||
if (PlanStatus::Completed === $status) {
|
||||
if (InitiativeStatus::Completed === $status) {
|
||||
$this->setCompletedAt(new \DateTime());
|
||||
} elseif (PlanStatus::Completed === $this->status) {
|
||||
} elseif (InitiativeStatus::Completed === $this->status) {
|
||||
$this->setCompletedAt(null);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
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
|
||||
* the general currency (CurrencyProvider). Plan::$allocationItems owns the lifecycle: items are saved
|
||||
* the general currency (CurrencyProvider). Initiative::$allocationItems owns the lifecycle: items are saved
|
||||
* 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 > Plan Settings
|
||||
* (parameter plan_allocation_item_types); see ItemTypeProvider.
|
||||
* The type is the key of an allocation item type set up in Settings > Configuration > Initiative Settings
|
||||
* (parameter program_allocation_item_types); see ItemTypeProvider.
|
||||
*/
|
||||
class PlanAllocationItem
|
||||
class InitiativeAllocationItem
|
||||
{
|
||||
public const TABLE_NAME = 'plan_allocation_items';
|
||||
public const TABLE_NAME = 'initiative_allocation_items';
|
||||
|
||||
public const TYPE_MAX_LENGTH = 64;
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
private ?Plan $plan = null;
|
||||
private ?Initiative $initiative = null;
|
||||
|
||||
private ?string $type = null;
|
||||
|
||||
@@ -50,7 +50,7 @@ class PlanAllocationItem
|
||||
public function __clone()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->plan = null;
|
||||
$this->initiative = null;
|
||||
}
|
||||
|
||||
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||
@@ -58,13 +58,13 @@ class PlanAllocationItem
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable(self::TABLE_NAME)
|
||||
->setCustomRepositoryClass(PlanAllocationItemRepository::class);
|
||||
->setCustomRepositoryClass(InitiativeAllocationItemRepository::class);
|
||||
|
||||
$builder->addId();
|
||||
|
||||
$builder->createManyToOne('plan', Plan::class)
|
||||
$builder->createManyToOne('initiative', Initiative::class)
|
||||
->inversedBy('allocationItems')
|
||||
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
|
||||
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createField('type', Types::STRING)
|
||||
@@ -96,7 +96,7 @@ class PlanAllocationItem
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.plan.allocation_item.type.required'));
|
||||
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.program.allocation_item.type.required'));
|
||||
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
|
||||
$metadata->addPropertyConstraint('name', new Length(max: 255));
|
||||
}
|
||||
@@ -106,14 +106,14 @@ class PlanAllocationItem
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPlan(): ?Plan
|
||||
public function getInitiative(): ?Initiative
|
||||
{
|
||||
return $this->plan;
|
||||
return $this->initiative;
|
||||
}
|
||||
|
||||
public function setPlan(?Plan $plan): static
|
||||
public function setInitiative(?Initiative $initiative): static
|
||||
{
|
||||
$this->plan = $plan;
|
||||
$this->initiative = $initiative;
|
||||
|
||||
return $this;
|
||||
}
|
||||
+3
-3
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
/**
|
||||
* @extends CommonRepository<PlanAllocationItem>
|
||||
* @extends CommonRepository<InitiativeAllocationItem>
|
||||
*/
|
||||
class PlanAllocationItemRepository extends CommonRepository
|
||||
class InitiativeAllocationItemRepository extends CommonRepository
|
||||
{
|
||||
use CountsItemsByTypeTrait;
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
* audience deletes its links (ON DELETE CASCADE on both sides).
|
||||
*/
|
||||
class InitiativeAudience
|
||||
{
|
||||
public const TABLE_NAME = 'initiative_audiences_initiative';
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
private ?Initiative $initiative = null;
|
||||
|
||||
private ?Audience $audience = null;
|
||||
|
||||
private AudiencePriority $priority = AudiencePriority::Primary;
|
||||
|
||||
/**
|
||||
* Key message / hook for this audience in this plan, overriding the audience's own positioning.
|
||||
*/
|
||||
private ?string $valueProposition = null;
|
||||
|
||||
/**
|
||||
* Display order within the plan, from 0. Set by drag and drop in the form.
|
||||
*/
|
||||
private int $position = 0;
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->initiative = null;
|
||||
}
|
||||
|
||||
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||
{
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable(self::TABLE_NAME)
|
||||
->setCustomRepositoryClass(InitiativeAudienceRepository::class);
|
||||
|
||||
$builder->addId();
|
||||
|
||||
$builder->createManyToOne('initiative', Initiative::class)
|
||||
->inversedBy('audiences')
|
||||
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createManyToOne('audience', Audience::class)
|
||||
->addJoinColumn('audience_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191).
|
||||
$metadata->mapField([
|
||||
'fieldName' => 'priority',
|
||||
'type' => Types::STRING,
|
||||
'length' => 20,
|
||||
'enumType' => AudiencePriority::class,
|
||||
'options' => ['default' => AudiencePriority::Primary->value],
|
||||
]);
|
||||
|
||||
$builder->createField('valueProposition', Types::TEXT)
|
||||
->columnName('value_proposition')
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createField('position', Types::INTEGER)
|
||||
->option('default', 0)
|
||||
->build();
|
||||
}
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->addPropertyConstraint('audience', new NotBlank(message: 'mautic.program.audience_link.audience.required'));
|
||||
$metadata->addPropertyConstraint('valueProposition', new Length(max: 1000));
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getInitiative(): ?Initiative
|
||||
{
|
||||
return $this->initiative;
|
||||
}
|
||||
|
||||
public function setInitiative(?Initiative $initiative): static
|
||||
{
|
||||
$this->initiative = $initiative;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAudience(): ?Audience
|
||||
{
|
||||
return $this->audience;
|
||||
}
|
||||
|
||||
public function setAudience(?Audience $audience): static
|
||||
{
|
||||
$this->audience = $audience;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPriority(): AudiencePriority
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
public function setPriority(AudiencePriority $priority): static
|
||||
{
|
||||
$this->priority = $priority;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValueProposition(): ?string
|
||||
{
|
||||
return $this->valueProposition;
|
||||
}
|
||||
|
||||
public function setValueProposition(?string $valueProposition): static
|
||||
{
|
||||
$this->valueProposition = $valueProposition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPosition(): int
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function setPosition(?int $position): static
|
||||
{
|
||||
$this->position = $position ?? 0;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
/**
|
||||
* @extends CommonRepository<InitiativeAudience>
|
||||
*/
|
||||
class InitiativeAudienceRepository extends CommonRepository
|
||||
{
|
||||
public function getTableAlias(): string
|
||||
{
|
||||
return 'pa';
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||
@@ -12,21 +12,21 @@ use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* One item of a plan's Description tab. Plan::$descriptionItems owns the lifecycle: items are saved and
|
||||
* One item of a plan's Description tab. Initiative::$descriptionItems owns the lifecycle: items are saved and
|
||||
* deleted with their plan, and are ordered by position.
|
||||
*
|
||||
* The type is the key of a type set up in Settings > Configuration > Plan (parameter
|
||||
* plan_description_item_types); see ItemTypeProvider (kind "description") for its name and description.
|
||||
* The type is the key of a type set up in Settings > Configuration > Initiative (parameter
|
||||
* program_description_item_types); see ItemTypeProvider (kind "description") for its name and description.
|
||||
*/
|
||||
class PlanDescriptionItem
|
||||
class InitiativeDescriptionItem
|
||||
{
|
||||
public const TABLE_NAME = 'plan_description_items';
|
||||
public const TABLE_NAME = 'initiative_description_items';
|
||||
|
||||
public const TYPE_MAX_LENGTH = 64;
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
private ?Plan $plan = null;
|
||||
private ?Initiative $initiative = null;
|
||||
|
||||
private ?string $type = null;
|
||||
|
||||
@@ -40,7 +40,7 @@ class PlanDescriptionItem
|
||||
public function __clone()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->plan = null;
|
||||
$this->initiative = null;
|
||||
}
|
||||
|
||||
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||
@@ -48,13 +48,13 @@ class PlanDescriptionItem
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable(self::TABLE_NAME)
|
||||
->setCustomRepositoryClass(PlanDescriptionItemRepository::class);
|
||||
->setCustomRepositoryClass(InitiativeDescriptionItemRepository::class);
|
||||
|
||||
$builder->addId();
|
||||
|
||||
$builder->createManyToOne('plan', Plan::class)
|
||||
$builder->createManyToOne('initiative', Initiative::class)
|
||||
->inversedBy('descriptionItems')
|
||||
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
|
||||
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createField('type', Types::STRING)
|
||||
@@ -72,7 +72,7 @@ class PlanDescriptionItem
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.plan.description_item.type.required'));
|
||||
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.program.description_item.type.required'));
|
||||
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
|
||||
}
|
||||
|
||||
@@ -81,14 +81,14 @@ class PlanDescriptionItem
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPlan(): ?Plan
|
||||
public function getInitiative(): ?Initiative
|
||||
{
|
||||
return $this->plan;
|
||||
return $this->initiative;
|
||||
}
|
||||
|
||||
public function setPlan(?Plan $plan): static
|
||||
public function setInitiative(?Initiative $initiative): static
|
||||
{
|
||||
$this->plan = $plan;
|
||||
$this->initiative = $initiative;
|
||||
|
||||
return $this;
|
||||
}
|
||||
+3
-3
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
/**
|
||||
* @extends CommonRepository<PlanDescriptionItem>
|
||||
* @extends CommonRepository<InitiativeDescriptionItem>
|
||||
*/
|
||||
class PlanDescriptionItemRepository extends CommonRepository
|
||||
class InitiativeDescriptionItemRepository extends CommonRepository
|
||||
{
|
||||
use CountsItemsByTypeTrait;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||
@@ -14,12 +14,12 @@ use Symfony\Component\Validator\Constraints\Range;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* An objective of a plan. Plan::$objectives owns the lifecycle: objectives are saved and deleted with
|
||||
* An objective of a plan. Initiative::$objectives owns the lifecycle: objectives are saved and deleted with
|
||||
* their plan, and are ordered by position.
|
||||
*/
|
||||
class PlanObjective
|
||||
class InitiativeObjective
|
||||
{
|
||||
public const TABLE_NAME = 'plan_objectives';
|
||||
public const TABLE_NAME = 'initiative_objectives';
|
||||
|
||||
public const TYPE_MAX_LENGTH = 64;
|
||||
|
||||
@@ -28,7 +28,7 @@ class PlanObjective
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
private ?Plan $plan = null;
|
||||
private ?Initiative $initiative = null;
|
||||
|
||||
private ?string $type = null;
|
||||
|
||||
@@ -54,7 +54,7 @@ class PlanObjective
|
||||
public function __clone()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->plan = null;
|
||||
$this->initiative = null;
|
||||
}
|
||||
|
||||
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||
@@ -62,13 +62,13 @@ class PlanObjective
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable(self::TABLE_NAME)
|
||||
->setCustomRepositoryClass(PlanObjectiveRepository::class);
|
||||
->setCustomRepositoryClass(InitiativeObjectiveRepository::class);
|
||||
|
||||
$builder->addId();
|
||||
|
||||
$builder->createManyToOne('plan', Plan::class)
|
||||
$builder->createManyToOne('initiative', Initiative::class)
|
||||
->inversedBy('objectives')
|
||||
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
|
||||
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createField('type', Types::STRING)
|
||||
@@ -100,13 +100,13 @@ class PlanObjective
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->addPropertyConstraint('title', new NotBlank(message: 'mautic.plan.objective.title.required'));
|
||||
$metadata->addPropertyConstraint('title', new NotBlank(message: 'mautic.program.objective.title.required'));
|
||||
$metadata->addPropertyConstraint('title', new Length(max: 255));
|
||||
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.plan.objective.type.required'));
|
||||
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.program.objective.type.required'));
|
||||
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
|
||||
$metadata->addPropertyConstraint('priority', new NotNull(message: 'mautic.plan.objective.priority.range'));
|
||||
$metadata->addPropertyConstraint('priority', new NotNull(message: 'mautic.program.objective.priority.range'));
|
||||
$metadata->addPropertyConstraint('priority', new Range(
|
||||
notInRangeMessage: 'mautic.plan.objective.priority.range',
|
||||
notInRangeMessage: 'mautic.program.objective.priority.range',
|
||||
min: self::PRIORITY_MIN,
|
||||
max: self::PRIORITY_MAX,
|
||||
));
|
||||
@@ -117,14 +117,14 @@ class PlanObjective
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPlan(): ?Plan
|
||||
public function getInitiative(): ?Initiative
|
||||
{
|
||||
return $this->plan;
|
||||
return $this->initiative;
|
||||
}
|
||||
|
||||
public function setPlan(?Plan $plan): static
|
||||
public function setInitiative(?Initiative $initiative): static
|
||||
{
|
||||
$this->plan = $plan;
|
||||
$this->initiative = $initiative;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
/**
|
||||
* @extends CommonRepository<PlanObjective>
|
||||
* @extends CommonRepository<InitiativeObjective>
|
||||
*/
|
||||
class PlanObjectiveRepository extends CommonRepository
|
||||
class InitiativeObjectiveRepository extends CommonRepository
|
||||
{
|
||||
use CountsItemsByTypeTrait;
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
/**
|
||||
* @extends CommonRepository<Plan>
|
||||
* @extends CommonRepository<Initiative>
|
||||
*/
|
||||
class PlanRepository extends CommonRepository
|
||||
class InitiativeRepository extends CommonRepository
|
||||
{
|
||||
public function getTableAlias(): string
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
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
|
||||
* different role on each plan.
|
||||
*
|
||||
* Plan::$stakeholders owns the lifecycle: links are saved and deleted with their plan. Deleting a
|
||||
* Initiative::$stakeholders owns the lifecycle: links are saved and deleted with their plan. Deleting a
|
||||
* stakeholder deletes its links (ON DELETE CASCADE on both sides).
|
||||
*/
|
||||
class PlanStakeholder
|
||||
class InitiativeStakeholder
|
||||
{
|
||||
public const TABLE_NAME = 'plan_stakeholders_plan';
|
||||
public const TABLE_NAME = 'initiative_stakeholders_initiative';
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
private ?Plan $plan = null;
|
||||
private ?Initiative $initiative = null;
|
||||
|
||||
private ?Stakeholder $stakeholder = null;
|
||||
|
||||
/**
|
||||
* The stakeholder's role in this plan, free text.
|
||||
*/
|
||||
private ?string $roleInPlan = null;
|
||||
private ?string $roleInInitiative = null;
|
||||
|
||||
/**
|
||||
* Display order within the plan, from 0. Set by drag and drop in the form.
|
||||
@@ -41,7 +41,7 @@ class PlanStakeholder
|
||||
public function __clone()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->plan = null;
|
||||
$this->initiative = null;
|
||||
}
|
||||
|
||||
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||
@@ -49,21 +49,21 @@ class PlanStakeholder
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable(self::TABLE_NAME)
|
||||
->setCustomRepositoryClass(PlanStakeholderRepository::class);
|
||||
->setCustomRepositoryClass(InitiativeStakeholderRepository::class);
|
||||
|
||||
$builder->addId();
|
||||
|
||||
$builder->createManyToOne('plan', Plan::class)
|
||||
$builder->createManyToOne('initiative', Initiative::class)
|
||||
->inversedBy('stakeholders')
|
||||
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
|
||||
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createManyToOne('stakeholder', Stakeholder::class)
|
||||
->addJoinColumn('stakeholder_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createField('roleInPlan', Types::STRING)
|
||||
->columnName('role_in_plan')
|
||||
$builder->createField('roleInInitiative', Types::STRING)
|
||||
->columnName('role_in_initiative')
|
||||
->length(191)
|
||||
->nullable()
|
||||
->build();
|
||||
@@ -75,8 +75,8 @@ class PlanStakeholder
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->addPropertyConstraint('stakeholder', new \Symfony\Component\Validator\Constraints\NotBlank(message: 'mautic.plan.stakeholder_link.stakeholder.required'));
|
||||
$metadata->addPropertyConstraint('roleInPlan', new Length(max: 191));
|
||||
$metadata->addPropertyConstraint('stakeholder', new \Symfony\Component\Validator\Constraints\NotBlank(message: 'mautic.program.stakeholder_link.stakeholder.required'));
|
||||
$metadata->addPropertyConstraint('roleInInitiative', new Length(max: 191));
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
@@ -84,14 +84,14 @@ class PlanStakeholder
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPlan(): ?Plan
|
||||
public function getInitiative(): ?Initiative
|
||||
{
|
||||
return $this->plan;
|
||||
return $this->initiative;
|
||||
}
|
||||
|
||||
public function setPlan(?Plan $plan): static
|
||||
public function setInitiative(?Initiative $initiative): static
|
||||
{
|
||||
$this->plan = $plan;
|
||||
$this->initiative = $initiative;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -108,14 +108,14 @@ class PlanStakeholder
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRoleInPlan(): ?string
|
||||
public function getRoleInInitiative(): ?string
|
||||
{
|
||||
return $this->roleInPlan;
|
||||
return $this->roleInInitiative;
|
||||
}
|
||||
|
||||
public function setRoleInPlan(?string $roleInPlan): static
|
||||
public function setRoleInInitiative(?string $roleInInitiative): static
|
||||
{
|
||||
$this->roleInPlan = $roleInPlan;
|
||||
$this->roleInInitiative = $roleInInitiative;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
/**
|
||||
* @extends CommonRepository<PlanStakeholder>
|
||||
* @extends CommonRepository<InitiativeStakeholder>
|
||||
*/
|
||||
class PlanStakeholderRepository extends CommonRepository
|
||||
class InitiativeStakeholderRepository extends CommonRepository
|
||||
{
|
||||
public function getTableAlias(): string
|
||||
{
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
enum InitiativeStatus: string
|
||||
{
|
||||
case Draft = 'draft';
|
||||
case Planned = 'planned';
|
||||
case Active = 'active';
|
||||
case Paused = 'paused';
|
||||
case Completed = 'completed';
|
||||
case Archived = 'archived';
|
||||
|
||||
public function getLabelKey(): string
|
||||
{
|
||||
return 'mautic.program.status.'.$this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Bootstrap class of the status label in the tables (the initiative's Status column).
|
||||
*/
|
||||
public function getLabelClass(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Active => 'label-success',
|
||||
self::Completed => 'label-info',
|
||||
self::Paused => 'label-warning',
|
||||
self::Archived => 'label-default',
|
||||
self::Draft, self::Planned => 'label-primary',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
|
||||
enum PlanStatus: string
|
||||
{
|
||||
case Draft = 'draft';
|
||||
case Planned = 'planned';
|
||||
case Active = 'active';
|
||||
case Paused = 'paused';
|
||||
case Completed = 'completed';
|
||||
case Archived = 'archived';
|
||||
|
||||
public function getLabelKey(): string
|
||||
{
|
||||
return 'mautic.plan.status.'.$this->value;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
return 'mautic.plan.task.raci_role.'.$this->value;
|
||||
return 'mautic.program.task.raci_role.'.$this->value;
|
||||
}
|
||||
|
||||
public function getLabelClass(): string
|
||||
|
||||
+22
-22
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
@@ -16,20 +16,20 @@ use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* A stakeholder of the planning: a person, a company or a team involved in the plans ("Agency XYZ",
|
||||
* "Exec committee"). Stakeholders are a global directory (Planning > Stakeholders), independent of
|
||||
* plans; a plan links to them through PlanStakeholder, which carries the stakeholder's role in that
|
||||
* plan.
|
||||
* A stakeholder of the program: a person, a company or a team involved in the initiatives ("Agency XYZ",
|
||||
* "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
|
||||
* initiative.
|
||||
*
|
||||
* The type is the key of a stakeholder type set up in Settings > Configuration > Plan Settings
|
||||
* (parameter plan_stakeholder_types); see ItemTypeProvider (kind "stakeholder").
|
||||
* The type is the key of a stakeholder type set up in Settings > Configuration > Initiative Settings
|
||||
* (parameter program_stakeholder_types); see ItemTypeProvider (kind "stakeholder").
|
||||
*
|
||||
* isPublished (from FormEntity) means "active": an unpublished stakeholder is hidden from the plan
|
||||
* form's stakeholder picker, but keeps its history on the plans it is already linked to.
|
||||
* isPublished (from FormEntity) means "active": an unpublished stakeholder is hidden from the initiative
|
||||
* form's stakeholder picker, but keeps its history on the initiatives it is already linked to.
|
||||
*/
|
||||
class Stakeholder extends FormEntity
|
||||
{
|
||||
public const TABLE_NAME = 'plan_stakeholders';
|
||||
public const TABLE_NAME = 'initiative_stakeholders';
|
||||
|
||||
public const TYPE_MAX_LENGTH = 64;
|
||||
|
||||
@@ -50,16 +50,16 @@ class Stakeholder extends FormEntity
|
||||
private ?string $type = null;
|
||||
|
||||
/**
|
||||
* The links to the plans this stakeholder is assigned to. Inverse side, read-only from here: the
|
||||
* links are managed from the plans (Plan::addStakeholder/removeStakeholder).
|
||||
* The links to the initiatives this stakeholder is assigned to. Inverse side, read-only from here: the
|
||||
* links are managed from the plans (Initiative::addStakeholder/removeStakeholder).
|
||||
*
|
||||
* @var Collection<int, PlanStakeholder>
|
||||
* @var Collection<int, InitiativeStakeholder>
|
||||
*/
|
||||
private Collection $planLinks;
|
||||
private Collection $initiativeLinks;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->planLinks = new ArrayCollection();
|
||||
$this->initiativeLinks = new ArrayCollection();
|
||||
}
|
||||
|
||||
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||
@@ -96,19 +96,19 @@ class Stakeholder extends FormEntity
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createOneToMany('planLinks', PlanStakeholder::class)
|
||||
$builder->createOneToMany('initiativeLinks', InitiativeStakeholder::class)
|
||||
->mappedBy('stakeholder')
|
||||
->fetchExtraLazy()
|
||||
->build();
|
||||
|
||||
$builder->addIndex(['email'], 'plan_stakeholder_email');
|
||||
$builder->addIndex(['email'], 'program_stakeholder_email');
|
||||
}
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required'));
|
||||
$metadata->addPropertyConstraint('name', new Length(max: 191));
|
||||
$metadata->addPropertyConstraint('email', new Email(mode: Email::VALIDATION_MODE_HTML5, message: 'mautic.plan.stakeholder.email.invalid'));
|
||||
$metadata->addPropertyConstraint('email', new Email(mode: Email::VALIDATION_MODE_HTML5, message: 'mautic.program.stakeholder.email.invalid'));
|
||||
$metadata->addPropertyConstraint('email', new Length(max: 191));
|
||||
$metadata->addPropertyConstraint('phone', new Length(max: 50));
|
||||
$metadata->addPropertyConstraint('role', new Length(max: 191));
|
||||
@@ -178,13 +178,13 @@ class Stakeholder extends FormEntity
|
||||
}
|
||||
|
||||
/**
|
||||
* The links to the plans this stakeholder is assigned to, each with its role in that plan.
|
||||
* The links to the initiatives this stakeholder is assigned to, each with its role in that initiative.
|
||||
*
|
||||
* @return Collection<int, PlanStakeholder>
|
||||
* @return Collection<int, InitiativeStakeholder>
|
||||
*/
|
||||
public function getPlanLinks(): Collection
|
||||
public function getInitiativeLinks(): Collection
|
||||
{
|
||||
return $this->planLinks;
|
||||
return $this->initiativeLinks;
|
||||
}
|
||||
|
||||
public function setType(?string $type): static
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
|
||||
+22
-22
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
@@ -10,9 +10,9 @@ use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||
use Mautic\CoreBundle\Entity\FormEntity;
|
||||
use MauticPlugin\PlanBundle\Validator\Constraints\EndDateAfterStartDate;
|
||||
use MauticPlugin\PlanBundle\Validator\Constraints\TaskDates;
|
||||
use MauticPlugin\PlanBundle\Validator\Constraints\ValidTaskDependency;
|
||||
use MauticPlugin\ProgramBundle\Validator\Constraints\EndDateAfterStartDate;
|
||||
use MauticPlugin\ProgramBundle\Validator\Constraints\TaskDates;
|
||||
use MauticPlugin\ProgramBundle\Validator\Constraints\ValidTaskDependency;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\PositiveOrZero;
|
||||
@@ -20,7 +20,7 @@ use Symfony\Component\Validator\Constraints\Range;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* A task of a plan. Every task belongs to exactly one plan.
|
||||
* A task of an initiative. Every task belongs to exactly one initiative.
|
||||
*
|
||||
* 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.
|
||||
@@ -29,15 +29,15 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
* End2End, Start2Start or Start2End. The former parent/child tree is replaced by this dependency
|
||||
* graph.
|
||||
*
|
||||
* RACI: a task is assigned to the plan's stakeholders through TaskRaci rows (R/A/C/I), several
|
||||
* RACI: a task is assigned to the initiative's stakeholders through TaskRaci rows (R/A/C/I), several
|
||||
* stakeholders per role.
|
||||
*
|
||||
* Database rules: deleting the plan deletes its tasks (ON DELETE CASCADE); deleting a task deletes
|
||||
* Database rules: deleting the initiative deletes its tasks (ON DELETE CASCADE); deleting a task deletes
|
||||
* its dependencies and RACI rows (ON DELETE CASCADE).
|
||||
*/
|
||||
class Task extends FormEntity implements DateRangeInterface
|
||||
{
|
||||
public const TABLE_NAME = 'plan_tasks';
|
||||
public const TABLE_NAME = 'initiative_tasks';
|
||||
|
||||
public const TYPE_MAX_LENGTH = 64;
|
||||
|
||||
@@ -48,10 +48,10 @@ class Task extends FormEntity implements DateRangeInterface
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
private ?Plan $plan = null;
|
||||
private ?Initiative $initiative = null;
|
||||
|
||||
/**
|
||||
* Key of a task type set up in Settings > Configuration > Plan Settings (parameter plan_task_types);
|
||||
* Key of a task type set up in Settings > Configuration > Program Settings (parameter program_task_types);
|
||||
* see ItemTypeProvider (kind "task") for its name, description and pictogram.
|
||||
*/
|
||||
private ?string $type = null;
|
||||
@@ -106,9 +106,9 @@ class Task extends FormEntity implements DateRangeInterface
|
||||
|
||||
$builder->addId();
|
||||
|
||||
$builder->createManyToOne('plan', Plan::class)
|
||||
$builder->createManyToOne('initiative', Initiative::class)
|
||||
->inversedBy('tasks')
|
||||
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
|
||||
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createField('type', Types::STRING)
|
||||
@@ -132,7 +132,7 @@ class Task extends FormEntity implements DateRangeInterface
|
||||
'enumType' => TaskStatus::class,
|
||||
'options' => ['default' => TaskStatus::New->value],
|
||||
]);
|
||||
$builder->addIndex(['status'], 'plan_task_status');
|
||||
$builder->addIndex(['status'], 'program_task_status');
|
||||
|
||||
$metadata->mapField([
|
||||
'fieldName' => 'taskKind',
|
||||
@@ -191,11 +191,11 @@ class Task extends FormEntity implements DateRangeInterface
|
||||
{
|
||||
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required'));
|
||||
$metadata->addPropertyConstraint('name', new Length(max: 255));
|
||||
$metadata->addPropertyConstraint('plan', new NotBlank(message: 'mautic.plan.task.plan.required'));
|
||||
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.plan.task.type.required'));
|
||||
$metadata->addPropertyConstraint('initiative', new NotBlank(message: 'mautic.program.task.initiative.required'));
|
||||
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.program.task.type.required'));
|
||||
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
|
||||
$metadata->addPropertyConstraint('plannedWork', new PositiveOrZero(message: 'mautic.plan.task.planned_work.invalid'));
|
||||
$metadata->addPropertyConstraint('plannedWork', new Range(notInRangeMessage: 'mautic.plan.task.planned_work.range', min: 0, max: self::PLANNED_WORK_MAX));
|
||||
$metadata->addPropertyConstraint('plannedWork', new PositiveOrZero(message: 'mautic.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->addConstraint(new EndDateAfterStartDate());
|
||||
$metadata->addConstraint(new TaskDates());
|
||||
$metadata->addConstraint(new ValidTaskDependency());
|
||||
@@ -206,15 +206,15 @@ class Task extends FormEntity implements DateRangeInterface
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPlan(): ?Plan
|
||||
public function getInitiative(): ?Initiative
|
||||
{
|
||||
return $this->plan;
|
||||
return $this->initiative;
|
||||
}
|
||||
|
||||
public function setPlan(?Plan $plan): static
|
||||
public function setInitiative(?Initiative $initiative): static
|
||||
{
|
||||
$this->isChanged('plan', $plan);
|
||||
$this->plan = $plan;
|
||||
$this->isChanged('initiative', $initiative);
|
||||
$this->initiative = $initiative;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||
@@ -17,7 +17,7 @@ use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||
*/
|
||||
class TaskDependency
|
||||
{
|
||||
public const TABLE_NAME = 'plan_task_dependencies';
|
||||
public const TABLE_NAME = 'initiative_task_dependencies';
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
return 'mautic.plan.task.kind.'.$this->value;
|
||||
return 'mautic.program.task.kind.'.$this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
@@ -19,12 +19,12 @@ use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||
*/
|
||||
class TaskRaci
|
||||
{
|
||||
public const TABLE_NAME = 'plan_task_raci';
|
||||
public const TABLE_NAME = 'initiative_task_raci';
|
||||
|
||||
/**
|
||||
* The join table carrying the stakeholders of a RACI row (TaskRaci -> Stakeholder).
|
||||
*/
|
||||
public const JOIN_TABLE_NAME = 'plan_task_raci_stakeholders';
|
||||
public const JOIN_TABLE_NAME = 'initiative_task_raci_stakeholders';
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
@@ -19,7 +19,7 @@ class TaskRepository extends CommonRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the plan, the dependencies (with their depends-on task) and the RACI rows (with their
|
||||
* Loads the initiative, 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.
|
||||
*
|
||||
* @param array<string, mixed> $args
|
||||
@@ -29,8 +29,8 @@ class TaskRepository extends CommonRepository
|
||||
$alias = $this->getTableAlias();
|
||||
|
||||
$args['qb'] = $this->createQueryBuilder($alias)
|
||||
->select($alias, 'pl', 'dep', 'depTask', 'raci', 'raciStakeholder')
|
||||
->leftJoin($alias.'.plan', 'pl')
|
||||
->select($alias, 'init', 'dep', 'depTask', 'raci', 'raciStakeholder')
|
||||
->leftJoin($alias.'.initiative', 'init')
|
||||
->leftJoin($alias.'.dependencies', 'dep')
|
||||
->leftJoin('dep.dependsOn', 'depTask')
|
||||
->leftJoin($alias.'.raci', 'raci')
|
||||
@@ -40,11 +40,11 @@ class TaskRepository extends CommonRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* All tasks of a plan, ordered by name, with their dependencies and RACI rows loaded.
|
||||
* All tasks of an initiative, ordered by name, with their dependencies and RACI rows loaded.
|
||||
*
|
||||
* @return Task[]
|
||||
*/
|
||||
public function findByPlan(Plan $plan): array
|
||||
public function findByInitiative(Initiative $initiative): array
|
||||
{
|
||||
return $this->createQueryBuilder('t')
|
||||
->select('t', 'dep', 'depTask', 'raci', 'raciStakeholder')
|
||||
@@ -52,8 +52,8 @@ class TaskRepository extends CommonRepository
|
||||
->leftJoin('dep.dependsOn', 'depTask')
|
||||
->leftJoin('t.raci', 'raci')
|
||||
->leftJoin('raci.stakeholders', 'raciStakeholder')
|
||||
->where('t.plan = :plan')
|
||||
->setParameter('plan', $plan)
|
||||
->where('t.initiative = :initiative')
|
||||
->setParameter('initiative', $initiative)
|
||||
->orderBy('t.name', 'ASC')
|
||||
->addOrderBy('t.id', 'ASC')
|
||||
->getQuery()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
namespace MauticPlugin\ProgramBundle\Entity;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
return 'mautic.plan.task.status.'.$this->value;
|
||||
return 'mautic.program.task.status.'.$this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user