Completed
Push — 1.x ( e997bd )
by Sullivan
19:38
created

PathInfoBuilderSlashes::build()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 20
rs 9.4285
cc 3
eloc 12
nc 4
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Sonata package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
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
13
namespace Sonata\DoctrinePHPCRAdminBundle\Route;
14
15
use Sonata\AdminBundle\Builder\RouteBuilderInterface;
16
use Sonata\AdminBundle\Admin\AdminInterface;
17
use Sonata\AdminBundle\Route\RouteCollection;
18
19
class PathInfoBuilderSlashes implements RouteBuilderInterface
20
{
21
    /**
22
     * RouteBuilder that allows slashes in the ids.
23
     *
24
     * {@inheritDoc}
25
     */
26
    function build(AdminInterface $admin, RouteCollection $collection)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
27
    {
28
29
        $collection->add('list');
30
        $collection->add('create');
31
        $collection->add('batch', null, array(), array('_method' => 'POST'));
32
        $collection->add('edit', $admin->getRouterIdParameter().'/edit', array(), array('id' => '.+'));
33
        $collection->add('delete', $admin->getRouterIdParameter().'/delete', array(), array('id' => '.+'));
34
        $collection->add('export');
35
        $collection->add('show', $admin->getRouterIdParameter().'/show', array(), array('id' => '.+', '_method' => 'GET'));
36
37
        if ($admin->isAclEnabled()) {
38
            $collection->add('acl', $admin->getRouterIdParameter().'/acl', array(), array('id' => '.+'));
39
        }
40
41
        // add children urls
42
        foreach ($admin->getChildren() as $children) {
43
            $collection->addCollection($children->getRoutes());
44
        }
45
    }
46
}
47