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

LabelProfile::getIDString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
7
 *
8
 * Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as published
12
 * by the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License
21
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
22
 */
23
24
namespace App\Entity\LabelSystem;
25
26
use App\Entity\Attachments\AttachmentContainingDBElement;
27
use App\Entity\Attachments\LabelAttachment;
28
use Doctrine\Common\Collections\Collection;
29
use Doctrine\ORM\Mapping as ORM;
30
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
31
use Symfony\Component\Validator\Constraints as Assert;
32
33
/**
34
 * @ORM\Entity(repositoryClass="App\Repository\LabelProfileRepository")
35
 * @ORM\Table(name="label_profiles")
36
 * @ORM\EntityListeners({"App\EntityListeners\TreeCacheInvalidationListener"})
37
 * @UniqueEntity({"name", "options.supported_element"})
38
 */
39
class LabelProfile extends AttachmentContainingDBElement
40
{
41
    /**
42
     * @var Collection<int, LabelAttachment>
43
     * @ORM\OneToMany(targetEntity="App\Entity\Attachments\LabelAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
44
     * @ORM\OrderBy({"name" = "ASC"})
45
     */
46
    protected $attachments;
47
48
    /**
49
     * @var LabelOptions
50
     * @ORM\Embedded(class="LabelOptions")
51
     * @Assert\Valid()
52
     */
53
    protected $options;
54
55
    /**
56
     * @var string The comment info for this element
57
     * @ORM\Column(type="text")
58
     */
59
    protected $comment = '';
60
61
    /**
62
     * @var bool Determines, if this label profile should be shown in the dropdown quick menu.
63
     * @ORM\Column(type="boolean")
64
     */
65
    protected $show_in_dropdown = true;
66
67
    public function __construct()
68
    {
69
        parent::__construct();
70
        $this->options = new LabelOptions();
71
    }
72
73
    public function getOptions(): LabelOptions
74
    {
75
        return $this->options;
76
    }
77
78
    public function setOptions(LabelOptions $labelOptions): self
79
    {
80
        $this->options = $labelOptions;
81
82
        return $this;
83
    }
84
85
    /**
86
     * Get the comment of the element.
87
     *
88
     * @return string the comment
89
     */
90
    public function getComment(): ?string
91
    {
92
        return $this->comment;
93
    }
94
95
    public function setComment(string $new_comment): string
96
    {
97
        $this->comment = $new_comment;
98
99
        return $this;
100
    }
101
102
    /**
103
     * Returns true, if this label profile should be shown in label generator quick menu.
104
     *
105
     * @return bool
106
     */
107
    public function isShowInDropdown(): bool
108
    {
109
        return $this->show_in_dropdown;
110
    }
111
112
    /**
113
     * Sets the show in dropdown menu.
114
     *
115
     * @return LabelProfile
116
     */
117
    public function setShowInDropdown(bool $show_in_dropdown): self
118
    {
119
        $this->show_in_dropdown = $show_in_dropdown;
120
121
        return $this;
122
    }
123
}
124