Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "gedmo/doctrine-extensions": "2.3.*@dev"
- stof_doctrine_extensions:
- orm:
- alopatria:
- timestampable: true
- sluggable: true
- translatable: true
- <?php
- namespace ...;
- use GedmoMappingAnnotation as Gedmo;
- use DoctrineORMMapping as ORM;
- use GedmoTranslatableTranslatable;
- /**
- * ...Entity
- *
- * @ORMTable(name="content")
- * @ORMHasLifecycleCallbacks
- * @ORMEntity(repositoryClass="...EntityContentRepository")
- */
- class Content implements Translatable
- {
- /**
- *
- * @ORMColumn(name="id", type="bigint", nullable=false)
- * @ORMId
- * @ORMGeneratedValue(strategy="IDENTITY")
- */
- protected $id;
- /**
- * @GedmoTranslatable
- * @ORMColumn(name="title", type="string", length=32, nullable=false)
- */
- protected $title;
- /**
- * @GedmoTranslatable
- * @ORMColumn(name="text", type="text", nullable=false)
- */
- protected $text;
- /**
- * @var datetime $created
- *
- * @GedmoTimestampable(on="create")
- * @ORMColumn(type="datetime")
- */
- private $created;
- /**
- * @var datetime $updated
- *
- * @GedmoTimestampable(on="update")
- * @ORMColumn(type="datetime")
- */
- private $updated;
- /**
- * @var datetime $contentChanged
- *
- * @ORMColumn(name="content_changed", type="datetime", nullable=true)
- * @GedmoTimestampable(on="change", field={"title", "text"})
- */
- private $contentChanged;
- /**
- * @GedmoSlug(fields={"title"})
- * @ORMColumn(length=128, unique=true)
- */
- private $slug;
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set title
- *
- * @param string $title
- * @return Content
- */
- public function setTitle($title)
- {
- $this->title = $title;
- return $this;
- }
- /**
- * Get title
- *
- * @return string
- */
- public function getTitle()
- {
- return $this->title;
- }
- /**
- * Set text
- *
- * @param string $text
- * @return Content
- */
- public function setText($text)
- {
- $this->text = $text;
- return $this;
- }
- /**
- * Get text
- *
- * @return string
- */
- public function getText()
- {
- return $this->text;
- }
- /**
- * Set created
- *
- * @param DateTime $created
- * @return Content
- */
- public function setCreated($created)
- {
- $this->created = $created;
- return $this;
- }
- /**
- * Get created
- *
- * @return DateTime
- */
- public function getCreated()
- {
- return $this->created;
- }
- /**
- * Set updated
- *
- * @param DateTime $updated
- * @return Content
- */
- public function setUpdated($updated)
- {
- $this->updated = $updated;
- return $this;
- }
- /**
- * Get updated
- *
- * @return DateTime
- */
- public function getUpdated()
- {
- return $this->updated;
- }
- /**
- * Set contentChanged
- *
- * @param DateTime $contentChanged
- * @return Content
- */
- public function setContentChanged($contentChanged)
- {
- $this->contentChanged = $contentChanged;
- return $this;
- }
- /**
- * Get contentChanged
- *
- * @return DateTime
- */
- public function getContentChanged()
- {
- return $this->contentChanged;
- }
- /**
- * Set slug
- *
- * @param string $slug
- * @return Content
- */
- public function setSlug($slug)
- {
- $this->slug = $slug;
- return $this;
- }
- /**
- * Get slug
- *
- * @return string
- */
- public function getSlug()
- {
- return $this->slug;
- }
- }
- $content = new Content();
- $content->setTitle('Content example');
- $content->setText('Content example...');
- $em = $this->getDoctrine()->getEntityManager();
- $em->persist($content);
- $em->flush();
- $content->setTranslatableLocale('fr'); // change locale
- $em->persist($content);
- $em->flush();
- The class 'GedmoTranslatableEntityTranslation' was not found in the chain configured namespaces ...Entity, FOSUserBundleModel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement