1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ArpTest\LaminasFactory\TestDouble; |
6
|
|
|
|
7
|
|
|
use Arp\LaminasFactory\AbstractFactory; |
8
|
|
|
use Psr\Container\ContainerExceptionInterface; |
9
|
|
|
use Psr\Container\ContainerInterface; |
10
|
|
|
|
11
|
|
|
class ServiceConfigStdClassFactory extends AbstractFactory |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var array<mixed>|null |
15
|
|
|
*/ |
16
|
|
|
private ?array $applicationOptions; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var array<mixed>|null |
20
|
|
|
*/ |
21
|
|
|
private ?array $serviceOptions; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param array<mixed>|null $factoryOptions |
25
|
|
|
* @param array<mixed>|null $applicationOptions |
26
|
|
|
* @param array<mixed>|null $serviceOptions |
27
|
|
|
*/ |
28
|
|
|
public function __construct( |
29
|
|
|
?array $factoryOptions = null, |
30
|
|
|
?array $applicationOptions = null, |
31
|
|
|
?array $serviceOptions = null |
32
|
|
|
) { |
33
|
|
|
$this->applicationOptions = $applicationOptions; |
34
|
|
|
$this->serviceOptions = $serviceOptions; |
35
|
|
|
|
36
|
|
|
parent::__construct($factoryOptions); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param array<mixed>|null $options |
41
|
|
|
* |
42
|
|
|
* @throws ContainerExceptionInterface |
43
|
|
|
*/ |
44
|
|
|
public function __invoke( |
45
|
|
|
ContainerInterface $container, |
46
|
|
|
string $requestedName, |
47
|
|
|
array $options = null |
48
|
|
|
): \stdClass { |
49
|
|
|
$options = $options ?? $this->getServiceOptions($container, $requestedName); |
50
|
|
|
|
51
|
|
|
$object = new \stdClass(); |
52
|
|
|
$object->options = $options; |
53
|
|
|
|
54
|
|
|
return $object; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return array<mixed> |
59
|
|
|
* @throws ContainerExceptionInterface |
60
|
|
|
*/ |
61
|
|
|
public function getApplicationOptions(ContainerInterface $container, ?string $optionsKey = null): array |
62
|
|
|
{ |
63
|
|
|
return $this->applicationOptions ?? parent::getApplicationOptions($container, $optionsKey); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return array<mixed> |
68
|
|
|
* @throws ContainerExceptionInterface |
69
|
|
|
*/ |
70
|
|
|
public function getServiceOptions(ContainerInterface $container, string $requestedName, ?string $key = null): array |
71
|
|
|
{ |
72
|
|
|
return $this->serviceOptions ?? parent::getServiceOptions($container, $requestedName, $key); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|