Passed
Push — up-php7 ( a2fe11...4e1c1e )
by Erik
05:48
created

UrlAliasAdmin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 67
ccs 0
cts 46
cp 0
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A configureDatagridFilters() 0 5 1
A configureShowFields() 0 6 1
A configureListFields() 0 14 1
A configureFormFields() 0 12 1
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
7
namespace Zicht\Bundle\UrlBundle\Admin;
8
9
use Sonata\AdminBundle\Datagrid\DatagridMapper;
10
use Sonata\AdminBundle\Datagrid\ListMapper;
11
use Sonata\AdminBundle\Show\ShowMapper;
12
use Sonata\AdminBundle\Admin\Admin;
13
use Sonata\AdminBundle\Form\FormMapper;
14
use Zicht\Bundle\UrlBundle\Entity\UrlAlias;
15
16
/**
17
 * Admin for URL aliases
18
 *
19
 */
20
class UrlAliasAdmin extends Admin
0 ignored issues
show
Deprecated Code introduced by
The class Sonata\AdminBundle\Admin\Admin has been deprecated: since version 3.1, to be removed in 4.0. Use Sonata\AdminBundle\AbstractAdmin instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

20
class UrlAliasAdmin extends /** @scrutinizer ignore-deprecated */ Admin
Loading history...
21
{
22
    protected $datagridValues = array(
23
        '_sort_order' => 'DESC', // Descendant ordering (default = 'ASC')
24
    );
25
26
    /**
27
     * @{inheritDoc}
28
     */
29
    public function configureListFields(ListMapper $listMapper)
30
    {
31
        $listMapper
32
            ->add('id')
33
            ->add('public_url', 'string', array('template' => 'ZichtAdminBundle:CRUD:list_url.html.twig'))
34
            ->add('internal_url', 'string', array('template' => 'ZichtAdminBundle:CRUD:list_url.html.twig'))
35
            ->add(
36
                '_action',
37
                'actions',
38
                array(
39
                    'actions' => array(
40
                        'show' => array(),
41
                        'edit' => array(),
42
                        'delete' => array()
43
                    )
44
                )
45
            );
46
    }
47
48
    /**
49
     * @{inheritDoc}
50
     */
51
    protected function configureDatagridFilters(DatagridMapper $filter)
52
    {
53
        $filter
54
            ->add('public_url')
55
            ->add('internal_url');
56
    }
57
58
    /**
59
     * @{inheritDoc}
60
     */
61
    protected function configureFormFields(FormMapper $form)
62
    {
63
        $form->add('public_url')
64
            ->add('internal_url', 'zicht_url', ['no_transform_public' => true])
65
            ->add(
66
                'mode',
67
                'choice',
68
                array(
69
                    'choices' => array(
70
                        UrlAlias::ALIAS   => 'alias (302 redirect)',
71
                        UrlAlias::MOVE    => 'move (301 redirect)',
72
                        UrlAlias::REWRITE => 'rewrite',
73
                    )
74
                )
75
            );
76
    }
77
78
    /**
79
     * @{inheritDoc}
80
     */
81
    protected function configureShowFields(ShowMapper $show)
82
    {
83
        $show
84
            ->add('public_url')
85
            ->add('internal_url')
86
            ->add('mode');
87
    }
88
}
89