File size: 898 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<?php

declare(strict_types=1);

namespace Mautic\CoreBundle\Test\Container;

use Symfony\Bundle\FrameworkBundle\Test\TestContainer as BaseTestContainer;
use Symfony\Component\DependencyInjection\ContainerInterface;

class TestContainer extends BaseTestContainer
{
    private ContainerInterface $publicContainer;

    /**
     * @param ?object $service
     */
    public function set(string $id, $service): void
    {
        $closure = static function (ContainerInterface $container) use ($id, $service) {
            $container->services[$id] = $service; // @phpstan-ignore-line
            $container->privates[$id] = $service; // @phpstan-ignore-line
        };
        \Closure::bind($closure, null, $this->publicContainer)($this->publicContainer);
    }

    public function setPublicContainer(ContainerInterface $container): void
    {
        $this->publicContainer = $container;
    }
}