Completed
Push — master ( 98a062...441031 )
by Ryan
10:10
created

AssignmentFormFields   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 69
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 60 4
1
<?php namespace Anomaly\Streams\Platform\Assignment\Form;
2
3
/**
4
 * Class AssignmentFormFields
5
 *
6
 * @link   http://pyrocms.com/
7
 * @author PyroCMS, Inc. <[email protected]>
8
 * @author Ryan Thompson <[email protected]>
9
 */
10
class AssignmentFormFields
11
{
12
13
    /**
14
     * Handle the form fields.
15
     *
16
     * @param AssignmentFormBuilder $builder
17
     */
18
    public function handle(AssignmentFormBuilder $builder)
19
    {
20
        $builder->setFields(
21
            [
22
                'label'        => [
23
                    'label'        => 'streams::assignment.label.name',
24
                    'instructions' => 'streams::assignment.label.instructions',
25
                    'type'         => 'anomaly.field_type.text',
26
                ],
27
                'placeholder'  => [
28
                    'label'        => 'streams::assignment.placeholder.name',
29
                    'instructions' => 'streams::assignment.placeholder.instructions',
30
                    'type'         => 'anomaly.field_type.text',
31
                ],
32
                'instructions' => [
33
                    'label'        => 'streams::assignment.instructions.name',
34
                    'instructions' => 'streams::assignment.instructions.instructions',
35
                    'type'         => 'anomaly.field_type.textarea',
36
                ],
37
                'warning'      => [
38
                    'label'        => 'streams::assignment.warning.name',
39
                    'instructions' => 'streams::assignment.warning.instructions',
40
                    'type'         => 'anomaly.field_type.text',
41
                ],
42
                'required'     => [
43
                    'label'        => 'streams::assignment.required.label',
44
                    'instructions' => 'streams::assignment.required.instructions',
45
                    'type'         => 'anomaly.field_type.boolean',
46
                ],
47
                'unique'       => [
48
                    'label'        => 'streams::assignment.unique.label',
49
                    'instructions' => 'streams::assignment.unique.instructions',
50
                    'type'         => 'anomaly.field_type.boolean',
51
                ],
52
                'translatable' => [
53
                    'label'        => 'streams::assignment.translatable.label',
54
                    'instructions' => 'streams::assignment.translatable.instructions',
55
                    'type'         => 'anomaly.field_type.boolean',
56
                    'warning'      => function (AssignmentFormBuilder $builder) {
57
58
                        $type = $builder->getFieldType();
59
60
                        return (!$type->getColumnType()) ? 'streams::assignment.translatable.warning' : null;
61
                    },
62
                    'disabled'     => function (AssignmentFormBuilder $builder) {
63
64
                        $stream = $builder->getStream();
65
66
                        if ($stream && !$stream->isTranslatable()) {
67
                            return true;
68
                        }
69
70
                        $type = $builder->getFieldType();
71
72
                        return (!$type->getColumnType());
73
                    },
74
                ],
75
            ]
76
        );
77
    }
78
}
79