Advertisement
Guest User

Untitled

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