|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Veslo project <https://github.com/symfony-doge/veslo>. |
|
5
|
|
|
* |
|
6
|
|
|
* (C) 2019 Pavel Petrov <[email protected]>. |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* @license https://opensource.org/licenses/GPL-3.0 GPL-3.0 |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
declare(strict_types=1); |
|
15
|
|
|
|
|
16
|
|
|
namespace Veslo\AnthillBundle\Entity\Repository\Vacancy\Roadmap\Configuration\Parameters; |
|
17
|
|
|
|
|
18
|
|
|
use Doctrine\ORM\Cache; |
|
19
|
|
|
use Doctrine\ORM\NonUniqueResultException; |
|
20
|
|
|
use Doctrine\ORM\NoResultException; |
|
21
|
|
|
use Veslo\AnthillBundle\Entity\Vacancy\Roadmap\Configuration\Parameters\HeadHunter as HeadHunterParameters; |
|
22
|
|
|
use Veslo\AnthillBundle\Exception\Vacancy\Roadmap\ConfigurationNotFoundException; |
|
23
|
|
|
use Veslo\AppBundle\Entity\Repository\BaseEntityRepository; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Repository for HeadHunter vacancy search parameters |
|
27
|
|
|
*/ |
|
28
|
|
|
class HeadHunterRepository extends BaseEntityRepository |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* Returns vacancy search parameters for HeadHunter website by roadmap configuration key |
|
32
|
|
|
* |
|
33
|
|
|
* @param string $configurationKey Roadmap configuration key |
|
34
|
|
|
* |
|
35
|
|
|
* @return HeadHunterParameters |
|
36
|
|
|
* |
|
37
|
|
|
* @throws NonUniqueResultException |
|
38
|
|
|
* @throws ConfigurationNotFoundException |
|
39
|
|
|
*/ |
|
40
|
|
|
public function requireByConfigurationKey(string $configurationKey): HeadHunterParameters |
|
41
|
|
|
{ |
|
42
|
|
|
$queryBuilder = $this->createQueryBuilder('p'); |
|
43
|
|
|
|
|
44
|
|
|
$queryBuilder |
|
45
|
|
|
->andWhere($queryBuilder->expr()->eq('p.configurationKey', ':configurationKey')) |
|
46
|
|
|
->setParameter('configurationKey', $configurationKey) |
|
47
|
|
|
->setCacheMode(Cache::MODE_NORMAL) |
|
48
|
|
|
->setCacheable(true) |
|
49
|
|
|
; |
|
50
|
|
|
|
|
51
|
|
|
try { |
|
52
|
|
|
return $queryBuilder->getQuery()->getSingleResult(); |
|
53
|
|
|
} catch (NoResultException $e) { |
|
54
|
|
|
throw ConfigurationNotFoundException::withKey($configurationKey); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|