vendor/lexik/translation-bundle/Entity/TransUnit.php line 14

Open in your IDE?
  1. <?php
  2. namespace Lexik\Bundle\TranslationBundle\Entity;
  3. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  4. use Lexik\Bundle\TranslationBundle\Model\TransUnit as TransUnitModel;
  5. use Lexik\Bundle\TranslationBundle\Manager\TransUnitInterface;
  6. /**
  7. * @UniqueEntity(fields={"key", "domain"})
  8. *
  9. * @author Cédric Girard <c.girard@lexik.fr>
  10. */
  11. class TransUnit extends TransUnitModel implements TransUnitInterface
  12. {
  13. /**
  14. * Add translations
  15. *
  16. * @param \Lexik\Bundle\TranslationBundle\Entity\Translation $translations
  17. */
  18. public function addTranslation(\Lexik\Bundle\TranslationBundle\Model\Translation $translation)
  19. {
  20. $translation->setTransUnit($this);
  21. $this->translations[] = $translation;
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function prePersist()
  27. {
  28. $this->createdAt = new \DateTime("now");
  29. $this->updatedAt = new \DateTime("now");
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function preUpdate()
  35. {
  36. $this->updatedAt = new \DateTime("now");
  37. }
  38. }