Completed
Push — master ( 5061c2...404712 )
by Jan
05:08
created

getMasterPictureAttachment()   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
 *
4
 * part-db version 0.1
5
 * Copyright (C) 2005 Christoph Lechner
6
 * http://www.cl-projects.de/
7
 *
8
 * part-db version 0.2+
9
 * Copyright (C) 2009 K. Jacobs and others (see authors.php)
10
 * http://code.google.com/p/part-db/
11
 *
12
 * Part-DB Version 0.4+
13
 * Copyright (C) 2016 - 2019 Jan Böhmer
14
 * https://github.com/jbtronics
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
29
 *
30
 */
31
32
namespace App\Entity\Base;
33
34
35
use App\Entity\Attachments\Attachment;
36
use App\Entity\Parts\Part;
37
use App\Security\Annotations\ColumnSecurity;
38
use Symfony\Component\Validator\Constraints as Assert;
39
40
/**
41
 * A entity with this class has a master attachment, which is used as a preview image for this object.
42
 * @package App\Entity\Parts\PartTraits
43
 */
44
trait MasterAttachmentTrait
45
{
46
    /**
47
     * @var Attachment
48
     * @ORM\ManyToOne(targetEntity="App\Entity\Attachments\Attachment")
49
     * @ORM\JoinColumn(name="id_preview_attachement", referencedColumnName="id")
50
     * @Assert\Expression("value == null or value.isPicture()", message="part.master_attachment.must_be_picture")
51
     * @ColumnSecurity(prefix="attachments", type="object")
52
     */
53
    protected $master_picture_attachment;
54
55
56
    /**
57
     * Get the master picture "Attachment"-object of this part (if there is one).
58
     * The master picture should be used as a visual description/representation of this part.
59
     * @return Attachment the master picture Attachement of this part (if there is one)
60
     */
61
    public function getMasterPictureAttachment(): ?Attachment
62
    {
63
        return $this->master_picture_attachment;
64
    }
65
66
    /**
67
     * Sets the new master picture for this part.
68
     * @param Attachment|null $new_master_attachment
69
     * @return Part
70
     */
71
    public function setMasterPictureAttachment(?Attachment $new_master_attachment): self
72
    {
73
        $this->master_picture_attachment = $new_master_attachment;
74
        return $this;
75
    }
76
77
78
}