src/Notaris/AdminBundle/Entity/Faq.php line 19

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: lisavandaele
  5.  * Date: 30/01/15
  6.  * Time: 12:53
  7.  */
  8. namespace Notaris\AdminBundle\Entity;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @ORM\Entity(repositoryClass="FaqRepository")
  14.  * @ORM\Table(name="faq")
  15.  */
  16. class Faq {
  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.      * @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\User")
  27.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="SET NULL")
  28.      */
  29.     private $user;
  30.     /**
  31.      * @Gedmo\Timestampable(on="create")
  32.      * @ORM\Column(name="created", type="datetime")
  33.      */
  34.     private $created;
  35.     /**
  36.      * @ORM\Column(name="updated", type="datetime")
  37.      * @Gedmo\Timestampable(on="update")
  38.      */
  39.     private $updated;
  40.     /**
  41.      * @var string
  42.      *
  43.      * @ORM\Column(name="locale", type="string", length=5)
  44.      */
  45.     private $locale;
  46.     /**
  47.      * @var string
  48.      *
  49.      * @ORM\Column(name="title", type="text")
  50.      */
  51.     private $title;
  52.     /**
  53.      * @var string
  54.      *
  55.      * @ORM\Column(name="subtitle", type="text")
  56.      */
  57.     private $subtitle;
  58.     /**
  59.      * @ORM\Column(type="text", name="answer")
  60.      */
  61.     private $answer;
  62.     /**
  63.      * @ORM\OneToOne(targetEntity="Asset", cascade={"remove"})
  64.      * @ORM\JoinColumn(name="asset_id", referencedColumnName="id")
  65.      */
  66.     protected $asset;
  67.     /**
  68.      * @ORM\Column(type="boolean", name="is_active")
  69.      * @Assert\Type("boolean")
  70.      */
  71.     private $isActive;
  72.     /**
  73.      * @ORM\Column(name="pub_date", type="datetime")
  74.      */
  75.     private $publicationDate;
  76.     /**
  77.      * @ORM\Column(type="boolean", name="is_general")
  78.      * @Assert\Type("boolean")
  79.      */
  80.     private $isGeneral;
  81.     /**
  82.      * @var integer
  83.      *
  84.      * @ORM\Column(type="integer", name="count_clicked")
  85.      */
  86.     private $countClicked = 0;
  87.     /**
  88.      * @ORM\OneToOne(targetEntity="News", inversedBy="faq", cascade={"remove"})
  89.      * @ORM\JoinColumn(name="news_id", referencedColumnName="id", onDelete="SET NULL")
  90.      */
  91.     protected $news;
  92.     /**
  93.      * @ORM\ManyToMany(targetEntity="Tag", inversedBy="faqItems")
  94.      * @ORM\JoinTable(name="tag_faq")
  95.      */
  96.     protected $tags;
  97.     /**
  98.      * @Gedmo\Slug(fields={"title"})
  99.      * @ORM\Column(length=128, unique=true)
  100.      */
  101.     private $slug;
  102.     /**
  103.      * @ORM\OneToOne(targetEntity="Meta", cascade={"remove"})
  104.      * @ORM\JoinColumn(name="meta_id", referencedColumnName="id")
  105.      */
  106.     protected $meta;
  107.     /**
  108.      * @ORM\OneToMany(targetEntity="FaqSubsite", mappedBy="faq")
  109.      * @ORM\OrderBy({"position" = "asc"})
  110.      */
  111.     private $subsites;
  112.     /**
  113.      * @ORM\Column(type="boolean", name="show_in_subsite", options={"default":1})
  114.      * @Assert\Type("boolean")
  115.      */
  116.     private $showInSubsite;
  117.     /**
  118.      * Constructor
  119.      */
  120.     public function __construct()
  121.     {
  122.         $this->attachments = new \Doctrine\Common\Collections\ArrayCollection();
  123.         $this->links = new \Doctrine\Common\Collections\ArrayCollection();
  124.     }
  125.     /**
  126.      * @return int|string
  127.      */
  128.     public function getRelatedTo(){
  129.         if($this->getSubsites()){
  130.             $count = count($this->getSubsites());
  131.             if($count){
  132.                 $subsites = $this->getSubsites();
  133.                 $result = array();
  134.                 foreach($subsites as $subsite){
  135.                     $result[] = $subsite->getSubsite();
  136.                 }
  137.                 return  implode('<br/>', $result);
  138.             }
  139.             else{
  140.                 return $count;
  141.             }
  142.         }
  143.         return '';
  144.     }
  145.     /**
  146.      * @return string
  147.      */
  148.     public function getRenderStatus()
  149.     {
  150.         if ($this->getIsActive()) {
  151.             $now = new \DateTime('now');
  152.             $date = $this->getPublicationDate();
  153.             if ($date <= $now) {
  154.                 return '<span class="label label-success">ON</span>';
  155.             }
  156.             return '<span class="label label-warning">...</span>';
  157.         }
  158.         return '<span class="label label-danger">OFF</span>';
  159.     }
  160.     /**
  161.      * Get id
  162.      *
  163.      * @return integer
  164.      */
  165.     public function getId()
  166.     {
  167.         return $this->id;
  168.     }
  169.     /**
  170.      * Set created
  171.      *
  172.      * @param \DateTime $created
  173.      * @return Faq
  174.      */
  175.     public function setCreated($created)
  176.     {
  177.         $this->created = $created;
  178.         return $this;
  179.     }
  180.     /**
  181.      * Get created
  182.      *
  183.      * @return \DateTime
  184.      */
  185.     public function getCreated()
  186.     {
  187.         return $this->created;
  188.     }
  189.     /**
  190.      * Set updated
  191.      *
  192.      * @param \DateTime $updated
  193.      * @return Faq
  194.      */
  195.     public function setUpdated($updated)
  196.     {
  197.         $this->updated = $updated;
  198.         return $this;
  199.     }
  200.     /**
  201.      * Get updated
  202.      *
  203.      * @return \DateTime
  204.      */
  205.     public function getUpdated()
  206.     {
  207.         return $this->updated;
  208.     }
  209.     /**
  210.      * Set locale
  211.      *
  212.      * @param string $locale
  213.      * @return Faq
  214.      */
  215.     public function setLocale($locale)
  216.     {
  217.         $this->locale = $locale;
  218.         return $this;
  219.     }
  220.     /**
  221.      * Get locale
  222.      *
  223.      * @return string
  224.      */
  225.     public function getLocale()
  226.     {
  227.         return $this->locale;
  228.     }
  229.     /**
  230.      * Set title
  231.      *
  232.      * @param string $title
  233.      * @return Faq
  234.      */
  235.     public function setTitle($title)
  236.     {
  237.         $this->title = $title;
  238.         return $this;
  239.     }
  240.     /**
  241.      * Get title
  242.      *
  243.      * @return string
  244.      */
  245.     public function getTitle()
  246.     {
  247.         return $this->title;
  248.     }
  249.     /**
  250.      * Set subtitle
  251.      *
  252.      * @param string $subtitle
  253.      * @return Faq
  254.      */
  255.     public function setSubtitle($subtitle)
  256.     {
  257.         $this->subtitle = $subtitle;
  258.         return $this;
  259.     }
  260.     /**
  261.      * Get subtitle
  262.      *
  263.      * @return string
  264.      */
  265.     public function getSubtitle()
  266.     {
  267.         return $this->subtitle;
  268.     }
  269.     /**
  270.      * Set answer
  271.      *
  272.      * @param string $answer
  273.      * @return Faq
  274.      */
  275.     public function setAnswer($answer)
  276.     {
  277.         $this->answer = $answer;
  278.         return $this;
  279.     }
  280.     /**
  281.      * Get answer
  282.      *
  283.      * @return string
  284.      */
  285.     public function getAnswer()
  286.     {
  287.         return $this->answer;
  288.     }
  289.     /**
  290.      * Set isActive
  291.      *
  292.      * @param boolean $isActive
  293.      * @return Faq
  294.      */
  295.     public function setIsActive($isActive)
  296.     {
  297.         $this->isActive = $isActive;
  298.         return $this;
  299.     }
  300.     /**
  301.      * Get isActive
  302.      *
  303.      * @return boolean
  304.      */
  305.     public function getIsActive()
  306.     {
  307.         return $this->isActive;
  308.     }
  309.     /**
  310.      * Set publicationDate
  311.      *
  312.      * @param \DateTime $publicationDate
  313.      * @return Faq
  314.      */
  315.     public function setPublicationDate($publicationDate)
  316.     {
  317.         $this->publicationDate = $publicationDate;
  318.         return $this;
  319.     }
  320.     /**
  321.      * Get publicationDate
  322.      *
  323.      * @return \DateTime
  324.      */
  325.     public function getPublicationDate()
  326.     {
  327.         return $this->publicationDate;
  328.     }
  329.     /**
  330.      * Set slug
  331.      *
  332.      * @param string $slug
  333.      * @return Faq
  334.      */
  335.     public function setSlug($slug)
  336.     {
  337.         $this->slug = $slug;
  338.         return $this;
  339.     }
  340.     /**
  341.      * Get slug
  342.      *
  343.      * @return string
  344.      */
  345.     public function getSlug()
  346.     {
  347.         return $this->slug;
  348.     }
  349.     /**
  350.      * Set user
  351.      *
  352.      * @param \Notaris\AdminBundle\Entity\User $user
  353.      * @return Faq
  354.      */
  355.     public function setUser(\Notaris\AdminBundle\Entity\User $user = null)
  356.     {
  357.         $this->user = $user;
  358.         return $this;
  359.     }
  360.     /**
  361.      * Get user
  362.      *
  363.      * @return \Notaris\AdminBundle\Entity\User
  364.      */
  365.     public function getUser()
  366.     {
  367.         return $this->user;
  368.     }
  369.     /**
  370.      * Set news
  371.      *
  372.      * @param \Notaris\AdminBundle\Entity\News $news
  373.      * @return Faq
  374.      */
  375.     public function setNews(\Notaris\AdminBundle\Entity\News $news = null)
  376.     {
  377.         $this->news = $news;
  378.         return $this;
  379.     }
  380.     /**
  381.      * Get news
  382.      *
  383.      * @return \Notaris\AdminBundle\Entity\News
  384.      */
  385.     public function getNews()
  386.     {
  387.         return $this->news;
  388.     }
  389.     /**
  390.      * Set meta
  391.      *
  392.      * @param \Notaris\AdminBundle\Entity\Meta $meta
  393.      * @return Faq
  394.      */
  395.     public function setMeta(\Notaris\AdminBundle\Entity\Meta $meta = null)
  396.     {
  397.         $this->meta = $meta;
  398.         return $this;
  399.     }
  400.     /**
  401.      * Get meta
  402.      *
  403.      * @return \Notaris\AdminBundle\Entity\Meta
  404.      */
  405.     public function getMeta()
  406.     {
  407.         return $this->meta;
  408.     }
  409.     /**
  410.      * Add tags
  411.      *
  412.      * @param \Notaris\AdminBundle\Entity\Tag $tags
  413.      * @return Faq
  414.      */
  415.     public function addTag(\Notaris\AdminBundle\Entity\Tag $tags)
  416.     {
  417.         $this->tags[] = $tags;
  418.         return $this;
  419.     }
  420.     /**
  421.      * Remove tags
  422.      *
  423.      * @param \Notaris\AdminBundle\Entity\Tag $tags
  424.      */
  425.     public function removeTag(\Notaris\AdminBundle\Entity\Tag $tags)
  426.     {
  427.         $this->tags->removeElement($tags);
  428.     }
  429.     /**
  430.      * Get tags
  431.      *
  432.      * @return \Doctrine\Common\Collections\Collection
  433.      */
  434.     public function getTags()
  435.     {
  436.         return $this->tags;
  437.     }
  438.     /**
  439.      * Set asset
  440.      *
  441.      * @param \Notaris\AdminBundle\Entity\Asset $asset
  442.      * @return Faq
  443.      */
  444.     public function setAsset(\Notaris\AdminBundle\Entity\Asset $asset = null)
  445.     {
  446.         $this->asset = $asset;
  447.         return $this;
  448.     }
  449.     /**
  450.      * Get asset
  451.      *
  452.      * @return \Notaris\AdminBundle\Entity\Asset
  453.      */
  454.     public function getAsset()
  455.     {
  456.         return $this->asset;
  457.     }
  458.     /**
  459.      * Add subsites
  460.      *
  461.      * @param \Notaris\AdminBundle\Entity\FaqSubsite $subsites
  462.      * @return Faq
  463.      */
  464.     public function addSubsite(\Notaris\AdminBundle\Entity\FaqSubsite $subsites)
  465.     {
  466.         $this->subsites[] = $subsites;
  467.         return $this;
  468.     }
  469.     /**
  470.      * Remove subsites
  471.      *
  472.      * @param \Notaris\AdminBundle\Entity\FaqSubsite $subsites
  473.      */
  474.     public function removeSubsite(\Notaris\AdminBundle\Entity\FaqSubsite $subsites)
  475.     {
  476.         $this->subsites->removeElement($subsites);
  477.     }
  478.     /**
  479.      * Get subsites
  480.      *
  481.      * @return \Doctrine\Common\Collections\Collection
  482.      */
  483.     public function getSubsites()
  484.     {
  485.         return $this->subsites;
  486.     }
  487.     /**
  488.      * Set countClicked
  489.      *
  490.      * @param integer $countClicked
  491.      * @return Faq
  492.      */
  493.     public function setCountClicked($countClicked)
  494.     {
  495.         $this->countClicked = $countClicked;
  496.         return $this;
  497.     }
  498.     /**
  499.      * Get countClicked
  500.      *
  501.      * @return integer
  502.      */
  503.     public function getCountClicked()
  504.     {
  505.         return $this->countClicked;
  506.     }
  507.     /**
  508.      * Set isGeneral
  509.      *
  510.      * @param boolean $isGeneral
  511.      * @return Faq
  512.      */
  513.     public function setIsGeneral($isGeneral)
  514.     {
  515.         $this->isGeneral = $isGeneral;
  516.         return $this;
  517.     }
  518.     /**
  519.      * Get isGeneral
  520.      *
  521.      * @return boolean
  522.      */
  523.     public function getIsGeneral()
  524.     {
  525.         return $this->isGeneral;
  526.     }
  527.     /**
  528.      * Set oldId
  529.      *
  530.      * @param integer $oldId
  531.      * @return Faq
  532.      */
  533.     public function setOldId($oldId)
  534.     {
  535.         $this->oldId = $oldId;
  536.         return $this;
  537.     }
  538.     /**
  539.      * Get oldId
  540.      *
  541.      * @return integer
  542.      */
  543.     public function getOldId()
  544.     {
  545.         return $this->oldId;
  546.     }
  547.     /**
  548.      * Set showInSubsite
  549.      *
  550.      * @param boolean $showInSubsite
  551.      * @return Faq
  552.      */
  553.     public function setShowInSubsite($showInSubsite)
  554.     {
  555.         $this->showInSubsite = $showInSubsite;
  556.         return $this;
  557.     }
  558.     /**
  559.      * Get showInSubsite
  560.      *
  561.      * @return boolean
  562.      */
  563.     public function getShowInSubsite()
  564.     {
  565.         return $this->showInSubsite;
  566.     }
  567. }