Files
Alexandre Gain b138056e43 style: fix indentation, alignment, and docblock annotations
- Correct getChoices() docblock to reflect translated label => enum
  backing value order instead of value => label
- Re-indent Smart Links menu config to match actual array nesting
- Align assignment operators in RefreshStatsCommand
- Add missing newline at end of RefreshStatsCommand.php
2026-11-21 11:23:33 +01:00

120 lines
2.9 KiB
PHP

<?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;
/**
* 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 = 'mt3s_mp_program_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;
}
}