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.
120 lines
2.9 KiB
PHP
120 lines
2.9 KiB
PHP
<?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;
|
|
|
|
/**
|
|
* One dependency edge of the task dependency graph: this task depends on the depends-on task, with
|
|
* the relation type End2Start, End2End, Start2Start or Start2End.
|
|
*
|
|
* The edge is owned by the task it belongs to (Task::$dependencies); deleting either task deletes
|
|
* the edge (ON DELETE CASCADE both sides).
|
|
*/
|
|
class TaskDependency
|
|
{
|
|
public const TABLE_NAME = 'initiative_task_dependencies';
|
|
|
|
private ?int $id = null;
|
|
|
|
private ?Task $task = null;
|
|
|
|
private ?Task $dependsOn = null;
|
|
|
|
private DependencyType $dependencyType = DependencyType::EndToStart;
|
|
|
|
/**
|
|
* Display order within the task's dependency list, from 0.
|
|
*/
|
|
private int $position = 0;
|
|
|
|
public static function loadMetadata(OrmClassMetadata $metadata): void
|
|
{
|
|
$builder = new ClassMetadataBuilder($metadata);
|
|
|
|
$builder->setTable(self::TABLE_NAME)
|
|
->setCustomRepositoryClass(TaskDependencyRepository::class);
|
|
|
|
$builder->addId();
|
|
|
|
$builder->createManyToOne('task', Task::class)
|
|
->inversedBy('dependencies')
|
|
->addJoinColumn('task_id', 'id', false, false, 'CASCADE')
|
|
->build();
|
|
|
|
$builder->createManyToOne('dependsOn', Task::class)
|
|
->addJoinColumn('depends_on_id', 'id', false, false, 'CASCADE')
|
|
->build();
|
|
|
|
$metadata->mapField([
|
|
'fieldName' => 'dependencyType',
|
|
'columnName' => 'dependency_type',
|
|
'type' => Types::STRING,
|
|
'length' => 20,
|
|
'enumType' => DependencyType::class,
|
|
'options' => ['default' => DependencyType::EndToStart->value],
|
|
]);
|
|
|
|
$builder->createField('position', Types::INTEGER)
|
|
->option('default', 0)
|
|
->build();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getTask(): ?Task
|
|
{
|
|
return $this->task;
|
|
}
|
|
|
|
public function setTask(?Task $task): static
|
|
{
|
|
$this->task = $task;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDependsOn(): ?Task
|
|
{
|
|
return $this->dependsOn;
|
|
}
|
|
|
|
public function setDependsOn(?Task $dependsOn): static
|
|
{
|
|
$this->dependsOn = $dependsOn;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDependencyType(): DependencyType
|
|
{
|
|
return $this->dependencyType;
|
|
}
|
|
|
|
public function setDependencyType(DependencyType $dependencyType): static
|
|
{
|
|
$this->dependencyType = $dependencyType;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPosition(): int
|
|
{
|
|
return $this->position;
|
|
}
|
|
|
|
public function setPosition(?int $position): static
|
|
{
|
|
$this->position = $position ?? 0;
|
|
|
|
return $this;
|
|
}
|
|
}
|