ENHANCEMENT: Deleting with doctrine
This commit is contained in:
parent
2fa127205c
commit
fee48b7a99
|
@ -57,7 +57,7 @@ class Job
|
|||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: "App\Entity\Run", mappedBy: "job")]
|
||||
#[ORM\OneToMany(targetEntity: "App\Entity\Run", mappedBy: "job", cascade: ["remove"])]
|
||||
private Collection $runs;
|
||||
|
||||
public function __construct()
|
||||
|
|
|
@ -9,7 +9,6 @@ use App\Entity\Run;
|
|||
use App\Service\Secret;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use phpseclib3\Crypt\PublicKeyLoader;
|
||||
|
@ -673,8 +672,11 @@ class JobRepository extends EntityRepository
|
|||
|
||||
public function deleteJob(int $id)
|
||||
{
|
||||
$this->getEntityManager()->getConnection()->prepare("DELETE FROM job WHERE id = :id")->executeStatement([':id' => $id]);
|
||||
$this->getEntityManager()->getConnection()->prepare("DELETE FROM run WHERE job_id = :id")->executeStatement([':id' => $id]);
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$job = $this->find($id);
|
||||
$em->remove($job);
|
||||
$em->flush();
|
||||
|
||||
return ['success' => true, 'message' => 'Cronjob succesfully deleted'];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue