refactor(plugin): rebrand as MT3SMarketingProgram, release 0.17.0
Rename the plugin's vendor/namespace from experiential/Program to mt3s/MT3SMarketingProgram (composer: mt3s/mautic-marketing-program-bundle): - ProgramBundle -> MT3SMarketingProgramBundle; extension, integration, config support, permissions, events and twig extension renamed likewise - Initiative* -> Program*: controller (InitiativeController -> ProgramController), model, entities, repositories, form types and views (new _tabs/_task_table/_tab_table_filter partials, details page) - Settings config form theme -> _config_mt3smarketingprogramconfig_widget; routes and translations re-prefixed (mt3s_marketing_program_*) - Assets: icon.svg -> mt3s-mp-icon.svg; program.js -> mt3s-mp-program.js (OnLoad hooks renamed mt3sMpProgram*) - Add Command/RefreshStatsCommand; Migrations/Version_0_17_0.php renames the tables to mt3s_mp_program_*
This commit is contained in:
1 parent
687d33d30c
commit
ea88b7a772
131 files changed
+3238
-2836
No files matched your search
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\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 program-specific message ("Key message for this plan"): the same
|
||||
* audience can be primary in one plan and secondary in another.
|
||||
*
|
||||
* Program::$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 ProgramAudience
|
||||
{
|
||||
public const TABLE_NAME = 'mt3s_mp_program_audiences_program';
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
private ?Program $program = 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->program = null;
|
||||
}
|
||||
|
||||
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||
{
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable(self::TABLE_NAME)
|
||||
->setCustomRepositoryClass(ProgramAudienceRepository::class);
|
||||
|
||||
$builder->addId();
|
||||
|
||||
$builder->createManyToOne('program', Program::class)
|
||||
->inversedBy('audiences')
|
||||
->addJoinColumn('program_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: 'mt3s.marketing_program.audience_link.audience.required'));
|
||||
$metadata->addPropertyConstraint('valueProposition', new Length(max: 1000));
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getProgram(): ?Program
|
||||
{
|
||||
return $this->program;
|
||||
}
|
||||
|
||||
public function setProgram(?Program $program): static
|
||||
{
|
||||
$this->program = $program;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user