src/Notaris/AdminBundle/Entity/SectionParagraph.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="SectionParagraphRepository")
  14.  * @ORM\Table(name="section_paragraph")
  15.  */
  16. class SectionParagraph {
  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.      * @Gedmo\Timestampable(on="create")
  27.      * @ORM\Column(name="created", type="datetime")
  28.      */
  29.     private $created;
  30.     /**
  31.      * @ORM\Column(name="updated", type="datetime")
  32.      * @Gedmo\Timestampable(on="update")
  33.      */
  34.     private $updated;
  35.     /**
  36.      * @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\User")
  37.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="SET NULL")
  38.      */
  39.     private $user;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\Section", inversedBy="paragraphs")
  42.      * @ORM\JoinColumn(name="section_id", referencedColumnName="id", onDelete="CASCADE")
  43.      */
  44.     private $section;
  45.     /**
  46.      * @var integer
  47.      *
  48.      * @ORM\Column(type="integer")
  49.      */
  50.     private $position = 0;
  51.     /**
  52.      * @var integer
  53.      *
  54.      * @ORM\Column(type="integer")
  55.      */
  56.     private $type = 0;
  57.     /**
  58.      * @var integer
  59.      *
  60.      * @ORM\Column(type="integer")
  61.      */
  62.     private $accordionStatus = 0;
  63.     /**
  64.      * @var string
  65.      *
  66.      * @ORM\Column(name="title", type="text")
  67.      */
  68.     private $title;
  69.     /**
  70.      * @var string
  71.      *
  72.      * @ORM\Column(name="subtitle", type="text")
  73.      */
  74.     private $subtitle;
  75.     /**
  76.      * @ORM\Column(type="text", name="description")
  77.      */
  78.     private $description;
  79.     /**
  80.      * @ORM\OneToOne(targetEntity="Asset")
  81.      * @ORM\JoinColumn(name="asset_id", referencedColumnName="id")
  82.      */
  83.     protected $asset;
  84.     
  85.     /**
  86.      * @ORM\Column(type="boolean", name="is_active")
  87.      * @Assert\Type("boolean")
  88.      */
  89.     private $isActive;
  90.     /**
  91.      * @ORM\Column(name="pub_date", type="datetime")
  92.      */
  93.     private $publicationDate;
  94.     /**
  95.      * @var string
  96.      *
  97.      * @ORM\Column(name="locale", type="string", length=5)
  98.      */
  99.     private $locale;
  100. //    /**
  101. //     * @ORM\OneToOne(targetEntity="Video")
  102. //     * @ORM\JoinColumn(name="video_id", referencedColumnName="id")
  103. //     */
  104. //    private $video;
  105. //
  106. //    /**
  107. //     * @ORM\Column(type="boolean", name="is_youtube")
  108. //     * @Assert\Type("boolean")
  109. //     */
  110. //    private $isYoutube;
  111.     /**
  112.      * Constructor
  113.      */
  114.     public function __construct()
  115.     {
  116.     }
  117.     /**
  118.      * @return string
  119.      */
  120.     public function __toString(){
  121.         if($this->getTitle()) {
  122.             return $this->getTitle();
  123.         }
  124.         if($this->getSubtitle()) {
  125.             return $this->getSubtitle();
  126.         }
  127.         if($this->getDescription()) {
  128.             return strip_tags($this->getDescription());
  129.         }
  130.         return 'None';
  131.     }
  132.     /**
  133.      * @return string
  134.      */
  135.     public function getRenderStatus()
  136.     {
  137.         if ($this->getIsActive()) {
  138.             $now = new \DateTime('now');
  139.             $date = $this->getPublicationDate();
  140.             if ($date <= $now) {
  141.                 return '<span class="label label-success">ON</span>';
  142.             }
  143.             return '<span class="label label-warning">...</span>';
  144.         }
  145.         return '<span class="label label-danger">OFF</span>';
  146.     }
  147.     /**
  148.      * Get id
  149.      *
  150.      * @return integer 
  151.      */
  152.     public function getId()
  153.     {
  154.         return $this->id;
  155.     }
  156.     /**
  157.      * Set created
  158.      *
  159.      * @param \DateTime $created
  160.      * @return SectionParagraph
  161.      */
  162.     public function setCreated($created)
  163.     {
  164.         $this->created = $created;
  165.         return $this;
  166.     }
  167.     /**
  168.      * Get created
  169.      *
  170.      * @return \DateTime 
  171.      */
  172.     public function getCreated()
  173.     {
  174.         return $this->created;
  175.     }
  176.     /**
  177.      * Set updated
  178.      *
  179.      * @param \DateTime $updated
  180.      * @return SectionParagraph
  181.      */
  182.     public function setUpdated($updated)
  183.     {
  184.         $this->updated = $updated;
  185.         return $this;
  186.     }
  187.     /**
  188.      * Get updated
  189.      *
  190.      * @return \DateTime 
  191.      */
  192.     public function getUpdated()
  193.     {
  194.         return $this->updated;
  195.     }
  196.     /**
  197.      * Set position
  198.      *
  199.      * @param integer $position
  200.      * @return SectionParagraph
  201.      */
  202.     public function setPosition($position)
  203.     {
  204.         $this->position = $position;
  205.         return $this;
  206.     }
  207.     /**
  208.      * Get position
  209.      *
  210.      * @return integer 
  211.      */
  212.     public function getPosition()
  213.     {
  214.         return $this->position;
  215.     }
  216.     /**
  217.      * Set type
  218.      *
  219.      * @param integer $type
  220.      * @return SectionParagraph
  221.      */
  222.     public function setType($type)
  223.     {
  224.         $this->type = $type;
  225.         return $this;
  226.     }
  227.     /**
  228.      * Get type
  229.      *
  230.      * @return integer
  231.      */
  232.     public function getType()
  233.     {
  234.         return $this->type;
  235.     }
  236.     /**
  237.      * Set accordion status
  238.      *
  239.      * @param integer $accordionStatus
  240.      * @return SectionParagraph
  241.      */
  242.     public function setAccordionStatus($accordionStatus)
  243.     {
  244.         $this->accordionStatus = $accordionStatus;
  245.         return $this;
  246.     }
  247.     /**
  248.      * Get accordion status
  249.      *
  250.      * @return integer
  251.      */
  252.     public function getAccordionStatus()
  253.     {
  254.         return $this->accordionStatus;
  255.     }
  256.     /**
  257.      * Set title
  258.      *
  259.      * @param string $title
  260.      * @return SectionParagraph
  261.      */
  262.     public function setTitle($title)
  263.     {
  264.         $this->title = $title;
  265.         return $this;
  266.     }
  267.     /**
  268.      * Get title
  269.      *
  270.      * @return string 
  271.      */
  272.     public function getTitle()
  273.     {
  274.         return  $this->title;
  275.     }
  276.     /**
  277.      * Set subtitle
  278.      *
  279.      * @param string $subtitle
  280.      * @return SectionParagraph
  281.      */
  282.     public function setSubtitle($subtitle)
  283.     {
  284.         $this->subtitle = $subtitle;
  285.         return $this;
  286.     }
  287.     /**
  288.      * Get subtitle
  289.      *
  290.      * @return string 
  291.      */
  292.     public function getSubtitle()
  293.     {
  294.         return $this->subtitle;
  295.     }
  296.     /**
  297.      * Set description
  298.      *
  299.      * @param string $description
  300.      * @return SectionParagraph
  301.      */
  302.     public function setDescription($description)
  303.     {
  304.         $this->description = $description;
  305.         return $this;
  306.     }
  307.     /**
  308.      * Get description
  309.      *
  310.      * @return string 
  311.      */
  312.     public function getDescription()
  313.     {
  314.         return $this->description;
  315.     }
  316.     /**
  317.      * Set publicationDate
  318.      *
  319.      * @param \DateTime $publicationDate
  320.      * @return SectionParagraph
  321.      */
  322.     public function setPublicationDate($publicationDate)
  323.     {
  324.         $this->publicationDate = $publicationDate;
  325.         return $this;
  326.     }
  327.     /**
  328.      * Get publicationDate
  329.      *
  330.      * @return \DateTime 
  331.      */
  332.     public function getPublicationDate()
  333.     {
  334.         return $this->publicationDate;
  335.     }
  336.     /**
  337.      * Set user
  338.      *
  339.      * @param \Notaris\AdminBundle\Entity\User $user
  340.      * @return SectionParagraph
  341.      */
  342.     public function setUser(\Notaris\AdminBundle\Entity\User $user = null)
  343.     {
  344.         $this->user = $user;
  345.         return $this;
  346.     }
  347.     /**
  348.      * Get user
  349.      *
  350.      * @return \Notaris\AdminBundle\Entity\User 
  351.      */
  352.     public function getUser()
  353.     {
  354.         return $this->user;
  355.     }
  356.     /**
  357.      * Set section
  358.      *
  359.      * @param \Notaris\AdminBundle\Entity\Section $section
  360.      * @return SectionParagraph
  361.      */
  362.     public function setSection(\Notaris\AdminBundle\Entity\Section $section = null)
  363.     {
  364.         $this->section = $section;
  365.         return $this;
  366.     }
  367.     /**
  368.      * Get section
  369.      *
  370.      * @return \Notaris\AdminBundle\Entity\Section 
  371.      */
  372.     public function getSection()
  373.     {
  374.         return $this->section;
  375.     }
  376.     /**
  377.      * Set isActive
  378.      *
  379.      * @param boolean $isActive
  380.      * @return SectionParagraph
  381.      */
  382.     public function setIsActive($isActive)
  383.     {
  384.         $this->isActive = $isActive;
  385.         return $this;
  386.     }
  387.     /**
  388.      * Get isActive
  389.      *
  390.      * @return boolean 
  391.      */
  392.     public function getIsActive()
  393.     {
  394.         return $this->isActive;
  395.     }
  396.   
  397.     /**
  398.      * Set asset
  399.      *
  400.      * @param \Notaris\AdminBundle\Entity\Asset $asset
  401.      * @return SectionParagraph
  402.      */
  403.     public function setAsset(\Notaris\AdminBundle\Entity\Asset $asset = null)
  404.     {
  405.         $this->asset = $asset;
  406.         return $this;
  407.     }
  408.     /**
  409.      * Get asset
  410.      *
  411.      * @return \Notaris\AdminBundle\Entity\Asset 
  412.      */
  413.     public function getAsset()
  414.     {
  415.         return $this->asset;
  416.     }
  417.     /**
  418.      * Set locale
  419.      *
  420.      * @param string $locale
  421.      * @return SectionParagraph
  422.      */
  423.     public function setLocale($locale)
  424.     {
  425.         $this->locale = $locale;
  426.         return $this;
  427.     }
  428.     /**
  429.      * Get locale
  430.      *
  431.      * @return string 
  432.      */
  433.     public function getLocale()
  434.     {
  435.         return $this->locale;
  436.     }
  437. //    /**
  438. //     * Set video
  439. //     *
  440. //     * @param \Notaris\AdminBundle\Entity\Video $video
  441. //     * @return SectionParagraph
  442. //     */
  443. //    public function setVideo(\Notaris\AdminBundle\Entity\Video $video = null)
  444. //    {
  445. //        $this->video = $video;
  446. //
  447. //        return $this;
  448. //    }
  449. //
  450. //    /**
  451. //     * Get video
  452. //     *
  453. //     * @return \Notaris\AdminBundle\Entity\Video
  454. //     */
  455. //    public function getVideo()
  456. //    {
  457. //        return $this->video;
  458. //    }
  459. //    /**
  460. //     * Set isYoutube
  461. //     *
  462. //     * @param boolean $isYoutube
  463. //     * @return SectionParagraph
  464. //     */
  465. //    public function setIsYoutube($isYoutube)
  466. //    {
  467. //        $this->isYoutube = $isYoutube;
  468. //
  469. //        return $this;
  470. //    }
  471. //
  472. //    /**
  473. //     * Get isYoutube
  474. //     *
  475. //     * @return boolean
  476. //     */
  477. //    public function getIsYoutube()
  478. //    {
  479. //        return $this->isYoutube;
  480. //    }
  481. }