AbstractTranslation.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * This file is part of the Sylius package.
  4. *
  5. * (c) Paweł Jędrzejewski
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sylius\Component\Translation\Model;
  11. /**
  12. * @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
  13. */
  14. class AbstractTranslation implements TranslationInterface
  15. {
  16. /**
  17. * Locale
  18. *
  19. * @var string
  20. */
  21. protected $locale;
  22. /**
  23. * Translatable object
  24. *
  25. * @var TranslatableInterface
  26. */
  27. protected $translatable;
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function getTranslatable()
  32. {
  33. return $this->translatable;
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function setTranslatable(TranslatableInterface $translatable = null)
  39. {
  40. if ($translatable === $this->translatable) {
  41. return $this;
  42. }
  43. $old = $this->translatable;
  44. $this->translatable = $translatable;
  45. if (null !== $old) {
  46. $old->removeTranslation($this);
  47. }
  48. if (null !== $translatable) {
  49. $translatable->addTranslation($this);
  50. }
  51. return $this;
  52. }
  53. /**
  54. * {@inheritdoc}
  55. */
  56. public function getLocale()
  57. {
  58. return $this->locale;
  59. }
  60. /**
  61. * {@inheritdoc}
  62. */
  63. public function setLocale($locale)
  64. {
  65. $this->locale = $locale;
  66. return $this;
  67. }
  68. }