Completed
Pull Request — develop (#17)
by Mario
09:34
created

Form   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 162
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 14

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 14
dl 0
loc 162
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
1
<?php
2
3
namespace App\Entity;
4
5
use Ds\Component\Locale\Model\Type\Localizable;
6
use Ds\Component\Model\Attribute\Accessor;
7
use Ds\Component\Model\Type\Deletable;
8
use Ds\Component\Model\Type\Identifiable;
9
use Ds\Component\Model\Type\Ownable;
10
use Ds\Component\Model\Type\Uuidentifiable;
11
use Ds\Component\Model\Type\Versionable;
12
use Ds\Component\Tenant\Model\Attribute\Accessor as TenantAccessor;
13
use Ds\Component\Tenant\Model\Type\Tenantable;
14
use Ds\Component\Translation\Model\Type\Translatable;
15
use Ds\Component\Translation\Model\Attribute\Accessor as TranslationAccessor;
16
use Knp\DoctrineBehaviors\Model as Behavior;
17
18
use ApiPlatform\Core\Annotation\ApiResource;
19
use ApiPlatform\Core\Annotation\ApiProperty;
20
use App\Validator\Constraints\Form as FormAssert;
21
use Doctrine\ORM\Mapping as ORM;
22
use Ds\Component\Locale\Model\Annotation\Locale;
23
use Ds\Component\Translation\Model\Annotation\Translate;
24
use Symfony\Bridge\Doctrine\Validator\Constraints as ORMAssert;
25
use Symfony\Component\Serializer\Annotation as Serializer;
26
use Symfony\Component\Validator\Constraints as Assert;
27
28
/**
29
 * Class Form
30
 *
31
 * @ApiResource(
32
 *      attributes={
33
 *          "normalization_context"={
34
 *              "groups"={"form_output"}
35
 *          },
36
 *          "denormalization_context"={
37
 *              "groups"={"form_input"}
38
 *          },
39
 *          "filters"={
40
 *              "app.form.search",
41
 *              "app.form.search_translation",
42
 *              "app.form.date",
43
 *              "app.form.order"
44
 *          }
45
 *      }
46
 * )
47
 * @ORM\Entity(repositoryClass="App\Repository\FormRepository")
48
 * @ORM\Table(name="app_form")
49
 * @ORM\Cache(usage="NONSTRICT_READ_WRITE")
50
 * @FormAssert\Config\Valid
51
 */
52
class Form implements Identifiable, Uuidentifiable, Ownable, Translatable, Localizable, Deletable, Versionable, Tenantable
53
{
54
    use Behavior\Translatable\Translatable;
55
    use Behavior\Timestampable\Timestampable;
56
    use Behavior\SoftDeletable\SoftDeletable;
57
58
    use Accessor\Id;
59
    use Accessor\Uuid;
60
    use Accessor\Owner;
61
    use Accessor\OwnerUuid;
62
    use Accessor\Type;
63
    use Accessor\Config;
64
    use TranslationAccessor\Title;
65
    use TranslationAccessor\Description;
66
    use Accessor\Deleted;
67
    use Accessor\Version;
68
    use TenantAccessor\Tenant;
69
70
    /**
71
     * @const string
72
     */
73
    const TYPE_FORMIO = 'formio';
74
75
    /**
76
     * @var integer
77
     * @ApiProperty(identifier=false, writable=false)
78
     * @Serializer\Groups({"form_output"})
79
     * @ORM\Id
80
     * @ORM\GeneratedValue(strategy="AUTO")
81
     * @ORM\Column(name="id", type="integer")
82
     */
83
    private $id;
84
85
    /**
86
     * @var string
87
     * @ApiProperty(identifier=true, writable=false)
88
     * @Serializer\Groups({"form_output"})
89
     * @ORM\Column(name="uuid", type="guid", unique=true)
90
     * @Assert\Uuid
91
     */
92
    private $uuid;
93
94
    /**
95
     * @var \DateTime
96
     * @ApiProperty(writable=false)
97
     * @Serializer\Groups({"form_output"})
98
     */
99
    protected $createdAt;
100
101
    /**
102
     * @var \DateTime
103
     * @ApiProperty(writable=false)
104
     * @Serializer\Groups({"form_output"})
105
     */
106
    protected $updatedAt;
107
108
    /**
109
     * @var \DateTime
110
     * @ApiProperty(writable=false)
111
     * @Serializer\Groups({"form_output"})
112
     */
113
    protected $deletedAt;
114
115
    /**
116
     * @var string
117
     * @ApiProperty
118
     * @Serializer\Groups({"form_output", "form_input"})
119
     * @ORM\Column(name="`owner`", type="string", length=255, nullable=true)
120
     * @Assert\NotBlank
121
     * @Assert\Length(min=1, max=255)
122
     */
123
    private $owner;
124
125
    /**
126
     * @var string
127
     * @ApiProperty
128
     * @Serializer\Groups({"form_output", "form_input"})
129
     * @ORM\Column(name="owner_uuid", type="guid", nullable=true)
130
     * @Assert\NotBlank
131
     * @Assert\Uuid
132
     */
133
    private $ownerUuid;
134
135
    /**
136
     * @var string
137
     * @ApiProperty
138
     * @Serializer\Groups({"form_output", "form_input"})
139
     * @ORM\Column(name="type", type="string", length=255, nullable=true)
140
     * @Assert\NotBlank
141
     * @Assert\Length(min=1, max=255)
142
     */
143
    private $type;
144
145
    /**
146
     * @var array
147
     * @ApiProperty
148
     * @Serializer\Groups({"form_output", "form_input"})
149
     * @ORM\Column(name="config", type="json_array")
150
     * @Assert\Type("array")
151
     */
152
    private $config;
153
154
    /**
155
     * @var array
156
     * @ApiProperty
157
     * @Serializer\Groups({"form_output", "form_input"})
158
     * @Assert\Type("array")
159
     * @Assert\NotBlank
160
     * @Assert\All({
161
     *     @Assert\NotBlank,
162
     *     @Assert\Length(min=1)
163
     * })
164
     * @Locale
165
     * @Translate
166
     */
167
    private $title;
168
169
    /**
170
     * @var array
171
     * @ApiProperty
172
     * @Serializer\Groups({"form_output", "form_input"})
173
     * @Assert\Type("array")
174
     * @Assert\NotBlank
175
     * @Assert\All({
176
     *     @Assert\NotBlank,
177
     *     @Assert\Length(min=1)
178
     * })
179
     * @Locale
180
     * @Translate
181
     */
182
    private $description;
183
184
    /**
185
     * @var integer
186
     * @ApiProperty
187
     * @Serializer\Groups({"form_output", "form_input"})
188
     * @ORM\Column(name="version", type="integer")
189
     * @ORM\Version
190
     * @Assert\NotBlank
191
     * @Assert\Type("integer")
192
     */
193
    private $version;
194
195
    /**
196
     * @var string
197
     * @ApiProperty(writable=false)
198
     * @Serializer\Groups({"form_output"})
199
     * @ORM\Column(name="tenant", type="guid")
200
     * @Assert\Uuid
201
     */
202
    private $tenant;
203
204
    /**
205
     * Constructor
206
     */
207
    public function __construct()
208
    {
209
        $this->config = [];
210
        $this->title = [];
211
        $this->description = [];
212
    }
213
}
214