Skip to content

Commit 1dd18a7

Browse files
committed
MakeAllPrivateServicePublic
1 parent 90b0301 commit 1dd18a7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace ProklUng\ContainerBoilerplate\DI\CompilerPass;
4+
5+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
8+
/**
9+
* Class MakePrivateServicePublic
10+
* Сделать все сервисы публичными.
11+
* @package Prokl\ServiceProvider\CompilePasses
12+
*
13+
* @since 18.07.2021
14+
*/
15+
final class MakeAllPrivateServicePublic implements CompilerPassInterface
16+
{
17+
/**
18+
* @inheritDoc
19+
*/
20+
public function process(ContainerBuilder $container) : void
21+
{
22+
$services = $container->getServiceIds();
23+
24+
foreach ($services as $id => $service) {
25+
if (!$container->hasDefinition($service)) {
26+
continue;
27+
}
28+
29+
$def = $container->getDefinition($service);
30+
$def->setPublic(true);
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)