Entry   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
eloc 5
c 1
b 0
f 1
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setObject() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[email protected]>.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\SanityBundle\Entity\Vacancy\Tag\Translation;
17
18
use Doctrine\ORM\Mapping as ORM;
19
use Gedmo\Translatable\Entity\MappedSuperclass\AbstractPersonalTranslation;
20
use Veslo\SanityBundle\Entity\Vacancy\Tag;
21
22
/**
23
 * Translation entry for a field of sanity tag entity
24
 *
25
 * Note: personal translation is chosen because this data is received from external source,
26
 * so each time we perform sync, old translation entries have to be deleted (cascade)
27
 *
28
 * @ORM\Table(
29
 *     name="sanity_vacancy_tag_translation",
30
 *     uniqueConstraints={
31
 *         @ORM\UniqueConstraint(
32
 *             name="sanity_vacancy_tag_translation_locale_object_id_field_uq",
33
 *             columns={"locale", "object_id", "field"}
34
 *         )
35
 *     }
36
 * )
37
 * @ORM\Entity(repositoryClass="Gedmo\Translatable\Entity\Repository\TranslationRepository", readOnly=true)
38
 * @ORM\Cache(usage="READ_ONLY", region="index")
39
 */
40
class Entry extends AbstractPersonalTranslation
41
{
42
    /**
43
     * Translatable entity
44
     *
45
     * @var Tag
46
     *
47
     * @ORM\ManyToOne(targetEntity="Veslo\SanityBundle\Entity\Vacancy\Tag", inversedBy="translations")
48
     * @ORM\JoinColumn(name="object_id", referencedColumnName="id", onDelete="CASCADE")
49
     */
50
    protected $object;
51
52
    /**
53
     * {@inheritdoc}
54
     *
55
     * @var Tag $object Sanity tag
56
     */
57
    public function setObject($object)
58
    {
59
        parent::setObject($object);
60
61
        $object->addTranslation($this);
62
63
        return $this;
64
    }
65
}
66