src/Notaris/AdminBundle/Entity/Section.php line 20

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. use Doctrine\Common\Collections\ArrayCollection;
  13. /**
  14.  * @ORM\Entity(repositoryClass="SectionRepository")
  15.  * @ORM\Table(name="section")
  16.  */
  17. class Section {
  18.     /**
  19.      * @var integer
  20.      *
  21.      * @ORM\Column(name="id", type="integer")
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @Gedmo\Timestampable(on="create")
  28.      * @ORM\Column(name="created", type="datetime")
  29.      */
  30.     private $created;
  31.     /**
  32.      * @ORM\Column(name="updated", type="datetime")
  33.      * @Gedmo\Timestampable(on="update")
  34.      */
  35.     private $updated;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\User")
  38.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="SET NULL")
  39.      */
  40.     private $user;
  41.     /**
  42.      * @var string
  43.      *
  44.      * @ORM\Column(name="navigation", type="string", length=255)
  45.      */
  46.     private $navigation;
  47.     /**
  48.      * @Gedmo\Slug(fields={"navigation"})
  49.      * @ORM\Column(length=128, unique=true)
  50.      */
  51.     private $slug;
  52.     /**
  53.      * @ORM\Column(type="boolean", name="is_active")
  54.      * @Assert\Type("boolean")
  55.      */
  56.     private $isActive;
  57.     /**
  58.      * @ORM\Column(name="pub_date", type="datetime", nullable=true)
  59.      */
  60.     private $publicationDate;
  61.     /**
  62.      * @ORM\Column(type="boolean", name="show_navigation", nullable=true)
  63.      * @Assert\Type("boolean")
  64.      */
  65.     private $show_navigation;
  66.     /**
  67.      * @var string
  68.      *
  69.      * @ORM\Column(name="title", type="string", length=255, nullable=true)
  70.      */
  71.     private $title;
  72.     /**
  73.      * @ORM\Column(type="text", name="description", nullable=true)
  74.      */
  75.     private $description;
  76.     /**
  77.      * @ORM\OneToOne(targetEntity="Asset")
  78.      * @ORM\JoinColumn(name="asset_id", referencedColumnName="id")
  79.      */
  80.     protected $asset;
  81.     /**
  82.      * @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\Subsite", inversedBy="sections")
  83.      * @ORM\JoinColumn(name="subsite_id", referencedColumnName="id", onDelete="CASCADE")
  84.      */
  85.     private $subsite;
  86.     
  87.     /**
  88.      * @ORM\OneToMany(targetEntity="Section", mappedBy="parent")
  89.      * @ORM\OrderBy({"position" = "ASC"})
  90.      */
  91.     private $children;
  92.     /**
  93.      * @ORM\ManyToOne(targetEntity="Section", inversedBy="children")
  94.      * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
  95.      */
  96.     private $parent;
  97.     /**
  98.      * @var integer
  99.      *
  100.      * @ORM\Column(type="integer")
  101.      */
  102.     private $position = 0;
  103.     /**
  104.      * @ORM\OneToMany(targetEntity="SectionParagraph", mappedBy="section")
  105.      * @ORM\OrderBy({"position" = "asc"})
  106.      */
  107.     protected $paragraphs;
  108.     /**
  109.      * @ORM\OneToMany(targetEntity="SectionModule", mappedBy="section")
  110.      * @ORM\OrderBy({"position" = "asc"})
  111.      */
  112.     protected $modules;
  113.     /**
  114.      * @ORM\OneToOne(targetEntity="Meta")
  115.      * @ORM\JoinColumn(name="meta_id", referencedColumnName="id")
  116.      */
  117.     protected $meta;
  118.     /**
  119.      * @ORM\ManyToMany(targetEntity="Tag", inversedBy="sections")
  120.      * @ORM\JoinTable(name="tag_section")
  121.      */
  122.     protected $tags;
  123.     /**
  124.      * @ORM\Column(type="boolean", name="not_delete", nullable=true)
  125.      * @Assert\Type("boolean")
  126.      */
  127.     protected $notDeleted;
  128.     /**
  129.      * @ORM\Column(type="text", name="redirect_url", nullable=true)
  130.      */
  131.     protected $redirectUrl;
  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 instanceof \DateTime)){
  141.                 $date = new \DateTime($date);
  142.             }
  143.             if ($date <= $now) {
  144.                 return '<span class="label label-success">ON</span>';
  145.             }
  146.             return '<span class="label label-warning">...</span>';
  147.         }
  148.         return '<span class="label label-danger">OFF</span>';
  149.     }
  150.     /**
  151.      * @return string
  152.      */
  153.     public function getNavigationCaption()
  154.     {
  155.         return $this->getNavigation();
  156.     }
  157.     /**
  158.      * @return string
  159.      */
  160.     public function getCount()
  161.     {
  162.         return 0;
  163.     }
  164.     /**
  165.      * Get id
  166.      *
  167.      * @return integer 
  168.      */
  169.     public function getId()
  170.     {
  171.         return $this->id;
  172.     }
  173.     /**
  174.      * Set created
  175.      *
  176.      * @param \DateTime $created
  177.      * @return Section
  178.      */
  179.     public function setCreated($created)
  180.     {
  181.         $this->created = $created;
  182.         return $this;
  183.     }
  184.     /**
  185.      * Get created
  186.      *
  187.      * @return \DateTime 
  188.      */
  189.     public function getCreated()
  190.     {
  191.         return $this->created;
  192.     }
  193.     /**
  194.      * Set updated
  195.      *
  196.      * @param \DateTime $updated
  197.      * @return Section
  198.      */
  199.     public function setUpdated($updated)
  200.     {
  201.         $this->updated = $updated;
  202.         return $this;
  203.     }
  204.     /**
  205.      * Get updated
  206.      *
  207.      * @return \DateTime 
  208.      */
  209.     public function getUpdated()
  210.     {
  211.         return $this->updated;
  212.     }
  213.     /**
  214.      * Set navigation
  215.      *
  216.      * @param string $navigation
  217.      * @return Section
  218.      */
  219.     public function setNavigation($navigation)
  220.     {
  221.         $this->navigation = $navigation;
  222.         return $this;
  223.     }
  224.     /**
  225.      * Get navigation
  226.      *
  227.      * @return string 
  228.      */
  229.     public function getNavigation()
  230.     {
  231.         return $this->navigation;
  232.     }
  233.     /**
  234.      * Set slug
  235.      *
  236.      * @param string $slug
  237.      * @return Section
  238.      */
  239.     public function setSlug($slug)
  240.     {
  241.         $this->slug = $slug;
  242.         return $this;
  243.     }
  244.     /**
  245.      * Get slug
  246.      *
  247.      * @return string 
  248.      */
  249.     public function getSlug()
  250.     {
  251.         return $this->slug;
  252.     }
  253.    
  254.     /**
  255.      * Set publicationDate
  256.      *
  257.      * @param \DateTime $publicationDate
  258.      * @return Section
  259.      */
  260.     public function setPublicationDate($publicationDate)
  261.     {
  262.         $this->publicationDate = $publicationDate;
  263.         return $this;
  264.     }
  265.     /**
  266.      * Get publicationDate
  267.      *
  268.      * @return \DateTime 
  269.      */
  270.     public function getPublicationDate()
  271.     {
  272.         return $this->publicationDate;
  273.     }
  274.     /**
  275.      * Set show_navigation
  276.      *
  277.      * @param boolean $showNavigation
  278.      * @return Section
  279.      */
  280.     public function setShowNavigation($showNavigation)
  281.     {
  282.         $this->show_navigation = $showNavigation;
  283.         return $this;
  284.     }
  285.     /**
  286.      * Get show_navigation
  287.      *
  288.      * @return boolean 
  289.      */
  290.     public function getShowNavigation()
  291.     {
  292.         return $this->show_navigation;
  293.     }
  294.     /**
  295.      * Set title
  296.      *
  297.      * @param string $title
  298.      * @return Section
  299.      */
  300.     public function setTitle($title)
  301.     {
  302.         $this->title = $title;
  303.         return $this;
  304.     }
  305.     /**
  306.      * Get title
  307.      *
  308.      * @return string 
  309.      */
  310.     public function getTitle()
  311.     {
  312.         return $this->title;
  313.     }
  314.     /**
  315.      * Set description
  316.      *
  317.      * @param string $description
  318.      * @return Section
  319.      */
  320.     public function setDescription($description)
  321.     {
  322.         $this->description = $description;
  323.         return $this;
  324.     }
  325.     /**
  326.      * Get description
  327.      *
  328.      * @return string 
  329.      */
  330.     public function getDescription()
  331.     {
  332.         return $this->description;
  333.     }
  334.     /**
  335.      * Set position
  336.      *
  337.      * @param integer $position
  338.      * @return Section
  339.      */
  340.     public function setPosition($position)
  341.     {
  342.         $this->position = $position;
  343.         return $this;
  344.     }
  345.     /**
  346.      * Get position
  347.      *
  348.      * @return integer 
  349.      */
  350.     public function getPosition()
  351.     {
  352.         return $this->position;
  353.     }
  354.     /**
  355.      * Set user
  356.      *
  357.      * @param \Notaris\AdminBundle\Entity\User $user
  358.      * @return Section
  359.      */
  360.     public function setUser(\Notaris\AdminBundle\Entity\User $user = null)
  361.     {
  362.         $this->user = $user;
  363.         return $this;
  364.     }
  365.     /**
  366.      * Get user
  367.      *
  368.      * @return \Notaris\AdminBundle\Entity\User 
  369.      */
  370.     public function getUser()
  371.     {
  372.         return $this->user;
  373.     }
  374.     /**
  375.      * Set parent
  376.      *
  377.      * @param \Notaris\AdminBundle\Entity\Section $parent
  378.      * @return Section
  379.      */
  380.     public function setParent(\Notaris\AdminBundle\Entity\Section $parent = null)
  381.     {
  382.         $this->parent = $parent;
  383.         return $this;
  384.     }
  385.     /**
  386.      * Get parent
  387.      *
  388.      * @return \Notaris\AdminBundle\Entity\Section 
  389.      */
  390.     public function getParent()
  391.     {
  392.         return $this->parent;
  393.     }
  394.     /**
  395.      * Constructor
  396.      */
  397.     public function __construct()
  398.     {
  399.         $this->paragraphs = new ArrayCollection();
  400.         $this->modules = new ArrayCollection();
  401.         $this->children = new ArrayCollection();
  402.     }
  403.     /**
  404.      * Add paragraphs
  405.      *
  406.      * @param \Notaris\AdminBundle\Entity\SectionParagraph $paragraphs
  407.      * @return Section
  408.      */
  409.     public function addParagraph(\Notaris\AdminBundle\Entity\SectionParagraph $paragraphs)
  410.     {
  411.         $this->paragraphs[] = $paragraphs;
  412.         return $this;
  413.     }
  414.     /**
  415.      * Remove paragraphs
  416.      *
  417.      * @param \Notaris\AdminBundle\Entity\SectionParagraph $paragraphs
  418.      */
  419.     public function removeParagraph(\Notaris\AdminBundle\Entity\SectionParagraph $paragraphs)
  420.     {
  421.         $this->paragraphs->removeElement($paragraphs);
  422.     }
  423.     /**
  424.      * Get paragraphs
  425.      *
  426.      * @return \Doctrine\Common\Collections\Collection 
  427.      */
  428.     public function getParagraphs()
  429.     {
  430.         return $this->paragraphs;
  431.     }
  432.     /**
  433.      * Add modules
  434.      *
  435.      * @param \Notaris\AdminBundle\Entity\SectionModule $modules
  436.      * @return Section
  437.      */
  438.     public function addModule(\Notaris\AdminBundle\Entity\SectionModule $modules)
  439.     {
  440.         $this->modules[] = $modules;
  441.         return $this;
  442.     }
  443.     /**
  444.      * Remove modules
  445.      *
  446.      * @param \Notaris\AdminBundle\Entity\SectionModule $modules
  447.      */
  448.     public function removeModule(\Notaris\AdminBundle\Entity\SectionModule $modules)
  449.     {
  450.         $this->modules->removeElement($modules);
  451.     }
  452.     /**
  453.      * Get modules
  454.      *
  455.      * @return \Doctrine\Common\Collections\Collection 
  456.      */
  457.     public function getModules()
  458.     {
  459.         return $this->modules;
  460.     }
  461.     /**
  462.      * Add tags
  463.      *
  464.      * @param \Notaris\AdminBundle\Entity\Tag $tags
  465.      * @return Section
  466.      */
  467.     public function addTag(\Notaris\AdminBundle\Entity\Tag $tags)
  468.     {
  469.         $this->tags[] = $tags;
  470.         return $this;
  471.     }
  472.     /**
  473.      * Remove tags
  474.      *
  475.      * @param \Notaris\AdminBundle\Entity\Tag $tags
  476.      */
  477.     public function removeTag(\Notaris\AdminBundle\Entity\Tag $tags)
  478.     {
  479.         $this->tags->removeElement($tags);
  480.     }
  481.     /**
  482.      * Get tags
  483.      *
  484.      * @return \Doctrine\Common\Collections\Collection 
  485.      */
  486.     public function getTags()
  487.     {
  488.         return $this->tags;
  489.     }
  490.     /**
  491.      * Set meta
  492.      *
  493.      * @param \Notaris\AdminBundle\Entity\Meta $meta
  494.      * @return Section
  495.      */
  496.     public function setMeta(\Notaris\AdminBundle\Entity\Meta $meta = null)
  497.     {
  498.         $this->meta = $meta;
  499.         return $this;
  500.     }
  501.     /**
  502.      * Get meta
  503.      *
  504.      * @return \Notaris\AdminBundle\Entity\Meta 
  505.      */
  506.     public function getMeta()
  507.     {
  508.         return $this->meta;
  509.     }
  510.     /**
  511.      * Set isActive
  512.      *
  513.      * @param boolean $isActive
  514.      * @return Section
  515.      */
  516.     public function setIsActive($isActive)
  517.     {
  518.         $this->isActive = $isActive;
  519.         return $this;
  520.     }
  521.     /**
  522.      * Get isActive
  523.      *
  524.      * @return boolean 
  525.      */
  526.     public function getIsActive()
  527.     {
  528.         return $this->isActive;
  529.     }
  530.     /**
  531.      * Set asset
  532.      *
  533.      * @param \Notaris\AdminBundle\Entity\Asset $asset
  534.      * @return Section
  535.      */
  536.     public function setAsset(\Notaris\AdminBundle\Entity\Asset $asset = null)
  537.     {
  538.         $this->asset = $asset;
  539.         return $this;
  540.     }
  541.     /**
  542.      * Get asset
  543.      *
  544.      * @return \Notaris\AdminBundle\Entity\Asset 
  545.      */
  546.     public function getAsset()
  547.     {
  548.         return $this->asset;
  549.     }
  550.     /**
  551.      * Set subsite
  552.      *
  553.      * @param \Notaris\AdminBundle\Entity\Subsite $subsite
  554.      * @return Section
  555.      */
  556.     public function setSubsite(\Notaris\AdminBundle\Entity\Subsite $subsite = null)
  557.     {
  558.         $this->subsite = $subsite;
  559.         return $this;
  560.     }
  561.     /**
  562.      * Get subsite
  563.      *
  564.      * @return \Notaris\AdminBundle\Entity\Subsite 
  565.      */
  566.     public function getSubsite()
  567.     {
  568.         return $this->subsite;
  569.     }
  570.     /**
  571.      * Add children
  572.      *
  573.      * @param \Notaris\AdminBundle\Entity\Section $children
  574.      * @return Section
  575.      */
  576.     public function addChild(\Notaris\AdminBundle\Entity\Section $children)
  577.     {
  578.         $this->children[] = $children;
  579.         return $this;
  580.     }
  581.     /**
  582.      * Remove children
  583.      *
  584.      * @param \Notaris\AdminBundle\Entity\Section $children
  585.      */
  586.     public function removeChild(\Notaris\AdminBundle\Entity\Section $children)
  587.     {
  588.         $this->children->removeElement($children);
  589.     }
  590.     /**
  591.      * Get children
  592.      *
  593.      * @return \Doctrine\Common\Collections\Collection 
  594.      */
  595.     public function getChildren()
  596.     {
  597.         return $this->children;
  598.     }
  599.     /**
  600.      * Set notDeleted
  601.      *
  602.      * @param boolean $notDeleted
  603.      * @return Section
  604.      */
  605.     public function setNotDeleted($notDeleted)
  606.     {
  607.         $this->notDeleted = $notDeleted;
  608.         return $this;
  609.     }
  610.     /**
  611.      * Get notDeleted
  612.      *
  613.      * @return boolean 
  614.      */
  615.     public function getNotDeleted()
  616.     {
  617.         return $this->notDeleted;
  618.     }
  619.     /**
  620.      * Set redirectUrl
  621.      *
  622.      * @param string $redirectUrl
  623.      *
  624.      * @return Section
  625.      */
  626.     public function setRedirectUrl($redirectUrl)
  627.     {
  628.         $this->redirectUrl = $redirectUrl;
  629.         return $this;
  630.     }
  631.     /**
  632.      * Get redirectUrl
  633.      *
  634.      * @return string
  635.      */
  636.     public function getRedirectUrl()
  637.     {
  638.         return $this->redirectUrl;
  639.     }
  640. }