Skip to content

Commit acf907f

Browse files
committed
Create ContainerIntrospectionService and Symfony bridge
1 parent 012a13e commit acf907f

File tree

9 files changed

+703
-4
lines changed

9 files changed

+703
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2018 Ekosport <[email protected]>
4+
*
5+
* This file is part of Ekosport website.
6+
*
7+
* Ekosport website can not be copied and/or distributed without the express permission of the CIO.
8+
*/
9+
10+
declare(strict_types=1);
11+
12+
namespace steevanb\ContainerIntrospection\Bridge\ContainerIntrospectionBundle;
13+
14+
use Symfony\Component\HttpKernel\Bundle\Bundle;
15+
16+
class ContainerIntrospectionBundle extends Bundle
17+
{
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace steevanb\ContainerIntrospection\Bridge\ContainerIntrospectionBundle\DataCollector;
6+
7+
use steevanb\ContainerIntrospection\ContainerIntrospectionService;
8+
use Symfony\Component\HttpFoundation\{
9+
Request,
10+
Response
11+
};
12+
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
13+
14+
class ContainerIntrospectionCollector extends DataCollector
15+
{
16+
/** @var ContainerIntrospectionService */
17+
protected $introspection;
18+
19+
public function __construct(ContainerIntrospectionService $introspection)
20+
{
21+
$this->introspection = $introspection;
22+
}
23+
24+
public function getName(): string
25+
{
26+
return 'steevanb.container_collector';
27+
}
28+
29+
public function collect(Request $request, Response $response, \Exception $exception = null): void
30+
{
31+
$this->data = [
32+
'containerCachePath' => $this->introspection->getContainerCachePath(),
33+
'containerCacheDir' => $this->introspection->getContainerCacheDir(),
34+
'countContainerCacheFiles' => $this->introspection->countContainerCacheFiles(),
35+
'countContainerCacheLines' => $this->introspection->countContainerCacheLines(),
36+
'containerCacheSize' => $this->introspection->getContainerCacheSize(),
37+
38+
'registeredServices' => $this->introspection->getRegisteredServices(),
39+
'countRegisteredServices' => $this->introspection->countRegisteredServices(),
40+
41+
'instantiatedServices' => $this->introspection->getInstantiatedServices(),
42+
'countInstanciatedServices' => $this->introspection->countInstantiatedServices(),
43+
44+
'publicServices' => $this->introspection->getPublicServices(),
45+
'countPublicServices' => $this->introspection->countPublicServices(),
46+
47+
'privateServices' => $this->introspection->getPrivateServices(),
48+
'countPrivateServices' => $this->introspection->countPrivateServices(),
49+
50+
'parameters' => $this->introspection->getParameters(),
51+
'countParameters' => $this->introspection->countParameters()
52+
];
53+
}
54+
55+
public function reset(): void
56+
{
57+
$this->data = [];
58+
}
59+
60+
public function getContainerCachePath(): string
61+
{
62+
return $this->data['containerCachePath'];
63+
}
64+
65+
public function getContainerCacheDir(): string
66+
{
67+
return $this->data['containerCacheDir'];
68+
}
69+
70+
public function countContainerCacheFiles(): int
71+
{
72+
return $this->data['countContainerCacheFiles'];
73+
}
74+
75+
public function countContainerCacheLines(): int
76+
{
77+
return $this->data['countContainerCacheLines'];
78+
}
79+
80+
public function getContainerCacheSize(): int
81+
{
82+
return $this->data['containerCacheSize'];
83+
}
84+
85+
public function getRegisteredServices(): array
86+
{
87+
return $this->data['registeredServices'];
88+
}
89+
90+
public function countRegisteredServices(): int
91+
{
92+
return $this->data['countRegisteredServices'];
93+
}
94+
95+
public function getInstantiatedServices(): array
96+
{
97+
return $this->data['instantiatedServices'];
98+
}
99+
100+
public function countInstantiatedServices(): int
101+
{
102+
return $this->data['countInstanciatedServices'];
103+
}
104+
105+
public function getPublicServices(): array
106+
{
107+
return $this->data['publicServices'];
108+
}
109+
110+
public function countPublicServices(): int
111+
{
112+
return $this->data['countPublicServices'];
113+
}
114+
115+
public function getPrivateServices(): array
116+
{
117+
return $this->data['privateServices'];
118+
}
119+
120+
public function countPrivateServices(): int
121+
{
122+
return $this->data['countPrivateServices'];
123+
}
124+
125+
public function getParameters(): array
126+
{
127+
return $this->data['parameters'];
128+
}
129+
130+
public function countParameters(): int
131+
{
132+
return $this->data['countParameters'];
133+
}
134+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace steevanb\ContainerIntrospection\Bridge\ContainerIntrospectionBundle\DependencyInjection;
6+
7+
use Symfony\Component\Config\FileLocator;
8+
use Symfony\Component\DependencyInjection\{
9+
ContainerBuilder,
10+
Loader
11+
};
12+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
13+
14+
class ContainerIntrospectionExtension extends Extension
15+
{
16+
public function load(array $configs, ContainerBuilder $container): void
17+
{
18+
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
19+
$loader->load('services.yml');
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
steevanb.container_introspection:
3+
class: steevanb\ContainerIntrospection\ContainerIntrospectionService
4+
arguments: ['@service_container']
5+
public: true
6+
7+
steevanb.container_introspection_data_collector:
8+
class: steevanb\ContainerIntrospection\Bridge\ContainerIntrospectionBundle\DataCollector\ContainerIntrospectionCollector
9+
arguments: ['@steevanb.container_introspection']
10+
tags:
11+
-
12+
name: data_collector
13+
template: 'ContainerIntrospectionBundle:DataCollector:container.html.twig'
14+
id: steevanb.container_collector
15+
public: false

0 commit comments

Comments
 (0)