Skip to content

Commit e2c3260

Browse files
Added find-by-task and remove function (#26)
* added find-by-task function * added remove method
1 parent e7854d3 commit e2c3260

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/Entity/TaskExecutionRepository.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ public function persist(TaskExecutionInterface $execution)
4141
return $this;
4242
}
4343

44+
/**
45+
* {@inheritdoc}
46+
*/
47+
public function remove(TaskExecutionInterface $execution)
48+
{
49+
$this->_em->remove($execution);
50+
51+
return $this;
52+
}
53+
4454
/**
4555
* {@inheritdoc}
4656
*/
@@ -87,6 +97,19 @@ public function findByStartTime(TaskInterface $task, \DateTime $scheduleTime)
8797
}
8898
}
8999

100+
/**
101+
* {@inheritdoc}
102+
*/
103+
public function findByTask(TaskInterface $task)
104+
{
105+
return $this->createQueryBuilder('e')
106+
->innerJoin('e.task', 't')
107+
->where('t.uuid = :uuid')
108+
->setParameter('uuid', $task->getUuid())
109+
->getQuery()
110+
->getResult();
111+
}
112+
90113
/**
91114
* {@inheritdoc}
92115
*/

src/Entity/TaskRepository.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ public function persist(TaskInterface $task)
4646
return $this;
4747
}
4848

49+
/**
50+
* {@inheritdoc}
51+
*/
52+
public function remove(TaskInterface $task)
53+
{
54+
$this->_em->remove($task);
55+
56+
return $this;
57+
}
58+
4959
/**
5060
* {@inheritdoc}
5161
*/

src/Resources/config/doctrine/TaskExecution.orm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<field name="status" type="string" length="20"/>
2525

2626
<many-to-one target-entity="Task\TaskBundle\Entity\Task" field="task">
27-
<join-column name="task_id" referenced-column-name="uuid" on-delete="SET NULL"/>
27+
<join-column name="task_id" referenced-column-name="uuid" on-delete="CASCADE"/>
2828
</many-to-one>
2929

3030
</entity>

0 commit comments

Comments
 (0)