|
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\Vacancy\ScannerPool; |
|
17
|
|
|
|
|
18
|
|
|
use Veslo\AnthillBundle\Dto\Vacancy\LocationDto; |
|
19
|
|
|
use Veslo\AnthillBundle\Exception\Vacancy\ScannerNotFoundException; |
|
20
|
|
|
use Veslo\AnthillBundle\Vacancy\Scanner\ConveyorAwareScanner; |
|
21
|
|
|
use Veslo\AnthillBundle\Vacancy\ScannerInterface; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Aggregates scanners for vacancy parsing in context of workflow conveyor |
|
25
|
|
|
*/ |
|
26
|
|
|
class ConveyorAwareScannerPool |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Actual scanner pool that manages scan services |
|
30
|
|
|
* Aggregates unique scan services which are exclusively binded to one compatible roadmap for vacancy URL parsing |
|
31
|
|
|
* |
|
32
|
|
|
* @var UniqueScannerPool |
|
33
|
|
|
*/ |
|
34
|
|
|
private $scannerPool; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* ConveyorAwareScannerPool constructor. |
|
38
|
|
|
* |
|
39
|
|
|
* @param UniqueScannerPool $scannerPool Aggregates scan services for vacancy URL parsing |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct(UniqueScannerPool $scannerPool) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->scannerPool = $scannerPool; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Adds scanner service in list of available vacancy URL scanners for specified roadmap |
|
48
|
|
|
* |
|
49
|
|
|
* @param string $roadmapName Roadmap name |
|
50
|
|
|
* @param ScannerInterface $scanner Performs lexical analysis for vacancy data from website |
|
51
|
|
|
* |
|
52
|
|
|
* @return void |
|
53
|
|
|
*/ |
|
54
|
|
|
public function addScanner(string $roadmapName, ScannerInterface $scanner): void |
|
55
|
|
|
{ |
|
56
|
|
|
$this->scannerPool->addScanner($roadmapName, $scanner); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Returns scan service that supports vacancies from specified location |
|
61
|
|
|
* |
|
62
|
|
|
* @param LocationDto $location Context of vacancy location from internet |
|
63
|
|
|
* |
|
64
|
|
|
* @return ConveyorAwareScanner |
|
65
|
|
|
* |
|
66
|
|
|
* @throws ScannerNotFoundException |
|
67
|
|
|
*/ |
|
68
|
|
|
public function requireByLocation(LocationDto $location): ConveyorAwareScanner |
|
69
|
|
|
{ |
|
70
|
|
|
$scanner = $this->scannerPool->requireByLocation($location); |
|
71
|
|
|
|
|
72
|
|
|
return new ConveyorAwareScanner($scanner); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|