|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Zikula package. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright Zikula - https://ziku.la/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Zikula\Bundle\HookBundle\Repository; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
|
17
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
|
18
|
|
|
use Zikula\Bundle\HookBundle\Entity\HookRuntimeEntity; |
|
19
|
|
|
use Zikula\Bundle\HookBundle\RepositoryInterface\HookRuntimeRepositoryInterface; |
|
20
|
|
|
|
|
21
|
|
|
class HookRuntimeRepository extends ServiceEntityRepository implements HookRuntimeRepositoryInterface |
|
22
|
|
|
{ |
|
23
|
|
|
public function __construct(ManagerRegistry $registry) |
|
24
|
|
|
{ |
|
25
|
|
|
parent::__construct($registry, HookRuntimeEntity::class); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function truncate(): void |
|
29
|
|
|
{ |
|
30
|
|
|
$this->_em->createQueryBuilder() |
|
31
|
|
|
->delete(HookRuntimeEntity::class) |
|
32
|
|
|
->getQuery() |
|
33
|
|
|
->execute(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function getOneOrNullByEventName(string $eventName) |
|
37
|
|
|
{ |
|
38
|
|
|
$result = $this->createQueryBuilder('t') |
|
39
|
|
|
->where('t.eventname = :name') |
|
40
|
|
|
->setParameter('name', $eventName) |
|
41
|
|
|
->getQuery() |
|
42
|
|
|
->getResult(); |
|
43
|
|
|
|
|
44
|
|
|
return count($result) > 0 ? array_shift($result) : $result; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function deleteAllByOwner(string $owner): void |
|
48
|
|
|
{ |
|
49
|
|
|
$qb = $this->_em->createQueryBuilder(); |
|
50
|
|
|
$qb->delete(HookRuntimeEntity::class, 't') |
|
51
|
|
|
->where('t.sowner = ?1 OR t.powner = ?2') |
|
52
|
|
|
->setParameters([1 => $owner, 2 => $owner]) |
|
53
|
|
|
->getQuery() |
|
54
|
|
|
->execute(); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|