1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Facile\SentryModule\Log\Writer; |
4
|
|
|
|
5
|
|
|
use Interop\Container\ContainerInterface; |
6
|
|
|
use Interop\Container\Exception\ContainerException; |
7
|
|
|
use Zend\ServiceManager\Exception\ServiceNotCreatedException; |
8
|
|
|
use Zend\ServiceManager\Exception\ServiceNotFoundException; |
9
|
|
|
use Zend\ServiceManager\FactoryInterface; |
10
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
11
|
|
|
|
12
|
|
|
class SentryFactory implements FactoryInterface |
|
|
|
|
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* zend-servicemanager v2 support for invocation options. |
16
|
|
|
* |
17
|
|
|
* @param array |
18
|
|
|
*/ |
19
|
|
|
protected $creationOptions; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Create an object |
23
|
|
|
* |
24
|
|
|
* @param ContainerInterface $container |
25
|
|
|
* @param string $requestedName |
26
|
|
|
* @param null|array $options |
27
|
|
|
* @return Sentry |
28
|
|
|
* @throws \Zend\Log\Exception\InvalidArgumentException |
29
|
|
|
* @throws \Interop\Container\Exception\NotFoundException |
30
|
|
|
* @throws \RuntimeException |
31
|
|
|
* @throws ServiceNotFoundException if unable to resolve the service. |
32
|
|
|
* @throws ServiceNotCreatedException if an exception is raised when |
33
|
|
|
* creating a service. |
34
|
|
|
* @throws ContainerException if any other error occurs |
35
|
|
|
*/ |
36
|
2 |
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
37
|
|
|
{ |
38
|
2 |
|
$options = $options ?: []; |
39
|
|
|
|
40
|
2 |
|
if (!array_key_exists('client', $options)) { |
41
|
1 |
|
throw new \RuntimeException('No client specified'); |
42
|
|
|
} |
43
|
|
|
|
44
|
1 |
|
$options['client'] = $container->get($options['client']); |
45
|
|
|
|
46
|
1 |
|
return new Sentry($options); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Create service |
51
|
|
|
* |
52
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
53
|
|
|
* @return Sentry |
54
|
|
|
*/ |
55
|
2 |
|
public function createService(ServiceLocatorInterface $serviceLocator) |
56
|
|
|
{ |
57
|
2 |
|
return $this($serviceLocator, Sentry::class, $this->creationOptions); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* zend-servicemanager v2 support for invocation options. |
62
|
|
|
* |
63
|
|
|
* @param array $options |
64
|
|
|
* @return void |
65
|
|
|
*/ |
66
|
1 |
|
public function setCreationOptions(array $options) |
67
|
|
|
{ |
68
|
1 |
|
$this->creationOptions = $options; |
69
|
1 |
|
} |
70
|
|
|
} |
71
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.