1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the zibios/sharep. |
7
|
|
|
* |
8
|
|
|
* (c) Zbigniew Ślązak |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace App\Entity\Accounting; |
12
|
|
|
|
13
|
|
|
use App\Entity\EntityInterface; |
14
|
|
|
use App\Entity\Traits; |
15
|
|
|
use App\Enum\Entity\TaskTypeEnum; |
16
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
17
|
|
|
use Doctrine\ORM\Mapping as ORM; |
18
|
|
|
use PascalDeVink\ShortUuid\ShortUuid; |
19
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @ORM\Entity() |
23
|
|
|
* @ORM\Table(name="accounting_tasks") |
24
|
|
|
*/ |
25
|
|
|
class Task implements EntityInterface |
26
|
|
|
{ |
27
|
|
|
use Traits\PropertyIdGeneratedTrait; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
* @ORM\Column(name="type", type="string", length=50, nullable=false) |
32
|
|
|
* |
33
|
|
|
* @Assert\NotBlank() |
34
|
|
|
* @Assert\Choice(callback={"App\Enum\Entity\TaskTypeEnum", "toArray"}) |
35
|
|
|
* @Assert\Length(min="1", max="50") |
36
|
|
|
*/ |
37
|
|
|
private $type; |
38
|
|
|
|
39
|
|
|
//------------------------------------------------------------------------------------------- |
40
|
|
|
/** |
41
|
|
|
* @var ArrayCollection|Journal[] |
42
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Accounting\Journal", mappedBy="task") |
43
|
|
|
*/ |
44
|
|
|
private $journals; |
45
|
|
|
|
46
|
|
|
//------------------------------------------------------------------------------------------- |
47
|
|
|
|
48
|
|
|
public function __construct(TaskTypeEnum $type) |
49
|
|
|
{ |
50
|
|
|
$this->id = ShortUuid::uuid4(); |
51
|
|
|
$this->type = $type->getValue(); |
52
|
|
|
$this->journals = new ArrayCollection(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
//------------------------------------------------------------------------------------------- |
56
|
|
|
|
57
|
|
|
public function getType(): TaskTypeEnum |
58
|
|
|
{ |
59
|
|
|
return new TaskTypeEnum($this->type); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return Journal[]|ArrayCollection |
64
|
|
|
*/ |
65
|
|
|
public function getJournals(): ArrayCollection |
66
|
|
|
{ |
67
|
|
|
return $this->journals; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|