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\Configurator;
13
 
14
use Symfony\Component\Routing\RouteCollection;
15
 
16
/**
17
 * @author Nicolas Grekas <p@tchwork.com>
18
 */
19
class ImportConfigurator
20
{
21
    use Traits\HostTrait;
22
    use Traits\PrefixTrait;
23
    use Traits\RouteTrait;
24
 
25
    private RouteCollection $parent;
26
 
27
    public function __construct(RouteCollection $parent, RouteCollection $route)
28
    {
29
        $this->parent = $parent;
30
        $this->route = $route;
31
    }
32
 
33
    public function __sleep(): array
34
    {
35
        throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
36
    }
37
 
38
    public function __wakeup()
39
    {
40
        throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
41
    }
42
 
43
    public function __destruct()
44
    {
45
        $this->parent->addCollection($this->route);
46
    }
47
 
48
    /**
49
     * Sets the prefix to add to the path of all child routes.
50
     *
51
     * @param string|array $prefix the prefix, or the localized prefixes
52
     *
53
     * @return $this
54
     */
55
    final public function prefix(string|array $prefix, bool $trailingSlashOnRoot = true): static
56
    {
57
        $this->addPrefix($this->route, $prefix, $trailingSlashOnRoot);
58
 
59
        return $this;
60
    }
61
 
62
    /**
63
     * Sets the prefix to add to the name of all child routes.
64
     *
65
     * @return $this
66
     */
67
    final public function namePrefix(string $namePrefix): static
68
    {
69
        $this->route->addNamePrefix($namePrefix);
70
 
71
        return $this;
72
    }
73
 
74
    /**
75
     * Sets the host to use for all child routes.
76
     *
77
     * @param string|array $host the host, or the localized hosts
78
     *
79
     * @return $this
80
     */
81
    final public function host(string|array $host): static
82
    {
83
        $this->addHost($this->route, $host);
84
 
85
        return $this;
86
    }
87
}