Completed
Push — master ( 3ecbe1...f7c2f1 )
by Jan
04:05
created

MasterAttachmentTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setMasterPictureAttachment() 0 4 1
A getMasterPictureAttachment() 0 3 1
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\Parts\PartTraits;
33
34
35
use App\Entity\Attachments\Attachment;
36
use App\Entity\Parts\Part;
37
use App\Security\Annotations\ColumnSecurity;
38
39
/**
40
 * A entity with this class has a master attachment, which is used as a preview image for this object.
41
 * @package App\Entity\Parts\PartTraits
42
 */
43
trait MasterAttachmentTrait
44
{
45
    /**
46
     * @var Attachment
47
     * @ORM\ManyToOne(targetEntity="App\Entity\Attachments\Attachment")
48
     * @ORM\JoinColumn(name="id_master_picture_attachement", referencedColumnName="id")
49
     * @Assert\Expression("value == null or value.isPicture()", message="part.master_attachment.must_be_picture")
50
     * @ColumnSecurity(prefix="attachments", type="object")
51
     */
52
    protected $master_picture_attachment;
53
54
55
    /**
56
     * Get the master picture "Attachment"-object of this part (if there is one).
57
     * The master picture should be used as a visual description/representation of this part.
58
     * @return Attachment the master picture Attachement of this part (if there is one)
59
     */
60
    public function getMasterPictureAttachment(): ?Attachment
61
    {
62
        return $this->master_picture_attachment;
63
    }
64
65
    /**
66
     * Sets the new master picture for this part.
67
     * @param Attachment|null $new_master_attachment
68
     * @return Part
69
     */
70
    public function setMasterPictureAttachment(?Attachment $new_master_attachment): self
71
    {
72
        $this->master_picture_attachment = $new_master_attachment;
73
        return $this;
74
    }
75
76
77
}