Advertisement
Guest User

Text.php

a guest
Nov 18th, 2013
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.09 KB | None | 0 0
  1. <?php
  2. namespace Acme\EntityBundle\Entity;
  3.  
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Doctrine\ORM\Mapping as ORM;
  7.  
  8. /**
  9.  * @ORM\Entity
  10.  * @ORM\Table(name="texts")
  11.  * @Gedmo\TranslationEntity(class="Acme\EntityBundle\Entity\Translation\TextTranslation")
  12.  */
  13. class Text
  14. {
  15.      /**
  16.      * @ORM\Column(type="integer")
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      */
  20.     private $id;
  21.  
  22.     /**
  23.      * @Gedmo\Translatable
  24.      * @ORM\Column(length=64)
  25.      */
  26.     private $title;
  27.  
  28.     /**
  29.      * @Gedmo\Translatable
  30.      * @ORM\Column(type="text", nullable=true)
  31.      */
  32.     private $content;
  33.  
  34.    
  35.     /**
  36.      *
  37.      * @ORM\Column(type="integer")
  38.      */
  39.     private $author;
  40.    
  41.     /**
  42.      * @ORM\OneToMany(
  43.      *   targetEntity="Acme\EntityBundle\Entity\Translation\TextTranslation",
  44.      *   mappedBy="object",
  45.      *   cascade={"persist", "remove"}
  46.      * )
  47.      */
  48.     private $translations;
  49.  
  50.      /**
  51.      * Constructor
  52.      */
  53.     public function __construct()
  54.     {
  55.         $this->translations = new \Doctrine\Common\Collections\ArrayCollection();
  56.     }
  57.    
  58.     public function getTranslations()
  59.     {
  60.         return $this->translations;
  61.     }
  62.  
  63.     public function addTranslation(\Acme\EntityBundle\Entity\Translation\TextTranslation $t)
  64.     {
  65.         if (!$this->translations->contains($t)) {
  66.             $this->translations[] = $t;
  67.             $t->setObject($this);
  68.         }
  69.     }
  70.    
  71. public function __toString()
  72.     {
  73.         return $this->getTitle();
  74.     }
  75.    
  76.     /**
  77.      * Get id
  78.      *
  79.      * @return integer
  80.      */
  81.     public function getId()
  82.     {
  83.         return $this->id;
  84.     }
  85.  
  86.     /**
  87.      * Set title
  88.      *
  89.      * @param string $title
  90.      * @return Text
  91.      */
  92.     public function setTitle($title)
  93.     {
  94.         $this->title = $title;
  95.    
  96.         return $this;
  97.     }
  98.  
  99.     /**
  100.      * Get title
  101.      *
  102.      * @return string
  103.      */
  104.     public function getTitle()
  105.     {
  106.         return $this->title;
  107.     }
  108.  
  109.     /**
  110.      * Set content
  111.      *
  112.      * @param string $content
  113.      * @return Text
  114.      */
  115.     public function setContent($content)
  116.     {
  117.         $this->content = $content;
  118.    
  119.         return $this;
  120.     }
  121.  
  122.     /**
  123.      * Get content
  124.      *
  125.      * @return string
  126.      */
  127.     public function getContent()
  128.     {
  129.         return $this->content;
  130.     }
  131.  
  132.     /**
  133.      * Set author
  134.      *
  135.      * @param integer $author
  136.      * @return Text
  137.      */
  138.     public function setAuthor($author)
  139.     {
  140.         $this->author = $author;
  141.    
  142.         return $this;
  143.     }
  144.  
  145.     /**
  146.      * Get author
  147.      *
  148.      * @return integer
  149.      */
  150.     public function getAuthor()
  151.     {
  152.         return $this->author;
  153.     }
  154.  
  155.    
  156.  
  157.     /**
  158.      * Remove translations
  159.      *
  160.      * @param \Acme\EntityBundle\Entity\Translation\TextTranslation $translations
  161.      */
  162.     public function removeTranslation(\Acme\EntityBundle\Entity\Translation\TextTranslation $translations)
  163.     {
  164.         $this->translations->removeElement($translations);
  165.     }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement