|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Task\TaskBundle\DoctrineStorage; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
6
|
|
|
use Task\Execution\TaskExecutionInterface; |
|
7
|
|
|
use Task\Execution\TaskExecutionRepositoryInterface; |
|
8
|
|
|
use Task\TaskBundle\Entity\TaskExecutionRepository as ORMTaskExecutionRepository; |
|
9
|
|
|
use Task\TaskInterface; |
|
10
|
|
|
|
|
11
|
|
|
class TaskExecutionRepository implements TaskExecutionRepositoryInterface |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var ObjectManager |
|
15
|
|
|
*/ |
|
16
|
|
|
private $objectManager; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var ORMTaskExecutionRepository |
|
20
|
|
|
*/ |
|
21
|
|
|
private $taskExecutionRepository; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @param ObjectManager $objectManager |
|
25
|
|
|
* @param ORMTaskExecutionRepository $taskExecutionRepository |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct(ObjectManager $objectManager, ORMTaskExecutionRepository $taskExecutionRepository) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->objectManager = $objectManager; |
|
30
|
|
|
$this->taskExecutionRepository = $taskExecutionRepository; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritdoc} |
|
35
|
|
|
*/ |
|
36
|
|
|
public function save(TaskExecutionInterface $execution) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->objectManager->persist($execution); |
|
39
|
|
|
$this->objectManager->flush(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* {@inheritdoc} |
|
44
|
|
|
*/ |
|
45
|
|
|
public function add(TaskExecutionInterface $execution) |
|
46
|
|
|
{ |
|
47
|
|
|
$this->objectManager->persist($execution); |
|
48
|
|
|
$this->objectManager->flush(); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* {@inheritdoc} |
|
53
|
|
|
*/ |
|
54
|
|
|
public function findScheduled() |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->taskExecutionRepository->findScheduled(new \DateTime()); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* {@inheritdoc} |
|
61
|
|
|
*/ |
|
62
|
|
|
public function findByStartTime(TaskInterface $task, \DateTime $scheduleTime) |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->taskExecutionRepository->findByStartTime($task, $scheduleTime); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function findAll($limit = null) |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->taskExecutionRepository->findBy([], ['scheduleTime' => 'ASC'], $limit); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function get($uuid) |
|
73
|
|
|
{ |
|
74
|
|
|
// TODO: Implement get() method. |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|