Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 915 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 liveuser 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 $parent;
26
 
27
    public function __construct(RouteCollection $parent, RouteCollection $route)
28
    {
29
        $this->parent = $parent;
30
        $this->route = $route;
31
    }
32
 
33
    public function __destruct()
34
    {
35
        $this->parent->addCollection($this->route);
36
    }
37
 
38
    /**
39
     * Sets the prefix to add to the path of all child routes.
40
     *
41
     * @param string|array $prefix the prefix, or the localized prefixes
42
     *
43
     * @return $this
44
     */
45
    final public function prefix($prefix, bool $trailingSlashOnRoot = true): self
46
    {
47
        $this->addPrefix($this->route, $prefix, $trailingSlashOnRoot);
48
 
49
        return $this;
50
    }
51
 
52
    /**
53
     * Sets the prefix to add to the name of all child routes.
54
     *
55
     * @return $this
56
     */
57
    final public function namePrefix(string $namePrefix): self
58
    {
59
        $this->route->addNamePrefix($namePrefix);
60
 
61
        return $this;
62
    }
63
 
64
    /**
65
     * Sets the host to use for all child routes.
66
     *
67
     * @param string|array $host the host, or the localized hosts
68
     *
69
     * @return $this
70
     */
71
    final public function host($host): self
72
    {
73
        $this->addHost($this->route, $host);
74
 
75
        return $this;
76
    }
77
}