1
|
|
|
<?php
|
2
|
|
|
|
3
|
|
|
namespace LSB\NumberingBundle\Repository;
|
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityRepository;
|
6
|
|
|
use LSB\NumberingBundle\Entity\NumberingCounterData;
|
7
|
|
|
|
8
|
|
|
/**
|
9
|
|
|
* Class NumberingCounterDataRepository
|
10
|
|
|
* @package LSB\NumberingBundle\Repository
|
11
|
|
|
*/
|
12
|
|
|
class NumberingCounterDataRepository extends EntityRepository
|
13
|
|
|
{
|
14
|
|
|
|
15
|
|
|
/**
|
16
|
|
|
* @param array $config
|
17
|
|
|
* @param string $subjectClass
|
18
|
|
|
* @param string|null $contextObjectValue
|
19
|
|
|
* @return NumberingCounterData|null
|
20
|
|
|
* @throws \Doctrine\ORM\NonUniqueResultException
|
21
|
|
|
*/
|
22
|
|
|
public function getByConfigAndSubjectClass(array $config, string $subjectClass, string $contextObjectValue = null): ?NumberingCounterData
|
23
|
|
|
{
|
24
|
|
|
$qb = $this->createQueryBuilder('ncd')
|
25
|
|
|
->where('ncd.subjectFQCN = :subjectClass')
|
26
|
|
|
->andWhere('ncd.configName = :configName')
|
27
|
|
|
->setParameters([':subjectClass' => $subjectClass, ':configName' => $config['name']]);
|
28
|
|
|
|
29
|
|
|
if (isset($config['time_context']) && !empty($config['time_context'])) {
|
30
|
|
|
$qb
|
31
|
|
|
->andWhere('ncd.timeContext = :timeContext')
|
32
|
|
|
->setParameter(':timeContext', $config['time_context']);
|
33
|
|
|
}
|
34
|
|
|
|
35
|
|
|
if (isset($config['context_object_fqcn']) && !empty($config['context_object_fqcn'])) {
|
36
|
|
|
$qb
|
37
|
|
|
->andWhere('ncd.contextObjectFQCN = :contextObjectFQCN')
|
38
|
|
|
->andWhere('ncd.contextObjectValue = :contextObjectValue')
|
39
|
|
|
->setParameter(':contextObjectFQCN', $config['context_object_fqcn'])
|
40
|
|
|
->setParameter(':contextObjectValue', $contextObjectValue);
|
41
|
|
|
}
|
42
|
|
|
|
43
|
|
|
|
44
|
|
|
return $qb->getQuery()->getOneOrNullResult();
|
45
|
|
|
}
|
46
|
|
|
|
47
|
|
|
|
48
|
|
|
}
|
49
|
|
|
|