PathInfoBuilderSlashes   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 27
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 19 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\DoctrinePHPCRAdminBundle\Route;
15
16
use Sonata\AdminBundle\Admin\AdminInterface;
17
use Sonata\AdminBundle\Builder\RouteBuilderInterface;
18
use Sonata\AdminBundle\Route\RouteCollection;
19
20
class PathInfoBuilderSlashes implements RouteBuilderInterface
21
{
22
    /**
23
     * RouteBuilder that allows slashes in the ids.
24
     *
25
     * {@inheritdoc}
26
     */
27
    public function build(AdminInterface $admin, RouteCollection $collection): void
28
    {
29
        $collection->add('list');
30
        $collection->add('create');
31
        $collection->add('batch', null, [], [], [], '', [], ['POST']);
32
        $collection->add('edit', $admin->getRouterIdParameter().'/edit', [], ['id' => '.+']);
33
        $collection->add('delete', $admin->getRouterIdParameter().'/delete', [], ['id' => '.+']);
34
        $collection->add('export');
35
        $collection->add('show', $admin->getRouterIdParameter().'/show', [], ['id' => '.+'], [], '', [], ['GET']);
36
37
        if ($admin->isAclEnabled()) {
38
            $collection->add('acl', $admin->getRouterIdParameter().'/acl', [], ['id' => '.+']);
39
        }
40
41
        // add children urls
42
        foreach ($admin->getChildren() as $children) {
43
            $collection->addCollection($children->getRoutes());
44
        }
45
    }
46
}
47