Completed
Pull Request — master (#124)
by Serhii
13:45
created

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