Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <fabien@symfony.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Symfony\Component\Routing\Loader;
13
 
14
use Psr\Container\ContainerInterface;
15
 
16
/**
17
 * A route loader that executes a service from a PSR-11 container to load the routes.
18
 *
19
 * @author Ryan Weaver <ryan@knpuniversity.com>
20
 */
21
class ContainerLoader extends ObjectLoader
22
{
23
    private ContainerInterface $container;
24
 
25
    public function __construct(ContainerInterface $container, string $env = null)
26
    {
27
        $this->container = $container;
28
        parent::__construct($env);
29
    }
30
 
31
    public function supports(mixed $resource, string $type = null): bool
32
    {
33
        return 'service' === $type && \is_string($resource);
34
    }
35
 
36
    protected function getObject(string $id): object
37
    {
38
        return $this->container->get($id);
39
    }
40
}