Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. "gedmo/doctrine-extensions": "2.3.*@dev"
  2.  
  3. stof_doctrine_extensions:
  4. orm:
  5. alopatria:
  6. timestampable: true
  7. sluggable: true
  8. translatable: true
  9.  
  10. <?php
  11.  
  12. namespace ...;
  13.  
  14. use GedmoMappingAnnotation as Gedmo;
  15. use DoctrineORMMapping as ORM;
  16. use GedmoTranslatableTranslatable;
  17.  
  18. /**
  19. * ...Entity
  20. *
  21. * @ORMTable(name="content")
  22. * @ORMHasLifecycleCallbacks
  23. * @ORMEntity(repositoryClass="...EntityContentRepository")
  24. */
  25. class Content implements Translatable
  26. {
  27. /**
  28. *
  29. * @ORMColumn(name="id", type="bigint", nullable=false)
  30. * @ORMId
  31. * @ORMGeneratedValue(strategy="IDENTITY")
  32. */
  33. protected $id;
  34.  
  35. /**
  36. * @GedmoTranslatable
  37. * @ORMColumn(name="title", type="string", length=32, nullable=false)
  38. */
  39. protected $title;
  40.  
  41. /**
  42. * @GedmoTranslatable
  43. * @ORMColumn(name="text", type="text", nullable=false)
  44. */
  45. protected $text;
  46.  
  47. /**
  48. * @var datetime $created
  49. *
  50. * @GedmoTimestampable(on="create")
  51. * @ORMColumn(type="datetime")
  52. */
  53. private $created;
  54.  
  55. /**
  56. * @var datetime $updated
  57. *
  58. * @GedmoTimestampable(on="update")
  59. * @ORMColumn(type="datetime")
  60. */
  61. private $updated;
  62.  
  63. /**
  64. * @var datetime $contentChanged
  65. *
  66. * @ORMColumn(name="content_changed", type="datetime", nullable=true)
  67. * @GedmoTimestampable(on="change", field={"title", "text"})
  68. */
  69. private $contentChanged;
  70.  
  71. /**
  72. * @GedmoSlug(fields={"title"})
  73. * @ORMColumn(length=128, unique=true)
  74. */
  75. private $slug;
  76.  
  77.  
  78. /**
  79. * Get id
  80. *
  81. * @return integer
  82. */
  83. public function getId()
  84. {
  85. return $this->id;
  86. }
  87.  
  88. /**
  89. * Set title
  90. *
  91. * @param string $title
  92. * @return Content
  93. */
  94. public function setTitle($title)
  95. {
  96. $this->title = $title;
  97.  
  98. return $this;
  99. }
  100.  
  101. /**
  102. * Get title
  103. *
  104. * @return string
  105. */
  106. public function getTitle()
  107. {
  108. return $this->title;
  109. }
  110.  
  111. /**
  112. * Set text
  113. *
  114. * @param string $text
  115. * @return Content
  116. */
  117. public function setText($text)
  118. {
  119. $this->text = $text;
  120.  
  121. return $this;
  122. }
  123.  
  124. /**
  125. * Get text
  126. *
  127. * @return string
  128. */
  129. public function getText()
  130. {
  131. return $this->text;
  132. }
  133.  
  134. /**
  135. * Set created
  136. *
  137. * @param DateTime $created
  138. * @return Content
  139. */
  140. public function setCreated($created)
  141. {
  142. $this->created = $created;
  143.  
  144. return $this;
  145. }
  146.  
  147. /**
  148. * Get created
  149. *
  150. * @return DateTime
  151. */
  152. public function getCreated()
  153. {
  154. return $this->created;
  155. }
  156.  
  157. /**
  158. * Set updated
  159. *
  160. * @param DateTime $updated
  161. * @return Content
  162. */
  163. public function setUpdated($updated)
  164. {
  165. $this->updated = $updated;
  166.  
  167. return $this;
  168. }
  169.  
  170. /**
  171. * Get updated
  172. *
  173. * @return DateTime
  174. */
  175. public function getUpdated()
  176. {
  177. return $this->updated;
  178. }
  179.  
  180. /**
  181. * Set contentChanged
  182. *
  183. * @param DateTime $contentChanged
  184. * @return Content
  185. */
  186. public function setContentChanged($contentChanged)
  187. {
  188. $this->contentChanged = $contentChanged;
  189.  
  190. return $this;
  191. }
  192.  
  193. /**
  194. * Get contentChanged
  195. *
  196. * @return DateTime
  197. */
  198. public function getContentChanged()
  199. {
  200. return $this->contentChanged;
  201. }
  202.  
  203. /**
  204. * Set slug
  205. *
  206. * @param string $slug
  207. * @return Content
  208. */
  209. public function setSlug($slug)
  210. {
  211. $this->slug = $slug;
  212.  
  213. return $this;
  214. }
  215.  
  216. /**
  217. * Get slug
  218. *
  219. * @return string
  220. */
  221. public function getSlug()
  222. {
  223. return $this->slug;
  224. }
  225. }
  226.  
  227. $content = new Content();
  228. $content->setTitle('Content example');
  229. $content->setText('Content example...');
  230. $em = $this->getDoctrine()->getEntityManager();
  231. $em->persist($content);
  232. $em->flush();
  233.  
  234. $content->setTranslatableLocale('fr'); // change locale
  235. $em->persist($content);
  236. $em->flush();
  237.  
  238. The class 'GedmoTranslatableEntityTranslation' was not found in the chain configured namespaces ...Entity, FOSUserBundleModel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement