Completed
Pull Request — master (#128)
by Antonio
02:07
created

Page::setImage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusCmsPlugin\Entity;
14
15
use Sylius\Component\Core\Model\ImageInterface;
16
use Sylius\Component\Resource\Model\TimestampableTrait;
17
use Sylius\Component\Resource\Model\ToggleableTrait;
18
use Sylius\Component\Resource\Model\TranslatableTrait;
19
use Sylius\Component\Resource\Model\TranslationInterface;
20
21
class Page implements PageInterface
22
{
23
    use ToggleableTrait;
24
    use ProductsAwareTrait;
25
    use SectionableTrait;
26
    use TimestampableTrait;
27
    use TranslatableTrait {
28
        __construct as protected initializeTranslationsCollection;
29
    }
30
31
    /**
32
     * @var int|null
33
     */
34
    protected $id;
35
36
    /**
37
     * @var string|null
38
     */
39
    protected $code;
40
41
    public function __construct()
42
    {
43
        $this->initializeProductsCollection();
44
        $this->initializeSectionsCollection();
45
        $this->initializeTranslationsCollection();
46
47
        $this->createdAt = new \DateTime();
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function getId(): ?int
54
    {
55
        return $this->id;
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function setId(?int $id): void
62
    {
63
        $this->id = $id;
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function getCode(): ?string
70
    {
71
        return $this->code;
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function setCode(?string $code): void
78
    {
79
        $this->code = $code;
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function getSlug(): ?string
86
    {
87
        return $this->getPageTranslation()->getSlug();
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    public function setSlug(?string $slug): void
94
    {
95
        $this->getPageTranslation()->setSlug($slug);
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101
    public function getMetaKeywords(): ?string
102
    {
103
        return $this->getPageTranslation()->getMetaKeywords();
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109
    public function setMetaKeywords(?string $metaKeywords): void
110
    {
111
        $this->getPageTranslation()->setMetaKeywords($metaKeywords);
112
    }
113
114
    /**
115
     * {@inheritdoc}
116
     */
117
    public function getMetaDescription(): ?string
118
    {
119
        return $this->getPageTranslation()->getMetaDescription();
120
    }
121
122
    /**
123
     * {@inheritdoc}
124
     */
125
    public function setMetaDescription(?string $metaDescription): void
126
    {
127
        $this->getPageTranslation()->setMetaDescription($metaDescription);
128
    }
129
130
    /**
131
     * {@inheritdoc}
132
     */
133
    public function getContent(): ?string
134
    {
135
        return $this->getPageTranslation()->getContent();
136
    }
137
138
    /**
139
     * {@inheritdoc}
140
     */
141
    public function setContent(?string $content): void
142
    {
143
        $this->getPageTranslation()->setContent($content);
144
    }
145
146
    /**
147
     * {@inheritdoc}
148
     */
149
    public function getName(): ?string
150
    {
151
        return $this->getPageTranslation()->getName();
152
    }
153
154
    /**
155
     * {@inheritdoc}
156
     */
157
    public function setName(?string $name): void
158
    {
159
        $this->getPageTranslation()->setName($name);
160
    }
161
162
    /**
163
     * {@inheritdoc}
164
     */
165
    public function getImage(): ?ImageInterface
166
    {
167
        return $this->getPageTranslation()->getImage();
168
    }
169
170
    /**
171
     * {@inheritdoc}
172
     */
173
    public function setImage(?ImageInterface $image): void
174
    {
175
        $this->getPageTranslation()->setImage($image);
176
    }
177
178
    /**
179
     * @return PageTranslationInterface|TranslationInterface|null
180
     */
181
    protected function getPageTranslation(): PageTranslationInterface
182
    {
183
        return $this->getTranslation();
184
    }
185
186
    /**
187
     * {@inheritdoc}
188
     */
189
    protected function createTranslation(): ?PageTranslationInterface
190
    {
191
        return new PageTranslation();
192
    }
193
}
194