-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathCompiledConfigurationFactory.php
More file actions
54 lines (47 loc) · 1.66 KB
/
CompiledConfigurationFactory.php
File metadata and controls
54 lines (47 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare(strict_types=1);
namespace OpenTelemetry\Config\SDK\Configuration\Internal;
use OpenTelemetry\API\Configuration\Config\ComponentProvider;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Config\Definition\NodeInterface;
use Symfony\Component\Config\Definition\Processor;
/**
* @template T
*
* @internal
*/
final readonly class CompiledConfigurationFactory
{
/**
* @param ComponentProvider<T> $rootComponent
* @param NodeInterface $node
* @param iterable<ResourceTrackable> $resourceTrackable
*/
public function __construct(
private ComponentProvider $rootComponent,
private NodeInterface $node,
private iterable $resourceTrackable,
) {
}
/**
* @param array $configs configs to process
* @param ResourceCollection|null $resources resources that can be used for cache invalidation
* @throws InvalidConfigurationException if the configuration is invalid
* @return ComponentPlugin<T> processed component plugin
*/
public function process(array $configs, ?ResourceCollection $resources = null): ComponentPlugin
{
$resources?->addClassResource($this->rootComponent::class);
foreach ($this->resourceTrackable as $trackable) {
$trackable->trackResources($resources);
}
try {
$properties = (new Processor())->process($this->node, $configs);
} finally {
foreach ($this->resourceTrackable as $trackable) {
$trackable->trackResources(null);
}
}
return new ComponentPlugin($properties, $this->rootComponent);
}
}