vendor/lexik/translation-bundle/Model/File.php line 13

Open in your IDE?
  1. <?php
  2. namespace Lexik\Bundle\TranslationBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. /**
  6. * Base File class.
  7. *
  8. * @author Cédric Girard <c.girard@lexik.fr>
  9. */
  10. abstract class File
  11. {
  12. /**
  13. * @var int
  14. */
  15. protected $id;
  16. /**
  17. * @var string
  18. *
  19. * @Assert\NotBlank()
  20. */
  21. protected $domain;
  22. /**
  23. * @var string
  24. *
  25. * @Assert\NotBlank()
  26. */
  27. protected $locale;
  28. /**
  29. * @var string
  30. *
  31. * @Assert\NotBlank()
  32. */
  33. protected $extention;
  34. /**
  35. * @var string
  36. *
  37. * @Assert\NotBlank()
  38. */
  39. protected $path;
  40. /**
  41. * @var string
  42. *
  43. * @Assert\NotBlank()
  44. */
  45. protected $hash;
  46. /**
  47. * @var Doctrine\Common\Collections\Collection
  48. */
  49. protected $translations;
  50. /**
  51. * Construct.
  52. */
  53. public function __construct()
  54. {
  55. $this->translations = new ArrayCollection();
  56. }
  57. /**
  58. * Get id
  59. *
  60. * @return int
  61. */
  62. public function getId()
  63. {
  64. return $this->id;
  65. }
  66. /**
  67. * Set domain
  68. *
  69. * @param string $domain
  70. */
  71. public function setDomain($domain)
  72. {
  73. $this->domain = $domain;
  74. }
  75. /**
  76. * Get domain
  77. *
  78. * @return string
  79. */
  80. public function getDomain()
  81. {
  82. return $this->domain;
  83. }
  84. /**
  85. * Set locale
  86. *
  87. * @param string $locale
  88. */
  89. public function setLocale($locale)
  90. {
  91. $this->locale = $locale;
  92. }
  93. /**
  94. * Get locale
  95. *
  96. * @return string
  97. */
  98. public function getLocale()
  99. {
  100. return $this->locale;
  101. }
  102. /**
  103. * Set extention
  104. *
  105. * @param string $extention
  106. */
  107. public function setExtention($extention)
  108. {
  109. $this->extention = $extention;
  110. }
  111. /**
  112. * Get extention
  113. *
  114. * @return string
  115. */
  116. public function getExtention()
  117. {
  118. return $this->extention;
  119. }
  120. /**
  121. * Set path
  122. *
  123. * @param string $path
  124. */
  125. public function setPath($path)
  126. {
  127. $this->path = $path;
  128. }
  129. /**
  130. * Get path
  131. *
  132. * @return string
  133. */
  134. public function getPath()
  135. {
  136. return $this->path;
  137. }
  138. /**
  139. * Set file name
  140. *
  141. * @param string $name
  142. */
  143. public function setName($name)
  144. {
  145. list($domain, $locale, $extention) = explode('.', $name);
  146. $this->domain = $domain;
  147. $this->locale = $locale;
  148. $this->extention = $extention;
  149. }
  150. /**
  151. * Get file name
  152. *
  153. * @return string
  154. */
  155. public function getName()
  156. {
  157. return sprintf('%s.%s.%s', $this->domain, $this->locale, $this->extention);
  158. }
  159. /**
  160. * Set hash
  161. *
  162. * @return string
  163. */
  164. public function setHash($hash)
  165. {
  166. $this->hash = $hash;
  167. }
  168. /**
  169. * Get hash
  170. *
  171. * @return string
  172. */
  173. public function getHash()
  174. {
  175. return $this->hash;
  176. }
  177. /**
  178. * Add translation
  179. *
  180. * @param Lexik\Bundle\TranslationBundle\Model\Translation $translation
  181. */
  182. public function addTranslation(\Lexik\Bundle\TranslationBundle\Model\Translation $translation)
  183. {
  184. $translation->setFile($this);
  185. $this->translations[] = $translation;
  186. }
  187. /**
  188. * Get translations
  189. *
  190. * @return \Doctrine\Common\Collections\Collection
  191. */
  192. public function getTranslations()
  193. {
  194. return $this->translations;
  195. }
  196. }