This repository has been archived by the owner on Dec 5, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Translation.php
110 lines (95 loc) · 2.3 KB
/
Translation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
namespace Liip\TranslationBundle\Model;
/**
* Representation of a translation element.
*
* This file is part of the LiipTranslationBundle. For more information concerning
* the bundle, see the README.md file at the project root.
*
* @version 0.0.1
*
* @license http://opensource.org/licenses/MIT MIT License
* @author David Jeanmonod <david.jeanmonod@liip.ch>
* @author Gilles Crettenand <gilles.crettenand@liip.ch>
* @author Sylvain Fankhauser <sylvain.fankhauser@liip.ch>
* @copyright Copyright (c) 2013, Liip, http://www.liip.ch
*/
class Translation extends Persistent
{
/** @var string */
private $value;
/** @var string */
private $locale;
/** @var Unit */
private $unit;
/** @var array */
private $metadata;
/**
* @param string $value value (ie translation)
* @param string $locale locale
* @param Unit $unit unit related to this translation
* @param array $metadata
*/
public function __construct($value, $locale, Unit $unit, array $metadata = array())
{
$this->value = $value;
$this->locale = $locale;
$this->unit = $unit;
$this->metadata = $metadata;
}
/**
* Mark this translation as deleted (will be remove at the next persist).
*/
public function delete()
{
$this->setIsDeleted();
}
/**
* @param array $m the new metadata
*/
public function setMetadata(array $m = array())
{
$this->metadata = $m;
}
/**
* @return array metadata as array
*/
public function getMetadata()
{
return $this->metadata;
}
public function getValue()
{
return $this->value;
}
public function setValue($t)
{
$this->value = $t;
$this->setIsModified(true);
}
public function getModificationDate()
{
// TODO fetch from the metadata
return '-';
}
public function getLocale()
{
return $this->locale;
}
public function getUnit()
{
return $this->unit;
}
public function getKey()
{
return $this->getUnit()->getKey();
}
public function getDomain()
{
return $this->getUnit()->getDomain();
}
public function __toString()
{
return $this->getValue();
}
}