-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathExceptionCompilerPass.php
More file actions
29 lines (23 loc) · 1.08 KB
/
ExceptionCompilerPass.php
File metadata and controls
29 lines (23 loc) · 1.08 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
<?php
declare(strict_types=1);
namespace CodeRhapsodie\DataflowBundle\DependencyInjection\Compiler;
use CodeRhapsodie\DataflowBundle\ExceptionsHandler\FilesystemExceptionHandler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Reference;
class ExceptionCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (!$container->hasParameter('coderhapsodie.dataflow.flysystem_service')) {
return;
}
$flysystem = $container->getParameter('coderhapsodie.dataflow.flysystem_service');
if (!$container->has($flysystem)) {
throw new InvalidArgumentException(\sprintf('Service "%s" not found', $flysystem));
}
$definition = $container->findDefinition(FilesystemExceptionHandler::class);
$definition->setArgument('$filesystem', new Reference($flysystem));
}
}