Person.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. namespace Translator\Fixture;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. /**
  6. * @ORM\Entity
  7. */
  8. class Person
  9. {
  10. /**
  11. * @ORM\Id
  12. * @ORM\GeneratedValue
  13. * @ORM\Column(type="integer")
  14. */
  15. private $id;
  16. /**
  17. * @ORM\Column(name="name", type="string", length=128)
  18. */
  19. public $name;
  20. /**
  21. * @ORM\Column(name="desc", type="string", length=128)
  22. */
  23. public $description;
  24. /**
  25. * @ORM\Column(name="last_name", type="string", length=128, nullable=true)
  26. */
  27. public $lastName;
  28. public function getId()
  29. {
  30. return $this->id;
  31. }
  32. public function setName($name)
  33. {
  34. $this->name = $name;
  35. }
  36. public function getName()
  37. {
  38. return $this->name;
  39. }
  40. public function setDescription($description)
  41. {
  42. $this->description = $description;
  43. }
  44. public function getDescription()
  45. {
  46. return $this->description;
  47. }
  48. public function getLastName()
  49. {
  50. return $this->lastName;
  51. }
  52. public function setLastName($name)
  53. {
  54. $this->lastName = $name;
  55. }
  56. //
  57. // TRANSLATIONS DEFINITION:
  58. //
  59. /**
  60. * @ORM\OneToMany(targetEntity="PersonTranslation", mappedBy="translatable", cascade={"persist"})
  61. */
  62. private $translations;
  63. /**
  64. * @ORM\ManyToOne(targetEntity="Person")
  65. */
  66. private $parent;
  67. public function setParent(Person $parent)
  68. {
  69. $this->parent = $parent;
  70. }
  71. public function getParent()
  72. {
  73. return $this->parent;
  74. }
  75. public function __construct()
  76. {
  77. $this->translations = new ArrayCollection();
  78. }
  79. public function translate($locale = 'en')
  80. {
  81. if ('en' === $locale) {
  82. return $this;
  83. }
  84. return new \Gedmo\Translator\TranslationProxy($this,
  85. /* Locale */ $locale,
  86. /* List of translatable properties: */ array('name', 'lastName'),
  87. /* Translation entity class: */ 'Translator\Fixture\PersonTranslation',
  88. /* Translations collection property: */ $this->translations
  89. );
  90. }
  91. }