Completed
Pull Request — master (#121)
by
unknown
12:37
created

Post::removeGalleryHasMedia()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 1
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use AppBundle\Entity\Translations\PostTranslation;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use AppBundle\Traits\DeletedByTrait;
8
use Application\Sonata\MediaBundle\Entity\GalleryHasMedia;
9
use Doctrine\ORM\Mapping as ORM;
10
use Gedmo\Mapping\Annotation as Gedmo;
11
use JMS\Serializer\Annotation as Serializer;
12
13
/**
14
 * @ORM\Table(name="posts")
15
 * @ORM\Entity(repositoryClass="AppBundle\Repository\PostRepository")
16
 * @Gedmo\TranslationEntity(class="AppBundle\Entity\Translations\PostTranslation")
17
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
18
 * @Serializer\ExclusionPolicy("all")
19
 */
20
class Post extends AbstractTranslateableStory
21
{
22
    use DeletedByTrait;
23
24
    /**
25
     * @var integer
26
     *
27
     * @ORM\Column(name="id", type="integer")
28
     * @ORM\Id
29
     * @ORM\GeneratedValue(strategy="AUTO")
30
     */
31
    protected $id;
32
33
    /**
34
     * @var ArrayCollection|PostTranslation[]
35
     *
36
     * @ORM\OneToMany(
37
     *     targetEntity="AppBundle\Entity\Translations\PostTranslation",
38
     *     mappedBy="object",
39
     *     cascade={"persist", "remove"}
40
     * )
41
     */
42
    protected $translations;
43
44
    /**
45
     * @var ArrayCollection|GalleryHasMedia[]
46
     *
47
     * @ORM\ManyToMany(targetEntity="Application\Sonata\MediaBundle\Entity\GalleryHasMedia", cascade={"persist"})
48
     * @ORM\JoinTable(name="post_galleryHasMedia",
49
     *     joinColumns={@ORM\JoinColumn(name="post_id",referencedColumnName="id")},
50
     *     inverseJoinColumns={@ORM\JoinColumn(name="galleryHasMedia_id",referencedColumnName="id")}
51
     * )
52
     */
53
    protected $galleryHasMedia;
54
55
    /**
56
     * @var ArrayCollection|Tag[]
57
     *
58
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Tag", inversedBy="posts", cascade={"persist"})
59
     * @Serializer\Expose
60
     */
61
    protected $tags;
62
63
    /**
64
     * @var bool
65
     *
66
     * @ORM\Column(name="pinned", type="boolean")
67
     * @Serializer\Type("boolean")
68
     * @Serializer\Expose
69
     */
70
    protected $pinned = false;
71
72 1
    /**
73
     * Constructor
74 1
     */
75 1
    public function __construct()
76 1
    {
77 1
        parent::__construct();
78
        $this->galleryHasMedia = new ArrayCollection();
79
        $this->tags = new ArrayCollection();
80
    }
81
82
    /**
83
     * Get id
84 2
     *
85
     * @return integer
86 2
     */
87
    public function getId()
88
    {
89
        return $this->id;
90
    }
91
92
    /**
93
     * Unset translations
94 4
     *
95
     * @return Post
96 4
     */
97
    public function unsetTranslations()
98 4
    {
99
        $this->translations = null;
100
101
        return $this;
102
    }
103
104
    /**
105
     * Add galleryHasMedia
106
     *
107
     * @param \Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia
108
     * @return self
109
     */
110
    public function addGalleryHasMedia(\Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia)
111
    {
112
        $this->galleryHasMedia[] = $galleryHasMedia;
113
114
        return $this;
115
    }
116
117
    /**
118
     * Remove galleryHasMedia
119
     *
120
     * @param \Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia
121
     */
122
    public function removeGalleryHasMedia(\Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia)
123
    {
124
        $this->galleryHasMedia->removeElement($galleryHasMedia);
125
    }
126
127
    /**
128
     * Get galleryHasMedia
129 6
     *
130
     * @return \Doctrine\Common\Collections\Collection
131 6
     */
132
    public function getGalleryHasMedia()
133
    {
134
        return $this->galleryHasMedia;
135
    }
136
137
    /**
138
     * Add tags
139
     *
140
     * @param \AppBundle\Entity\Tag $tags
141
     * @return self
142
     */
143
    public function addTag(\AppBundle\Entity\Tag $tags)
144
    {
145
        $this->tags[] = $tags;
146
147
        return $this;
148
    }
149
150
    /**
151
     * Remove tags
152
     *
153
     * @param \AppBundle\Entity\Tag $tags
154
     */
155
    public function removeTag(\AppBundle\Entity\Tag $tags)
156
    {
157
        $this->tags->removeElement($tags);
158
    }
159
160
    /**
161
     * Get tags
162 5
     *
163
     * @return \Doctrine\Common\Collections\Collection
164 5
     */
165
    public function getTags()
166
    {
167
        return $this->tags;
168
    }
169
170
    /**
171 1
     * @param boolean $pinned
172
     * @return Post
173 1
     */
174
    public function setPinned($pinned)
175 1
    {
176
        $this->pinned = $pinned;
177
178
        return $this;
179
    }
180
181 1
    /**
182
     * @return boolean
183 1
     */
184
    public function isPinned()
185
    {
186
        return $this->pinned;
187
    }
188
}
189