Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.66 KB | None | 0 0
  1. <?php
  2.  
  3. namespace My\Bundle\Entity\Post;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8.  
  9. /**
  10.  * GalleryImage
  11.  *
  12.  * @ORM\Table()
  13.  * @ORM\Entity
  14.  */
  15. class GalleryImage
  16. {
  17.     /**
  18.      * @var integer
  19.      *
  20.      * @ORM\Column(name="id", type="integer")
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     private $id;
  25.  
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity="Gallery", inversedBy="images")
  28.      * @ORM\JoinColumn(name="gallery_id", referencedColumnName="id")
  29.      */
  30.     protected $gallery;
  31.  
  32.     /**
  33.      * @Vich\UploadableField(mapping="post_image", fileNameProperty="image_name")
  34.      *
  35.      * @var File $image
  36.      */
  37.     protected $image;
  38.  
  39.     /**
  40.      * @ORM\Column(type="string", length=255, name="image_name")
  41.      *
  42.      * @var string $imageName
  43.      */
  44.     protected $imageName;
  45.  
  46.  
  47.     /**
  48.      * Get id
  49.      *
  50.      * @return integer
  51.      */
  52.     public function getId()
  53.     {
  54.         return $this->id;
  55.     }
  56.  
  57.     /**
  58.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  59.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  60.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  61.      * must be able to accept an instance of 'File' as the bundle will inject one here
  62.      * during Doctrine hydration.
  63.      *
  64.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
  65.      */
  66.     public function setImage(File $image)
  67.     {
  68.         $this->image = $image;
  69.  
  70.         if ($image) {
  71.             $this->updatedAt = new \DateTime('now');
  72.         }
  73.     }
  74.  
  75.     /**
  76.      * @return File
  77.      */
  78.     public function getImage()
  79.     {
  80.         return $this->image;
  81.     }
  82.  
  83.     /**
  84.      * Set gallery
  85.      *
  86.      * @param \My\Bundle\Entity\Post\Gallery $gallery
  87.      * @return GalleryImage
  88.      */
  89.     public function setGallery(\My\Bundle\Entity\Post\Gallery $gallery = null)
  90.     {
  91.         $this->gallery = $gallery;
  92.  
  93.         return $this;
  94.     }
  95.  
  96.     /**
  97.      * Get gallery
  98.      *
  99.      * @return \My\Bundle\Entity\Post\Gallery
  100.      */
  101.     public function getGallery()
  102.     {
  103.         return $this->gallery;
  104.     }
  105.  
  106.     /**
  107.      * Set imageName
  108.      *
  109.      * @param string $imageName
  110.      * @return GalleryImage
  111.      */
  112.     public function setImageName($imageName)
  113.     {
  114.         $this->imageName = $imageName;
  115.  
  116.         return $this;
  117.     }
  118.  
  119.     /**
  120.      * Get imageName
  121.      *
  122.      * @return string
  123.      */
  124.     public function getImageName()
  125.     {
  126.         return $this->imageName;
  127.     }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement