ContactAdmin::configureFormFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace ClientBundle\Admin;
4
5
use Sonata\AdminBundle\Admin\AbstractAdmin;
6
use Sonata\AdminBundle\Datagrid\ListMapper;
7
use Sonata\AdminBundle\Datagrid\DatagridMapper;
8
use Sonata\AdminBundle\Form\FormMapper;
9
use ClientBundle\Entity\Contact;
10
11
/**
12
 * Class ContactAdmin
13
 */
14
class ContactAdmin extends AbstractAdmin
15
{
16
    protected $parentAssociationMapping = 'client';
17
18
    /**
19
     * @param mixed $object
20
     * @return string
21
     */
22
    public function toString($object)
23
    {
24
        return $object instanceof Contact
25
            ? $object->getDisplayName()
26
            : 'Контакт';
27
    }
28
29
    protected function configureFormFields(FormMapper $formMapper)
30
    {
31
        $formMapper
32
            ->add('type', 'entity', ['class' => 'ClientBundle:ContactType', 'choice_label' => 'name'])
33
            ->add('mean')
34
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
35
            ->add('client', 'entity', array(
36
                'class' => 'ClientBundle:Client',
37
                'choice_label' => 'getDisplayName',
38
                'multiple' => false,
39
            ))
40
        */
41
        ;
42
    }
43
44
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
45
    {
46
        $datagridMapper
47
            ->add('type', null, array(), 'entity', null, ['label' => 'Newtypecontact'])
48
            ->add('mean', null, array(), 'text', null, ['label' => 'Newmeancontact'])
49
            ->add('client', null, array(), 'entity', null, ['class' => 'ClientBundle:Client', 'choice_label' => 'getDisplayName'])
50
        ;
51
    }
52
53
    protected function configureListFields(ListMapper $listMapper)
54
    {
55
        $listMapper->addIdentifier('getDisplayName', 'text', ['label' => 'Newmeancontact'])
56
            ->add('client', 'entity', array('class' => 'ClientBundle:Client', 'choice_label' => 'getDisplayName'))
57
58
        ;
59
    }
60
}
61