Passed
Branch master (350f1b)
by Jan
04:53
created

Category::getIDString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
4
 *
5
 * Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License as published
9
 * by the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License
18
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
 */
20
21
declare(strict_types=1);
22
23
namespace App\Entity\Parts;
24
25
use App\Entity\Attachments\CategoryAttachment;
26
use App\Entity\Base\AbstractPartsContainingDBElement;
27
use App\Entity\Parameters\CategoryParameter;
28
use Doctrine\Common\Collections\Collection;
29
use Doctrine\ORM\Mapping as ORM;
30
use Symfony\Component\Validator\Constraints as Assert;
31
32
/**
33
 * Class AttachmentType.
34
 *
35
 * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
36
 * @ORM\Table(name="`categories`")
37
 */
38
class Category extends AbstractPartsContainingDBElement
39
{
40
    /**
41
     * @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
42
     * @ORM\OrderBy({"name" = "ASC"})
43
     */
44
    protected $children;
45
46
    /**
47
     * @ORM\ManyToOne(targetEntity="Category", inversedBy="children")
48
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
49
     */
50
    protected $parent;
51
52
    /**
53
     * @ORM\OneToMany(targetEntity="Part", mappedBy="category", fetch="EXTRA_LAZY")
54
     */
55
    protected $parts;
56
57
    /**
58
     * @var string
59
     * @ORM\Column(type="text")
60
     */
61
    protected $partname_hint = '';
62
63
    /**
64
     * @var string
65
     * @ORM\Column(type="text")
66
     */
67
    protected $partname_regex = '';
68
69
    /**
70
     * @var bool
71
     * @ORM\Column(type="boolean")
72
     */
73
    protected $disable_footprints = false;
74
75
    /**
76
     * @var bool
77
     * @ORM\Column(type="boolean")
78
     */
79
    protected $disable_manufacturers = false;
80
81
    /**
82
     * @var bool
83
     * @ORM\Column(type="boolean")
84
     */
85
    protected $disable_autodatasheets = false;
86
87
    /**
88
     * @var bool
89
     * @ORM\Column(type="boolean")
90
     */
91
    protected $disable_properties = false;
92
93
    /**
94
     * @var string
95
     * @ORM\Column(type="text")
96
     */
97
    protected $default_description = '';
98
99
    /**
100
     * @var string
101
     * @ORM\Column(type="text")
102
     */
103
    protected $default_comment = '';
104
    /**
105
     * @var Collection<int, CategoryAttachment>
106
     * @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
107
     * @ORM\OrderBy({"name" = "ASC"})
108
     * @Assert\Valid()
109
     */
110
    protected $attachments;
111
112
    /** @var Collection<int, CategoryParameter>
113
     * @ORM\OneToMany(targetEntity="App\Entity\Parameters\CategoryParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
114
     * @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
115
     * @Assert\Valid()
116
     */
117
    protected $parameters;
118
119
120
    public function getPartnameHint(): string
121
    {
122
        return $this->partname_hint;
123
    }
124
125
    /**
126
     * @return Category
127
     */
128
    public function setPartnameHint(string $partname_hint): self
129
    {
130
        $this->partname_hint = $partname_hint;
131
132
        return $this;
133
    }
134
135
    public function getPartnameRegex(): string
136
    {
137
        return $this->partname_regex;
138
    }
139
140
    /**
141
     * @return Category
142
     */
143
    public function setPartnameRegex(string $partname_regex): self
144
    {
145
        $this->partname_regex = $partname_regex;
146
147
        return $this;
148
    }
149
150
    public function isDisableFootprints(): bool
151
    {
152
        return $this->disable_footprints;
153
    }
154
155
    /**
156
     * @return Category
157
     */
158
    public function setDisableFootprints(bool $disable_footprints): self
159
    {
160
        $this->disable_footprints = $disable_footprints;
161
162
        return $this;
163
    }
164
165
    public function isDisableManufacturers(): bool
166
    {
167
        return $this->disable_manufacturers;
168
    }
169
170
    /**
171
     * @return Category
172
     */
173
    public function setDisableManufacturers(bool $disable_manufacturers): self
174
    {
175
        $this->disable_manufacturers = $disable_manufacturers;
176
177
        return $this;
178
    }
179
180
    public function isDisableAutodatasheets(): bool
181
    {
182
        return $this->disable_autodatasheets;
183
    }
184
185
    /**
186
     * @return Category
187
     */
188
    public function setDisableAutodatasheets(bool $disable_autodatasheets): self
189
    {
190
        $this->disable_autodatasheets = $disable_autodatasheets;
191
192
        return $this;
193
    }
194
195
    public function isDisableProperties(): bool
196
    {
197
        return $this->disable_properties;
198
    }
199
200
    /**
201
     * @return Category
202
     */
203
    public function setDisableProperties(bool $disable_properties): self
204
    {
205
        $this->disable_properties = $disable_properties;
206
207
        return $this;
208
    }
209
210
    public function getDefaultDescription(): string
211
    {
212
        return $this->default_description;
213
    }
214
215
    /**
216
     * @return Category
217
     */
218
    public function setDefaultDescription(string $default_description): self
219
    {
220
        $this->default_description = $default_description;
221
222
        return $this;
223
    }
224
225
    public function getDefaultComment(): string
226
    {
227
        return $this->default_comment;
228
    }
229
230
    /**
231
     * @return Category
232
     */
233
    public function setDefaultComment(string $default_comment): self
234
    {
235
        $this->default_comment = $default_comment;
236
237
        return $this;
238
    }
239
}
240