Completed
Pull Request — master (#124)
by
unknown
14:32
created

Post::unsetTranslations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 2
cts 2
cp 1
crap 1
rs 9.4285
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
    /**
73
     * Constructor
74
     */
75
    public function __construct()
76
    {
77
        parent::__construct();
78
        $this->galleryHasMedia = new ArrayCollection();
79
        $this->tags = new ArrayCollection();
80
    }
81
82
    /**
83
     * Get id
84
     *
85 1
     * @return integer
86
     */
87 1
    public function getId()
88
    {
89
        return $this->id;
90
    }
91
92
    /**
93
     * Unset translations
94
     *
95 4
     * @return Post
96
     */
97 4
    public function unsetTranslations()
98
    {
99 4
        $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
     *
130 5
     * @return \Doctrine\Common\Collections\Collection
131
     */
132 5
    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
     *
163 4
     * @return \Doctrine\Common\Collections\Collection
164
     */
165 4
    public function getTags()
166
    {
167
        return $this->tags;
168
    }
169
170
    /**
171
     * @param boolean $pinned
172 1
     * @return Post
173
     */
174 1
    public function setPinned($pinned)
175
    {
176 1
        $this->pinned = $pinned;
177
178
        return $this;
179
    }
180
181
    /**
182
     * @return boolean
183
     */
184
    public function isPinned()
185
    {
186
        return $this->pinned;
187
    }
188
}
189