Completed
Push — master ( 86bee8...f7a629 )
by Grégoire
04:38
created

GalleryItemAdmin   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 43
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B configureFormFields() 0 24 4
A configureListFields() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project 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
namespace Sonata\MediaBundle\Admin;
13
14
use Sonata\AdminBundle\Admin\AbstractAdmin;
15
use Sonata\AdminBundle\Datagrid\ListMapper;
16
use Sonata\AdminBundle\Form\FormMapper;
17
18
class GalleryItemAdmin extends AbstractAdmin
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    protected function configureFormFields(FormMapper $formMapper)
24
    {
25
        $link_parameters = array();
26
27
        if ($this->hasParentFieldDescription()) {
28
            $link_parameters = $this->getParentFieldDescription()->getOption('link_parameters', array());
29
        }
30
31
        if ($this->hasRequest()) {
32
            $context = $this->getRequest()->get('context', null);
33
34
            if (null !== $context) {
35
                $link_parameters['context'] = $context;
36
            }
37
        }
38
39
        $formMapper
40
            ->add('media', 'sonata_type_model_list', array('required' => false), array(
41
                'link_parameters' => $link_parameters,
42
            ))
43
            ->add('enabled', null, array('required' => false))
44
            ->add('position', 'hidden')
45
        ;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    protected function configureListFields(ListMapper $listMapper)
52
    {
53
        $listMapper
54
            ->add('media')
55
            ->add('gallery')
56
            ->add('position')
57
            ->add('enabled')
58
        ;
59
    }
60
}
61