Advertisement
Guest User

Keywords Entity

a guest
Jul 26th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppBundle\Entity;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\ORM\Mapping\Index as Index;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7.  
  8. /**
  9.  *
  10.  * @ORM\Table(name="sm_keywords", indexes={@Index(name="name_x", columns={"id", "name"})})
  11.  * @ORM\Entity
  12.  */
  13. class Keywords
  14. {
  15.     /**
  16.      * @var integer
  17.      *
  18.      * @ORM\Column(name="id", type="integer")
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue(strategy="AUTO")
  21.      * @ORM\OrderBy({"name" = "DESC"})
  22.      */
  23.     private $id;
  24.  
  25.     /**
  26.      * @var string
  27.      *
  28.      * @ORM\Column(name="name", type="string", length=255, nullable=true)
  29.      */
  30.     private $name;
  31.  
  32.     /**
  33.      * @ORM\ManyToMany(targetEntity="File", inversedBy="keywords", indexBy="id",cascade={"persist"})
  34.      * @ORM\JoinTable(name="sm_file_keywords")
  35.      */
  36.     private $file;
  37.  
  38.     public function __construct($name = null) {
  39.         $this->name = $name;
  40.         $this->file = new ArrayCollection();
  41.     }
  42.  
  43.     /**
  44.      * @return int
  45.      */
  46.     public function getId()
  47.     {
  48.         return $this->id;
  49.     }
  50.  
  51.     /**
  52.      * @param int $id
  53.      */
  54.     public function setId($id)
  55.     {
  56.         $this->id = $id;
  57.     }
  58.  
  59.     /**
  60.      * @return string
  61.      */
  62.     public function getName()
  63.     {
  64.         return $this->name;
  65.     }
  66.  
  67.     /**
  68.      * @param string $name
  69.      */
  70.     public function setName($name)
  71.     {
  72.         $this->name = $name;
  73.     }
  74.  
  75.     /**
  76.      * @return mixed
  77.      */
  78.     public function getFile()
  79.     {
  80.         return $this->file;
  81.     }
  82.  
  83.     /**
  84.      * @param mixed $file
  85.      */
  86.     public function setFile($file)
  87.     {
  88.         $this->file = $file;
  89.     }
  90.  
  91.     public function addFile(File $file){
  92.         if (!$this->file->contains($file)) {
  93.             $this->file[] = $file;
  94.         }
  95.     }
  96.     /**
  97.      * Remove keyword
  98.      */
  99.     public function removeFile($file)
  100.     {
  101.         if ($this->file->contains($file)) {
  102.             $this->file->removeElement($file);
  103.         }
  104.  
  105.     }
  106.  
  107.  
  108.  
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement