ContentItemAdmin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 47
ccs 0
cts 30
cp 0
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configureDatagridFilters() 0 3 1
A configureListFields() 0 12 1
A configureFormFields() 0 15 2
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
namespace Zicht\Bundle\PageBundle\Admin;
7
8
use Sonata\AdminBundle\Form\FormMapper;
9
use Sonata\AdminBundle\Datagrid\ListMapper;
10
use Sonata\AdminBundle\Admin\Admin;
11
use Sonata\AdminBundle\Datagrid\DatagridMapper;
12
13
/**
14
 * Admin for content items.
15
 */
16
class ContentItemAdmin 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

16
class ContentItemAdmin extends /** @scrutinizer ignore-deprecated */ Admin
Loading history...
17
{
18
    /**
19
     * @{inheritDoc}
20
     */
21
    protected function configureFormFields(FormMapper $form)
22
    {
23
        if (!$this->isChild()) {
24
            $form->add('page');
25
        } else {
26
            $page = $this->getParentFieldDescription()->getAdmin()->getSubject();
27
28
            // This fixes a weird bug where the router does not get the correct parameters for the containing page.
29
            $this->getParentFieldDescription()->setOption('link_parameters', array('id' => $page->getId()));
30
31
            $form
32
                ->add('weight')
33
                ->add('internalName', 'text', array('disabled' => true, 'read_only' => true, 'required' => false))
34
                ->add('content_item_region', 'zicht_content_item_region', array('container' => $page))
35
                ->add('content_item_type', 'zicht_content_item_type', array('container' => $page));
36
        }
37
    }
38
39
    /**
40
     * @{inheritDoc}
41
     */
42
    protected function configureDatagridFilters(DatagridMapper $filter)
43
    {
44
        $filter->add('page');
45
    }
46
47
48
    /**
49
     * @{inheritDoc}
50
     */
51
    public function configureListFields(ListMapper $listMapper)
52
    {
53
        return $listMapper
54
            ->addIdentifier('page')
55
            ->add(
56
                '_action',
57
                'actions',
58
                array(
59
                    'actions' => array(
60
                        'view'   => array(),
61
                        'edit'   => array(),
62
                        'delete' => array(),
63
                    )
64
                )
65
            );
66
    }
67
}
68