FormReader   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 12
dl 0
loc 49
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configureCreateFields() 0 9 1
A configureEditFields() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Neimheadh\SonataAnnotationBundle\Reader;
6
7
use Doctrine\Common\Annotations\Reader;
8
use Neimheadh\SonataAnnotationBundle\Annotation\FormField;
9
use ReflectionClass;
10
use Sonata\AdminBundle\Form\FormMapper;
11
12
/**
13
 * Form configuration reader.
14
 *
15
 * @author Marko Kunic <[email protected]>
16
 * @author Mathieu Wambre <[email protected]>
17
 */
18
final class FormReader extends AbstractFieldConfigurationReader
19
{
20
21
    /**
22
     * {@inheritDoc}
23
     */
24
    public function __construct(
25
        Reader $annotationReader
26
    ) {
27
        parent::__construct($annotationReader, FormField::class);
28
    }
29
30
    /**
31
     * Build creation fields configuration.
32
     *
33
     * @param ReflectionClass $class      Entity class.
34
     * @param FormMapper      $formMapper Admin form mapper.
35
     *
36
     * @return void
37
     */
38
    public function configureCreateFields(
39
        ReflectionClass $class,
40
        FormMapper $formMapper
41
    ): void {
42
        $this->configureReaderFields(
43
            $class,
44
            $formMapper,
45
            $this->annotationClass,
46
            FormField::ACTION_CREATE
47
        );
48
    }
49
50
    /**
51
     * Build edit fields configuration.
52
     *
53
     * @param ReflectionClass $class      Entity class.
54
     * @param FormMapper      $formMapper Admin form mapper.
55
     *
56
     * @return void
57
     */
58
    public function configureEditFields(
59
        ReflectionClass $class,
60
        FormMapper $formMapper
61
    ): void {
62
        $this->configureReaderFields(
63
            $class,
64
            $formMapper,
65
            $this->annotationClass,
66
            FormField::ACTION_EDIT
67
        );
68
    }
69
70
}
71