- Introduced migration Version_0_13_0 to update task schema: - Changed start_date and end_date to DATE type, truncating time. - Added new columns: task_kind, definition_of_done, planned_work. - Removed parent_id and its index, replacing with a dependency graph. - Created new tables: plan_task_dependencies and plan_task_raci, including a join table for stakeholders. - Updated Version_0_4_0 migration to remove references to parent_id. - Refactored TaskModel to return tasks as flat rows with dependencies and RACI assignments. - Modified task table view to display tasks without hierarchical structure, adding badges for milestones and phases. - Enhanced task form to include dependencies and RACI roles, with appropriate macros for rendering. - Updated task list view to reflect new task structure and display status based on task kind. - Added new validation constraints for task dependencies and dates, ensuring no cycles or self-references. - Removed obsolete ValidTaskParent validation as parent-child relationships are no longer supported. - Updated translations to reflect changes in task management and new fields. - Revised documentation to describe new task handling and features.
334 lines
8.7 KiB
PHP
334 lines
8.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace MauticPlugin\PlanBundle\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\StageBundle\Entity\Stage;
|
|
use Symfony\Component\Validator\Constraints\Length;
|
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
|
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.
|
|
*
|
|
* 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.
|
|
*/
|
|
class Target
|
|
{
|
|
public const TABLE_NAME = 'plan_targets';
|
|
|
|
/**
|
|
* 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',
|
|
];
|
|
|
|
private ?int $id = null;
|
|
|
|
private ?Plan $plan = null;
|
|
|
|
private ?string $name = null;
|
|
|
|
private TargetType $targetType = TargetType::Persona;
|
|
|
|
private TargetPriority $priority = TargetPriority::Primary;
|
|
|
|
/**
|
|
* @var Collection<int, Stage>
|
|
*/
|
|
private Collection $stages;
|
|
|
|
/**
|
|
* Estimated number of people or accounts, or null when unknown.
|
|
*/
|
|
private ?int $estimatedSize = null;
|
|
|
|
/**
|
|
* Demographics, firmographics, job titles, geography.
|
|
*/
|
|
private ?string $profileCriteria = null;
|
|
|
|
/**
|
|
* Problems, triggers, motivations.
|
|
*/
|
|
private ?string $painPoints = null;
|
|
|
|
/**
|
|
* Key message / hook for this target in this plan.
|
|
*/
|
|
private ?string $valueProposition = null;
|
|
|
|
/**
|
|
* Keys of self::CHANNELS the plan means to use for this target.
|
|
*
|
|
* @var list<string>|null
|
|
*/
|
|
private ?array $preferredChannels = null;
|
|
|
|
/**
|
|
* Display order within the plan, from 0. Set by drag and drop in the form.
|
|
*/
|
|
private int $position = 0;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->stages = new ArrayCollection();
|
|
}
|
|
|
|
public function __clone()
|
|
{
|
|
$this->id = null;
|
|
$this->plan = null;
|
|
$this->stages = new ArrayCollection();
|
|
}
|
|
|
|
public static function loadMetadata(OrmClassMetadata $metadata): void
|
|
{
|
|
$builder = new ClassMetadataBuilder($metadata);
|
|
|
|
$builder->setTable(self::TABLE_NAME)
|
|
->setCustomRepositoryClass(TargetRepository::class);
|
|
|
|
$builder->addId();
|
|
|
|
$builder->createManyToOne('plan', Plan::class)
|
|
->inversedBy('targets')
|
|
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
|
|
->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',
|
|
'type' => Types::STRING,
|
|
'length' => 30,
|
|
'enumType' => TargetType::class,
|
|
'options' => ['default' => TargetType::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) {
|
|
$metadata->mapField([
|
|
'fieldName' => $field,
|
|
'columnName' => $column,
|
|
'type' => Types::TEXT,
|
|
'nullable' => true,
|
|
]);
|
|
}
|
|
|
|
$builder->createManyToMany('stages', Stage::class)
|
|
->setJoinTable('plan_target_stages')
|
|
->addJoinColumn('target_id', 'id', false, false, 'CASCADE')
|
|
->addInverseJoinColumn('stage_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)
|
|
->build();
|
|
}
|
|
|
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
|
{
|
|
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.plan.target.name.required'));
|
|
$metadata->addPropertyConstraint('name', new Length(max: 191));
|
|
$metadata->addPropertyConstraint('estimatedSize', new PositiveOrZero(message: 'mautic.plan.target.estimated_size.invalid'));
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
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;
|
|
}
|
|
|
|
public function setName(?string $name): static
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTargetType(): TargetType
|
|
{
|
|
return $this->targetType;
|
|
}
|
|
|
|
public function setTargetType(TargetType $targetType): static
|
|
{
|
|
$this->targetType = $targetType;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPriority(): TargetPriority
|
|
{
|
|
return $this->priority;
|
|
}
|
|
|
|
public function setPriority(TargetPriority $priority): static
|
|
{
|
|
$this->priority = $priority;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Stage>
|
|
*/
|
|
public function getStages(): Collection
|
|
{
|
|
return $this->stages;
|
|
}
|
|
|
|
public function addStage(Stage $stage): static
|
|
{
|
|
if (!$this->stages->contains($stage)) {
|
|
$this->stages->add($stage);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeStage(Stage $stage): static
|
|
{
|
|
$this->stages->removeElement($stage);
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getEstimatedSize(): ?int
|
|
{
|
|
return $this->estimatedSize;
|
|
}
|
|
|
|
public function setEstimatedSize(?int $estimatedSize): static
|
|
{
|
|
$this->estimatedSize = $estimatedSize;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getProfileCriteria(): ?string
|
|
{
|
|
return $this->profileCriteria;
|
|
}
|
|
|
|
public function setProfileCriteria(?string $profileCriteria): static
|
|
{
|
|
$this->profileCriteria = $profileCriteria;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPainPoints(): ?string
|
|
{
|
|
return $this->painPoints;
|
|
}
|
|
|
|
public function setPainPoints(?string $painPoints): static
|
|
{
|
|
$this->painPoints = $painPoints;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getValueProposition(): ?string
|
|
{
|
|
return $this->valueProposition;
|
|
}
|
|
|
|
public function setValueProposition(?string $valueProposition): static
|
|
{
|
|
$this->valueProposition = $valueProposition;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return list<string>|null
|
|
*/
|
|
public function getPreferredChannels(): ?array
|
|
{
|
|
return $this->preferredChannels;
|
|
}
|
|
|
|
/**
|
|
* @param list<string>|null $preferredChannels
|
|
*/
|
|
public function setPreferredChannels(?array $preferredChannels): static
|
|
{
|
|
$this->preferredChannels = $preferredChannels;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPosition(): int
|
|
{
|
|
return $this->position;
|
|
}
|
|
|
|
public function setPosition(?int $position): static
|
|
{
|
|
$this->position = $position ?? 0;
|
|
|
|
return $this;
|
|
}
|
|
}
|