|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Kreta package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
|
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
declare(strict_types=1); |
|
14
|
|
|
|
|
15
|
|
|
namespace Kreta\TaskManager\Infrastructure\Persistence\Doctrine\ORM\Project\Task; |
|
16
|
|
|
|
|
17
|
|
|
use Kreta\SharedKernel\Domain\Model\Exception; |
|
18
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\MemberId; |
|
19
|
|
|
use Kreta\TaskManager\Domain\Model\Project\ProjectId; |
|
20
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskId; |
|
21
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskPriority; |
|
22
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskProgress; |
|
23
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskSpecificationFactory; |
|
24
|
|
|
|
|
25
|
|
|
class DoctrineORMTaskSpecificationFactory implements TaskSpecificationFactory |
|
26
|
|
|
{ |
|
27
|
|
|
public function buildFilterableSpecification( |
|
28
|
|
|
array $projectIds, |
|
29
|
|
|
?string $title, |
|
30
|
|
|
?TaskId $parentId, |
|
31
|
|
|
?TaskPriority $priority, |
|
32
|
|
|
?TaskProgress $progress, |
|
33
|
|
|
array $assigneeIds = [], |
|
34
|
|
|
array $reporterIds = [], |
|
35
|
|
|
int $offset = 0, |
|
36
|
|
|
int $limit = -1 |
|
37
|
|
|
) { |
|
38
|
|
|
if (empty($projectIds)) { |
|
39
|
|
|
throw new Exception('Needs at least one project id'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
return new DoctrineORMFilterableSpecification( |
|
43
|
|
|
$projectIds, |
|
44
|
|
|
$title, |
|
45
|
|
|
$parentId, |
|
46
|
|
|
$priority, |
|
47
|
|
|
$progress, |
|
48
|
|
|
$assigneeIds, |
|
49
|
|
|
$reporterIds, |
|
50
|
|
|
$offset, |
|
51
|
|
|
$limit |
|
52
|
|
|
); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function buildByProjectSpecification(ProjectId $projectId, int $offset = 0, int $limit = -1) |
|
56
|
|
|
{ |
|
57
|
|
|
return new DoctrineORMFilterableSpecification([$projectId], null, null, null, null, [], [], $offset, $limit); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function buildByAssigneeSpecification(MemberId $assigneeId, int $offset = 0, int $limit = -1) |
|
61
|
|
|
{ |
|
62
|
|
|
return new DoctrineORMFilterableSpecification([], null, null, null, null, [$assigneeId], [], $offset, $limit); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function buildByReporterSpecification(MemberId $reporterId, int $offset = 0, int $limit = -1) |
|
66
|
|
|
{ |
|
67
|
|
|
return new DoctrineORMFilterableSpecification([], null, null, null, null, [], [$reporterId], $offset, $limit); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|