<?php

namespace RxConnexionBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use RxConnexionBundle\Entity\Base\BaseEntity;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\MaxDepth;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\FrequentlyAskedQuestionRepository")
 * @ORM\Table(name="frequently_asked_question")
 * @ORM\HasLifecycleCallbacks()
 */
 
class FrequentlyAskedQuestionEntity extends BaseEntity
{
    /**
     * @ORM\Column(type="bigint")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
	protected $id;

    /**
     * @ORM\Column(name="code", type="string", nullable=true)
     */
	protected $code;
	
    /**
     * @ORM\Column(name="description", type="string")
     */
	protected $description;

    /**
     * @ORM\Column(name="note", type="text", nullable=true)
     * @Groups("forAudit")
     */
    protected $note;

    /**
     * @ORM\Column(name="is_deleted", type="boolean")
     */
    protected $isDeleted;

    /**
     * @ORM\ManyToOne(targetEntity="RxConnexionBundle\Entity\FileTypeEntity", inversedBy="fileTypes")
     * @ORM\JoinColumn(name="file_type_id", referencedColumnName="id")
     * @Groups("forAudit")
     * @MaxDepth(1)
     */
    protected $fileType;

    /**
     * @ORM\OneToMany(targetEntity="FrequentlyAskedQuestionFileEntity", mappedBy="frequentlyAskedQuestion", orphanRemoval=true, cascade={"persist", "remove"})
     */
    protected $frequentlyAskedQuestionFiles;

    /**
     * Set createdAt
     *
     * @ORM\PrePersist
     */
    public function setCreatedAtValue()
    {
        parent::setCreatedAtValue();
        $this->isDeleted = 0;
    }

    public function __construct($data=null)
    {
    	if(!is_null($data)) {
    		$this->id = $data->getId();
	    	$this->code = $data->getCode();
            $this->description = $data->getDescription();
            $this->note = $data->getNote();
            $this->fileType = $data->getFileType();
    	}

        $this->frequentlyAskedQuestionFiles = new ArrayCollection();
    }

	/*--------------------------------------------------------------------------------------------------------*/
	/*					User Defined Setters and Getters													  */
	/*--------------------------------------------------------------------------------------------------------*/

    /**
     * Get idEncoded
     *
     * @return string
     */
    public function getIdEncoded(){

        return base64_encode($this->id);
    }

    /*--------------------------------------------------------------------------------------------------------*/
    /*					Setters and Getters													                  */
    /*--------------------------------------------------------------------------------------------------------*/



    /**
     * Set code
     *
     * @param string $code
     *
     * @return FrequentlyAskedQuestionEntity
     */
    public function setCode($code)
    {
        $this->code = $code;

        return $this;
    }

    /**
     * Get code
     *
     * @return string
     */
    public function getCode()
    {
        return $this->code;
    }

    /**
     * Set description
     *
     * @param string $description
     *
     * @return FrequentlyAskedQuestionEntity
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get description
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set note
     *
     * @param string $note
     *
     * @return FrequentlyAskedQuestionEntity
     */
    public function setNote($note)
    {
        $this->note = $note;

        return $this;
    }

    /**
     * Get note
     *
     * @return string
     */
    public function getNote()
    {
        return $this->note;
    }

    /**
     * Set isDeleted
     *
     * @param boolean $isDeleted
     *
     * @return FrequentlyAskedQuestionEntity
     */
    public function setIsDeleted($isDeleted)
    {
        $this->isDeleted = $isDeleted;

        return $this;
    }

    /**
     * Get isDeleted
     *
     * @return boolean
     */
    public function getIsDeleted()
    {
        return $this->isDeleted;
    }

    /**
     * Set fileType
     *
     * @param \RxConnexionBundle\Entity\FileTypeEntity $fileType
     *
     * @return FrequentlyAskedQuestionEntity
     */
    public function setFileType(\RxConnexionBundle\Entity\FileTypeEntity $fileType = null)
    {
        $this->fileType = $fileType;

        return $this;
    }

    /**
     * Get fileType
     *
     * @return \RxConnexionBundle\Entity\FileTypeEntity
     */
    public function getFileType()
    {
        return $this->fileType;
    }

    /**
     * Add frequentlyAskedQuestionFile
     *
     * @param \RxConnexionBundle\Entity\FrequentlyAskedQuestionFileEntity $frequentlyAskedQuestionFile
     *
     * @return FrequentlyAskedQuestionEntity
     */
    public function addFrequentlyAskedQuestionFile(\RxConnexionBundle\Entity\FrequentlyAskedQuestionFileEntity $frequentlyAskedQuestionFile)
    {
        $this->frequentlyAskedQuestionFiles[] = $frequentlyAskedQuestionFile;

        return $this;
    }

    /**
     * Remove frequentlyAskedQuestionFile
     *
     * @param \RxConnexionBundle\Entity\FrequentlyAskedQuestionFileEntity $frequentlyAskedQuestionFile
     */
    public function removeFrequentlyAskedQuestionFile(\RxConnexionBundle\Entity\FrequentlyAskedQuestionFileEntity $frequentlyAskedQuestionFile)
    {
        $this->frequentlyAskedQuestionFiles->removeElement($frequentlyAskedQuestionFile);
    }

    /**
     * Get frequentlyAskedQuestionFiles
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getFrequentlyAskedQuestionFiles()
    {
        return $this->frequentlyAskedQuestionFiles;
    }
}
