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\Traits;
13
 
14
use Symfony\Component\Routing\Loader\Configurator\AliasConfigurator;
15
use Symfony\Component\Routing\Loader\Configurator\CollectionConfigurator;
16
use Symfony\Component\Routing\Loader\Configurator\RouteConfigurator;
17
use Symfony\Component\Routing\RouteCollection;
18
 
19
/**
20
 * @author Nicolas Grekas <p@tchwork.com>
21
 */
22
trait AddTrait
23
{
24
    use LocalizedRouteTrait;
25
 
26
    /**
27
     * @var RouteCollection
28
     */
29
    protected $collection;
30
    protected $name = '';
31
    protected $prefixes;
32
 
33
    /**
34
     * Adds a route.
35
     *
36
     * @param string|array $path the path, or the localized paths of the route
37
     */
38
    public function add(string $name, string|array $path): RouteConfigurator
39
    {
40
        $parentConfigurator = $this instanceof CollectionConfigurator ? $this : ($this instanceof RouteConfigurator ? $this->parentConfigurator : null);
41
        $route = $this->createLocalizedRoute($this->collection, $name, $path, $this->name, $this->prefixes);
42
 
43
        return new RouteConfigurator($this->collection, $route, $this->name, $parentConfigurator, $this->prefixes);
44
    }
45
 
46
    public function alias(string $name, string $alias): AliasConfigurator
47
    {
48
        return new AliasConfigurator($this->collection->addAlias($name, $alias));
49
    }
50
 
51
    /**
52
     * Adds a route.
53
     *
54
     * @param string|array $path the path, or the localized paths of the route
55
     */
56
    public function __invoke(string $name, string|array $path): RouteConfigurator
57
    {
58
        return $this->add($name, $path);
59
    }
60
}