1<?php
2/**
3 * Copyright since 2007 PrestaShop SA and Contributors
4 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
5 *
6 * NOTICE OF LICENSE
7 *
8 * This source file is subject to the Open Software License (OSL 3.0)
9 * that is bundled with this package in the file LICENSE.md.
10 * It is also available through the world-wide-web at this URL:
11 * https://opensource.org/licenses/OSL-3.0
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@prestashop.com so we can send you a copy immediately.
15 *
16 * DISCLAIMER
17 *
18 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
19 * versions in the future. If you wish to customize PrestaShop for your
20 * needs please refer to https://devdocs.prestashop.com/ for more information.
21 *
22 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
23 * @copyright Since 2007 PrestaShop SA and Contributors
24 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
25 */
26
27namespace PrestaShopBundle\Entity;
28
29use Doctrine\Common\Collections\ArrayCollection;
30use Doctrine\ORM\Mapping as ORM;
31use PrestaShop\PrestaShop\Core\Language\LanguageInterface;
32
33/**
34 * @ORM\Table()
35 * @ORM\Entity(repositoryClass="PrestaShopBundle\Entity\Repository\LangRepository")
36 */
37class Lang implements LanguageInterface
38{
39    /**
40     * @var int
41     *
42     * @ORM\Id
43     * @ORM\Column(name="id_lang", type="integer")
44     * @ORM\GeneratedValue(strategy="AUTO")
45     */
46    private $id;
47
48    /**
49     * @var string
50     *
51     * @ORM\Column(name="name", type="string", length=32)
52     */
53    private $name;
54
55    /**
56     * @var int
57     *
58     * @ORM\Column(name="active", type="boolean")
59     */
60    private $active;
61
62    /**
63     * @var string
64     *
65     * @ORM\Column(name="iso_code", type="string", length=2)
66     */
67    private $isoCode;
68
69    /**
70     * @var string
71     *
72     * @ORM\Column(name="language_code", type="string", length=5)
73     */
74    private $languageCode;
75
76    /**
77     * @var string
78     *
79     * @ORM\Column(name="locale", type="string", length=5)
80     */
81    private $locale;
82
83    /**
84     * @var string
85     *
86     * @ORM\Column(name="date_format_lite", type="string", length=32)
87     */
88    private $dateFormatLite;
89
90    /**
91     * @var string
92     *
93     * @ORM\Column(name="date_format_full", type="string", length=32)
94     */
95    private $dateFormatFull;
96
97    /**
98     * @var bool
99     *
100     * @ORM\Column(name="is_rtl", type="boolean")
101     */
102    private $isRtl;
103
104    /**
105     * @ORM\OneToMany(targetEntity="Translation", mappedBy="lang")
106     */
107    private $translations;
108
109    /**
110     * @ORM\ManyToMany(targetEntity="PrestaShopBundle\Entity\Shop", cascade={"remove", "persist"})
111     * @ORM\JoinTable(
112     *      joinColumns={@ORM\JoinColumn(name="id_lang", referencedColumnName="id_lang", onDelete="CASCADE")},
113     *      inverseJoinColumns={@ORM\JoinColumn(name="id_shop", referencedColumnName="id_shop", onDelete="CASCADE")}
114     * )
115     */
116    private $shops;
117
118    /**
119     * Constructor.
120     */
121    public function __construct()
122    {
123        $this->shops = new ArrayCollection();
124    }
125
126    /**
127     * Get id.
128     *
129     * @return int
130     */
131    public function getId()
132    {
133        return $this->id;
134    }
135
136    /**
137     * Set name.
138     *
139     * @param string $name
140     *
141     * @return Lang
142     */
143    public function setName($name)
144    {
145        $this->name = $name;
146
147        return $this;
148    }
149
150    /**
151     * Get name.
152     *
153     * @return string
154     */
155    public function getName()
156    {
157        return $this->name;
158    }
159
160    /**
161     * Set active.
162     *
163     * @param int $active
164     *
165     * @return Lang
166     */
167    public function setActive($active)
168    {
169        $this->active = $active;
170
171        return $this;
172    }
173
174    /**
175     * Get active.
176     *
177     * @return int
178     */
179    public function getActive()
180    {
181        return $this->active;
182    }
183
184    /**
185     * Set isoCode.
186     *
187     * @param string $isoCode
188     *
189     * @return Lang
190     */
191    public function setIsoCode($isoCode)
192    {
193        $this->isoCode = $isoCode;
194
195        return $this;
196    }
197
198    /**
199     * Get isoCode.
200     *
201     * @return string
202     */
203    public function getIsoCode()
204    {
205        return $this->isoCode;
206    }
207
208    /**
209     * Set languageCode.
210     *
211     * @param string $languageCode
212     *
213     * @return Lang
214     */
215    public function setLanguageCode($languageCode)
216    {
217        $this->languageCode = $languageCode;
218
219        return $this;
220    }
221
222    /**
223     * Get languageCode.
224     *
225     * @return string
226     */
227    public function getLanguageCode()
228    {
229        return $this->languageCode;
230    }
231
232    /**
233     * Set dateFormatLite.
234     *
235     * @param string $dateFormatLite
236     *
237     * @return Lang
238     */
239    public function setDateFormatLite($dateFormatLite)
240    {
241        $this->dateFormatLite = $dateFormatLite;
242
243        return $this;
244    }
245
246    /**
247     * Get dateFormatLite.
248     *
249     * @return string
250     */
251    public function getDateFormatLite()
252    {
253        return $this->dateFormatLite;
254    }
255
256    /**
257     * Set dateFormatFull.
258     *
259     * @param string $dateFormatFull
260     *
261     * @return Lang
262     */
263    public function setDateFormatFull($dateFormatFull)
264    {
265        $this->dateFormatFull = $dateFormatFull;
266
267        return $this;
268    }
269
270    /**
271     * Get dateFormatFull.
272     *
273     * @return string
274     */
275    public function getDateFormatFull()
276    {
277        return $this->dateFormatFull;
278    }
279
280    /**
281     * Set isRtl.
282     *
283     * @param bool $isRtl
284     *
285     * @return Lang
286     */
287    public function setIsRtl($isRtl)
288    {
289        $this->isRtl = $isRtl;
290
291        return $this;
292    }
293
294    /**
295     * Get isRtl.
296     *
297     * @return bool
298     */
299    public function getIsRtl()
300    {
301        return $this->isRtl;
302    }
303
304    /**
305     * {@inheritdoc}
306     */
307    public function isRTL()
308    {
309        return $this->getIsRtl();
310    }
311
312    /**
313     * @return string
314     */
315    public function getLocale()
316    {
317        return !empty($this->locale) ? $this->locale : $this->getLanguageCode();
318    }
319
320    /**
321     * @param string $locale
322     *
323     * @return Lang
324     */
325    public function setLocale($locale)
326    {
327        $this->locale = $locale;
328
329        return $this;
330    }
331
332    /**
333     * Add shop.
334     *
335     * @param \PrestaShopBundle\Entity\Shop $shop
336     *
337     * @return Lang
338     */
339    public function addShop(Shop $shop)
340    {
341        $this->shops[] = $shop;
342
343        return $this;
344    }
345
346    /**
347     * Remove shop.
348     *
349     * @param \PrestaShopBundle\Entity\Shop $shop
350     */
351    public function removeShop(Shop $shop)
352    {
353        $this->shops->removeElement($shop);
354    }
355
356    /**
357     * Get shops.
358     *
359     * @return \Doctrine\Common\Collections\Collection
360     */
361    public function getShops()
362    {
363        return $this->shops;
364    }
365}
366