feat: Add TargetType form and migration for plan targets

- Implemented TargetType form for managing target details including name, type, priority, stages, estimated size, profile criteria, pain points, value proposition, and preferred channels.
- Created migration scripts for adding type and priority columns to plan objectives and tasks.
- Added migration for creating plan targets and plan target stages tables, including foreign key constraints.
- Introduced stakeholder management with forms and views for creating, editing, and listing stakeholders.
- Enhanced UI with read more functionality for long text descriptions and filtering options in plan tab tables.
This commit is contained in:
Alexandre Gain committed 2026-11-08 11:54:25 +01:00
1 parent 8c8d7a6f95
commit 8696acd01c
52 files changed
+3178 -125

No files matched your search

+197
View File
@@ -0,0 +1,197 @@
<?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\CoreBundle\Entity\FormEntity;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\Length;
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.
*
* The type is the key of a stakeholder type set up in Settings > Configuration > Plan Settings
* (parameter plan_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.
*/
class Stakeholder extends FormEntity
{
public const TABLE_NAME = 'plan_stakeholders';
public const TYPE_MAX_LENGTH = 64;
private ?int $id = null;
private ?string $name = null;
private ?string $email = null;
/**
* Free input, normalized to E.164 on save when it parses (StakeholderModel); the raw input is
* kept when it doesn't.
*/
private ?string $phone = null;
private ?string $role = null;
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).
*
* @var Collection<int, PlanStakeholder>
*/
private Collection $planLinks;
public function __construct()
{
$this->planLinks = new ArrayCollection();
}
public static function loadMetadata(OrmClassMetadata $metadata): void
{
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(StakeholderRepository::class);
$builder->addId();
$builder->createField('name', Types::STRING)
->length(191)
->build();
$builder->createField('email', Types::STRING)
->length(191)
->nullable()
->build();
// Indexed for duplicate detection.
$builder->createField('phone', Types::STRING)
->length(50)
->nullable()
->build();
$builder->createField('role', Types::STRING)
->length(191)
->nullable()
->build();
$builder->createField('type', Types::STRING)
->length(self::TYPE_MAX_LENGTH)
->nullable()
->build();
$builder->createOneToMany('planLinks', PlanStakeholder::class)
->mappedBy('stakeholder')
->fetchExtraLazy()
->build();
$builder->addIndex(['email'], 'plan_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 Length(max: 191));
$metadata->addPropertyConstraint('phone', new Length(max: 50));
$metadata->addPropertyConstraint('role', new Length(max: 191));
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->isChanged('name', $name);
$this->name = $name;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): static
{
$this->isChanged('email', $email);
$this->email = $email;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): static
{
$this->isChanged('phone', $phone);
$this->phone = $phone;
return $this;
}
public function getRole(): ?string
{
return $this->role;
}
public function setRole(?string $role): static
{
$this->isChanged('role', $role);
$this->role = $role;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
/**
* The links to the plans this stakeholder is assigned to, each with its role in that plan.
*
* @return Collection<int, PlanStakeholder>
*/
public function getPlanLinks(): Collection
{
return $this->planLinks;
}
public function setType(?string $type): static
{
$this->isChanged('type', $type);
$this->type = $type;
return $this;
}
}