Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace My\Bundle\Entity\Post;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\HttpFoundation\File\File;
- use Vich\UploaderBundle\Mapping\Annotation as Vich;
- /**
- * GalleryImage
- *
- * @ORM\Table()
- * @ORM\Entity
- * @Vich\Uploadable
- */
- class GalleryImage
- {
- /**
- * @var integer
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @ORM\ManyToOne(targetEntity="Gallery", inversedBy="galleryImage", cascade={"persist"})
- * @ORM\JoinColumn(name="gallery_id", referencedColumnName="id")
- */
- protected $gallery;
- /**
- * @Vich\UploadableField(mapping="post_image", fileNameProperty="imageName")
- *
- * @var File $image
- */
- protected $image;
- /**
- * @ORM\Column(type="string", length=255, name="image_name")
- *
- * @var string $imageName
- */
- protected $imageName;
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
- * of 'UploadedFile' is injected into this setter to trigger the update. If this
- * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
- * must be able to accept an instance of 'File' as the bundle will inject one here
- * during Doctrine hydration.
- *
- * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
- */
- public function setImage(File $image)
- {
- $this->image = $image;
- if ($image) {
- $this->updatedAt = new \DateTime('now');
- }
- }
- /**
- * @return File
- */
- public function getImage()
- {
- return $this->image;
- }
- /**
- * Set gallery
- *
- * @param \My\Bundle\Entity\Post\Gallery $gallery
- * @return GalleryImage
- */
- public function setGallery(\My\Bundle\Entity\Post\Gallery $gallery = null)
- {
- $this->gallery = $gallery;
- return $this;
- }
- /**
- * Get gallery
- *
- * @return \My\Bundle\Entity\Post\Gallery
- */
- public function getGallery()
- {
- return $this->gallery;
- }
- /**
- * Set imageName
- *
- * @param string $imageName
- * @return GalleryImage
- */
- public function setImageName($imageName)
- {
- $this->imageName = $imageName;
- return $this;
- }
- /**
- * Get imageName
- *
- * @return string
- */
- public function getImageName()
- {
- return $this->imageName;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement