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
@@ -0,0 +1,192 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* 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). 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 > Initiative Settings
|
||||
* (parameter program_allocation_item_types); see ItemTypeProvider.
|
||||
*/
|
||||
class InitiativeAllocationItem
|
||||
{
|
||||
public const TABLE_NAME = 'initiative_allocation_items';
|
||||
|
||||
public const TYPE_MAX_LENGTH = 64;
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
private ?Initiative $initiative = null;
|
||||
|
||||
private ?string $type = null;
|
||||
|
||||
private ?string $name = null;
|
||||
|
||||
private ?string $description = null;
|
||||
|
||||
/**
|
||||
* DECIMAL(12,2), as a string (Doctrine keeps decimals as strings for precision).
|
||||
*/
|
||||
private ?string $plannedCost = null;
|
||||
|
||||
private ?string $realCost = 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(InitiativeAllocationItemRepository::class);
|
||||
|
||||
$builder->addId();
|
||||
|
||||
$builder->createManyToOne('initiative', Initiative::class)
|
||||
->inversedBy('allocationItems')
|
||||
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createField('type', Types::STRING)
|
||||
->length(self::TYPE_MAX_LENGTH)
|
||||
->build();
|
||||
|
||||
$builder->createField('name', Types::STRING)
|
||||
->length(255)
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createField('description', Types::TEXT)
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
foreach (['planned', 'real'] as $kind) {
|
||||
$builder->createField($kind.'Cost', Types::DECIMAL)
|
||||
->columnName($kind.'_cost')
|
||||
->precision(12)
|
||||
->scale(2)
|
||||
->nullable()
|
||||
->build();
|
||||
}
|
||||
|
||||
$builder->createField('position', Types::INTEGER)
|
||||
->option('default', 0)
|
||||
->build();
|
||||
}
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$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));
|
||||
}
|
||||
|
||||
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 getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(?string $type): static
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(?string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): static
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlannedCost(): ?string
|
||||
{
|
||||
return $this->plannedCost;
|
||||
}
|
||||
|
||||
public function setPlannedCost(?string $plannedCost): static
|
||||
{
|
||||
$this->plannedCost = $plannedCost;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRealCost(): ?string
|
||||
{
|
||||
return $this->realCost;
|
||||
}
|
||||
|
||||
public function setRealCost(?string $realCost): static
|
||||
{
|
||||
$this->realCost = $realCost;
|
||||
|
||||
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