src/Notaris/AdminBundle/Entity/SectionModule.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="SectionModuleRepository")
  14.  * @ORM\Table(name="section_module")
  15.  */
  16. class SectionModule {
  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\Module")
  27.      * @ORM\JoinColumn(name="module_id", referencedColumnName="id", onDelete="CASCADE")
  28.      */
  29.     private $module;
  30.     /**
  31.      * @var string
  32.      *
  33.      * @ORM\Column(name="title", type="text", nullable = true)
  34.      */
  35.     private $title;
  36.     /**
  37.      * @ORM\Column(type="text", name="text", nullable = true)
  38.      */
  39.     private $text;
  40.     /**
  41.      * @ORM\OneToOne(targetEntity="Asset")
  42.      * @ORM\JoinColumn(name="asset_id", referencedColumnName="id")
  43.      */
  44.     protected $asset;
  45.     /**
  46.      * @ORM\Column(type="boolean", name="is_active")
  47.      * @Assert\Type("boolean")
  48.      */
  49.     private $isActive;
  50.     /**
  51.      * @Gedmo\Timestampable(on="create")
  52.      * @ORM\Column(name="created", type="datetime")
  53.      */
  54.     private $created;
  55.     /**
  56.      * @ORM\Column(name="updated", type="datetime")
  57.      * @Gedmo\Timestampable(on="update")
  58.      */
  59.     private $updated;
  60.     /**
  61.      * @ORM\Column(name="pub_date", type="datetime")
  62.      */
  63.     private $publicationDate;
  64.     /**
  65.      * @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\User")
  66.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="SET NULL")
  67.      */
  68.     private $user;
  69.     /**
  70.      * @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\Section", inversedBy="modules")
  71.      * @ORM\JoinColumn(name="section_id", referencedColumnName="id", onDelete="CASCADE")
  72.      */
  73.     private $section;
  74.     /**
  75.      * @var integer
  76.      *
  77.      * @ORM\Column(type="integer")
  78.      */
  79.     private $position = 0;
  80.     /**
  81.      * @Gedmo\Slug(fields={"title"})
  82.      * @ORM\Column(length=128, unique=true)
  83.      */
  84.     private $slug;
  85.     /**
  86.      * @var string
  87.      *
  88.      * @ORM\Column(name="locale", type="string", length=5)
  89.      */
  90.     private $locale;
  91.     
  92.     /**
  93.      * @return string
  94.      */
  95.     public function getRenderStatus()
  96.     {
  97.         if ($this->getIsActive()) {
  98.             $now = new \DateTime('now');
  99.             $date = $this->getPublicationDate();
  100.             if ($date <= $now) {
  101.                 return '<span class="label label-success">ON</span>';
  102.             }
  103.             return '<span class="label label-warning">...</span>';
  104.         }
  105.         return '<span class="label label-danger">OFF</span>';
  106.     }
  107.     /**
  108.      * Get id
  109.      *
  110.      * @return integer 
  111.      */
  112.     public function getId()
  113.     {
  114.         return $this->id;
  115.     }
  116.     /**
  117.      * Set title
  118.      *
  119.      * @param string $title
  120.      * @return SectionModule
  121.      */
  122.     public function setTitle($title)
  123.     {
  124.         $this->title = $title;
  125.         return $this;
  126.     }
  127.     /**
  128.      * Get title
  129.      *
  130.      * @return string 
  131.      */
  132.     public function getTitle()
  133.     {
  134.         return $this->title;
  135.     }
  136.     /**
  137.      * Set text
  138.      *
  139.      * @param string $text
  140.      * @return SectionModule
  141.      */
  142.     public function setText($text)
  143.     {
  144.         $this->text = $text;
  145.         return $this;
  146.     }
  147.     /**
  148.      * Get text
  149.      *
  150.      * @return string 
  151.      */
  152.     public function getText()
  153.     {
  154.         return $this->text;
  155.     }
  156.     
  157.     /**
  158.      * Get text's first line
  159.      *
  160.      * @return string 
  161.      */
  162.     public function getTextFirstLine()
  163.     {
  164.         return html_entity_decode(strip_tags(mb_substr($this->text , 0, mb_strpos($this->text, '</p>'))));
  165.     }
  166.     /**
  167.      * Set created
  168.      *
  169.      * @param \DateTime $created
  170.      * @return SectionModule
  171.      */
  172.     public function setCreated($created)
  173.     {
  174.         $this->created = $created;
  175.         return $this;
  176.     }
  177.     /**
  178.      * Get created
  179.      *
  180.      * @return \DateTime 
  181.      */
  182.     public function getCreated()
  183.     {
  184.         return $this->created;
  185.     }
  186.     /**
  187.      * Set updated
  188.      *
  189.      * @param \DateTime $updated
  190.      * @return SectionModule
  191.      */
  192.     public function setUpdated($updated)
  193.     {
  194.         $this->updated = $updated;
  195.         return $this;
  196.     }
  197.     /**
  198.      * Get updated
  199.      *
  200.      * @return \DateTime 
  201.      */
  202.     public function getUpdated()
  203.     {
  204.         return $this->updated;
  205.     }
  206.     /**
  207.      * Set publicationDate
  208.      *
  209.      * @param \DateTime $publicationDate
  210.      * @return SectionModule
  211.      */
  212.     public function setPublicationDate($publicationDate)
  213.     {
  214.         $this->publicationDate = $publicationDate;
  215.         return $this;
  216.     }
  217.     /**
  218.      * Get publicationDate
  219.      *
  220.      * @return \DateTime 
  221.      */
  222.     public function getPublicationDate()
  223.     {
  224.         return $this->publicationDate;
  225.     }
  226.     /**
  227.      * Set position
  228.      *
  229.      * @param integer $position
  230.      * @return SectionModule
  231.      */
  232.     public function setPosition($position)
  233.     {
  234.         $this->position = $position;
  235.         return $this;
  236.     }
  237.     /**
  238.      * Get position
  239.      *
  240.      * @return integer 
  241.      */
  242.     public function getPosition()
  243.     {
  244.         return $this->position;
  245.     }
  246.     /**
  247.      * Set module
  248.      *
  249.      * @param \Notaris\AdminBundle\Entity\Module $module
  250.      * @return SectionModule
  251.      */
  252.     public function setModule(\Notaris\AdminBundle\Entity\Module $module = null)
  253.     {
  254.         $this->module = $module;
  255.         return $this;
  256.     }
  257.     /**
  258.      * Get module
  259.      *
  260.      * @return \Notaris\AdminBundle\Entity\Module 
  261.      */
  262.     public function getModule()
  263.     {
  264.         return $this->module;
  265.     }
  266.     /**
  267.      * Set user
  268.      *
  269.      * @param \Notaris\AdminBundle\Entity\User $user
  270.      * @return SectionModule
  271.      */
  272.     public function setUser(\Notaris\AdminBundle\Entity\User $user = null)
  273.     {
  274.         $this->user = $user;
  275.         return $this;
  276.     }
  277.     /**
  278.      * Get user
  279.      *
  280.      * @return \Notaris\AdminBundle\Entity\User 
  281.      */
  282.     public function getUser()
  283.     {
  284.         return $this->user;
  285.     }
  286.     /**
  287.      * Set section
  288.      *
  289.      * @param \Notaris\AdminBundle\Entity\Section $section
  290.      * @return SectionModule
  291.      */
  292.     public function setSection(\Notaris\AdminBundle\Entity\Section $section = null)
  293.     {
  294.         $this->section = $section;
  295.         return $this;
  296.     }
  297.     /**
  298.      * Get section
  299.      *
  300.      * @return \Notaris\AdminBundle\Entity\Section 
  301.      */
  302.     public function getSection()
  303.     {
  304.         return $this->section;
  305.     }
  306.     /**
  307.      * Set isActive
  308.      *
  309.      * @param boolean $isActive
  310.      * @return SectionModule
  311.      */
  312.     public function setIsActive($isActive)
  313.     {
  314.         $this->isActive = $isActive;
  315.         return $this;
  316.     }
  317.     /**
  318.      * Get isActive
  319.      *
  320.      * @return boolean 
  321.      */
  322.     public function getIsActive()
  323.     {
  324.         return $this->isActive;
  325.     }
  326.     /**
  327.      * Constructor
  328.      */
  329.     public function __construct()
  330.     {
  331.     }
  332.    
  333.     /**
  334.      * Set asset
  335.      *
  336.      * @param \Notaris\AdminBundle\Entity\Asset $asset
  337.      * @return SectionModule
  338.      */
  339.     public function setAsset(\Notaris\AdminBundle\Entity\Asset $asset = null)
  340.     {
  341.         $this->asset = $asset;
  342.         return $this;
  343.     }
  344.     /**
  345.      * Get asset
  346.      *
  347.      * @return \Notaris\AdminBundle\Entity\Asset 
  348.      */
  349.     public function getAsset()
  350.     {
  351.         return $this->asset;
  352.     }
  353.     /**
  354.      * Set slug
  355.      *
  356.      * @param string $slug
  357.      * @return SectionModule
  358.      */
  359.     public function setSlug($slug)
  360.     {
  361.         $this->slug = $slug;
  362.         return $this;
  363.     }
  364.     /**
  365.      * Get slug
  366.      *
  367.      * @return string 
  368.      */
  369.     public function getSlug()
  370.     {
  371.         return $this->slug;
  372.     }
  373.     /**
  374.      * Set locale
  375.      *
  376.      * @param string $locale
  377.      * @return SectionModule
  378.      */
  379.     public function setLocale($locale)
  380.     {
  381.         $this->locale = $locale;
  382.         return $this;
  383.     }
  384.     /**
  385.      * Get locale
  386.      *
  387.      * @return string 
  388.      */
  389.     public function getLocale()
  390.     {
  391.         return $this->locale;
  392.     }
  393. }