<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;

abstract class HomeItem
{
	protected $id;

	public function setId($id)
	{
		$this->id = $id;
	}

	public function getId()
	{
		return $this->id;
	}

	/**
	 * @ORM\Column(type="integer")
	 */
	protected $position = -1;

	public function setPosition($position)
	{
		$this->position = $position;
	}

	public function getPosition()
	{
		return $this->position;
	}

	/**
	 * @Vich\UploadableField(mapping="home_images", fileNameProperty="image")
	 * @var File
	 * @Assert\File(
	 *     maxSize = "1M"
	 * )
	 */
	protected $imageFile;

	/**
	 * @ORM\Column(type="datetime")
	 * @var \DateTime
	 */
	protected $imageUpdatedAt;

	public function setImageFile(File $image = null)
	{
		$this->imageFile = $image;

		// VERY IMPORTANT:
		// It is required that at least one field changes if you are using Doctrine,
		// otherwise the event listeners won't be called and the file is lost
		if ($image) {
			// if 'imageUpdatedAt' is not defined in your entity, use another property
			$this->imageUpdatedAt = new \DateTime('now');
		}
	}

	public function getImageFile()
	{
		return $this->imageFile;
	}

	/**
	 * @ORM\Column(type="string", length=255)
	 * @var string
	 */
	protected $image;

	public function setImage($image)
	{
		$this->image = $image;
	}

	public function getImage()
	{
		return $this->image;
	}
}
