|
1
|
|
|
<?php |
|
2
|
|
|
namespace Kartenmacherei\RestFramework; |
|
3
|
|
|
|
|
4
|
|
|
use Kartenmacherei\NewRelic\NewRelicFactory; |
|
5
|
|
|
use Kartenmacherei\RestFramework\Monitoring\MonitoringLocator; |
|
6
|
|
|
use Kartenmacherei\RestFramework\Monitoring\NewRelicMonitoring; |
|
7
|
|
|
use Kartenmacherei\RestFramework\Monitoring\VoidTransactionMonitoring; |
|
8
|
|
|
use Kartenmacherei\RestFramework\Monitoring\TransactionMonitoring; |
|
9
|
|
|
use Kartenmacherei\RestFramework\Monitoring\TransactionNameMapper; |
|
10
|
|
|
use Kartenmacherei\RestFramework\Router\RouterChain; |
|
11
|
|
|
|
|
12
|
|
|
class Factory |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var Config |
|
16
|
|
|
*/ |
|
17
|
|
|
private $config; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @param Config $config |
|
21
|
|
|
*/ |
|
22
|
|
|
public function __construct(Config $config) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->config = $config; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @return RouterChain |
|
29
|
|
|
*/ |
|
30
|
|
|
public function createRouterChain(): RouterChain |
|
31
|
|
|
{ |
|
32
|
|
|
return new RouterChain(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @return ActionMapper |
|
37
|
|
|
*/ |
|
38
|
|
|
public function createActionMapper(): ActionMapper |
|
39
|
|
|
{ |
|
40
|
|
|
return new ActionMapper(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function createTransactionMonitoring(): TransactionMonitoring |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->createMonitoringLocator()->getTransactionMonitoring(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @codeCoverageIgnore |
|
50
|
|
|
*/ |
|
51
|
|
|
public function createConcreteTransactionMonitoring(): TransactionMonitoring |
|
52
|
|
|
{ |
|
53
|
|
|
$appName = $this->config->getApplicationName(); |
|
54
|
|
|
$newRelicAgent = $this->createNewRelicFactory()->createNewRelicAgent($appName); |
|
55
|
|
|
|
|
56
|
|
|
return new NewRelicMonitoring($newRelicAgent); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function createVoidTransactionMonitoring(): TransactionMonitoring |
|
60
|
|
|
{ |
|
61
|
|
|
return new VoidTransactionMonitoring(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function createTransactionNameMapper(): TransactionNameMapper |
|
65
|
|
|
{ |
|
66
|
|
|
return new TransactionNameMapper($this->config->getTransactionMapping()); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
private function createMonitoringLocator(): MonitoringLocator |
|
70
|
|
|
{ |
|
71
|
|
|
return new MonitoringLocator($this->config->isTransactionMonitoringEnabled(), $this); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
private function createNewRelicFactory(): NewRelicFactory |
|
75
|
|
|
{ |
|
76
|
|
|
return new NewRelicFactory(); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|