src/Notaris/AdminBundle/Entity/Brochure.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 Notaris\AdminBundle\ValueObject\BrochureType;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * @ORM\Entity(repositoryClass="BrochureRepository")
  15.  * @ORM\Table(name="brochure")
  16.  */
  17. class Brochure {
  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.      * @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\User")
  28.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="SET NULL")
  29.      */
  30.     private $user;
  31.     /**
  32.      * @Gedmo\Timestampable(on="create")
  33.      * @ORM\Column(name="created", type="datetime")
  34.      */
  35.     private $created;
  36.     /**
  37.      * @ORM\Column(name="updated", type="datetime")
  38.      * @Gedmo\Timestampable(on="update")
  39.      */
  40.     private $updated;
  41.     /**
  42.      * @var string
  43.      *
  44.      * @ORM\Column(name="locale", type="string", length=5)
  45.      */
  46.     private $locale;
  47.     /**
  48.      * @var string
  49.      *
  50.      * @ORM\Column(name="title", type="string", length=255)
  51.      */
  52.     private $title;
  53.     /**
  54.      * @ORM\Column(type="text", name="description")
  55.      */
  56.     private $description;
  57.     /**
  58.      * @ORM\OneToOne(targetEntity="Asset", cascade={"remove"})
  59.      * @ORM\JoinColumn(name="asset_id", referencedColumnName="id")
  60.      */
  61.     protected $asset;
  62.     /**
  63.      * @var integer
  64.      *
  65.      * @ORM\Column(type="integer", name="pages", nullable=true)
  66.      */
  67.     private $pages;
  68.     /**
  69.      * @ORM\Column(name="edition", type="date", nullable=true)
  70.      */
  71.     private $edition;
  72.     /**
  73.      * @var integer
  74.      *
  75.      * @ORM\Column(type="integer", name="count_clicked")
  76.      */
  77.     private $countClicked = 0;
  78.     /**
  79.      * @var string
  80.      *
  81.      * @ORM\Column(name="publisher", type="string", length=255)
  82.      */
  83.     private $publisher;
  84.     /**
  85.      * @ORM\Column(type="boolean", name="is_active")
  86.      * @Assert\Type("boolean")
  87.      */
  88.     private $isActive;
  89.     /**
  90.      * @ORM\Column(name="pub_date", type="datetime")
  91.      */
  92.     private $publicationDate;
  93.     /**
  94.      * @ORM\Column(type="boolean", name="is_general")
  95.      * @Assert\Type("boolean")
  96.      */
  97.     private $isGeneral;
  98.     /**
  99.      * @var integer
  100.      *
  101.      * @ORM\Column(type="integer", name="general_position", nullable=true)
  102.      */
  103.     private $generalPosition;
  104.     /**
  105.      * @ORM\Column(type="boolean", name="is_general_primary")
  106.      * @Assert\Type("boolean")
  107.      */
  108.     private $isGeneralPrimary;
  109.     /**
  110.      * @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\Subsite")
  111.      * @ORM\JoinColumn(name="primary_subsite", referencedColumnName="id", onDelete="SET NULL")
  112.      */
  113.     private $primarySubsite;
  114.     /**
  115.      * @ORM\OneToOne(targetEntity="News", inversedBy="brochure", cascade={"remove"})
  116.      * @ORM\JoinColumn(name="news_id", referencedColumnName="id", onDelete="SET NULL")
  117.      */
  118.     protected $news;
  119.     /**
  120.      * @ORM\ManyToMany(targetEntity="Tag", inversedBy="brochures")
  121.      * @ORM\JoinTable(name="tag_brochure")
  122.      */
  123.     protected $tags;
  124.     /**
  125.      * @ORM\OneToMany(targetEntity="BrochureSubsite", mappedBy="brochure")
  126.      * @ORM\JoinColumn(name="id", referencedColumnName="brochure")
  127.      * @ORM\OrderBy({"position" = "asc"})
  128.      */
  129.     private $subsites;
  130.     /**
  131.      * @ORM\ManyToMany(targetEntity="IzimiCategory")
  132.      * @ORM\JoinTable(name="brochure_izimi_category")
  133.      */
  134.     protected $categories;
  135.     /**
  136.      * @ORM\Column(type="boolean", name="is_izimi")
  137.      * @Assert\Type("boolean")
  138.      */
  139.     private $isIzimi;
  140.     /**
  141.      * @var BrochureType
  142.      *
  143.      * @ORM\Column(type="brochure_type", options={"default": "Brochure"})
  144.      */
  145.     private $brochureType;
  146.     /**
  147.      * Constructor
  148.      */
  149.     public function __construct()
  150.     {
  151.         $this->tags = new \Doctrine\Common\Collections\ArrayCollection();
  152.         $this->brochureType = BrochureType::brochure();
  153.     }
  154.     /**
  155.      * @return string
  156.      */
  157.     public function getRelatedTo()
  158.     {
  159.         if ($this->getSubsites()) {
  160.             $default_general = 'General';
  161.             $count = count($this->getSubsites());
  162.             if (!$count && $this->getIsGeneral()) {
  163.                 return $default_general;
  164.             } elseif ($count >= 1) {
  165.                 if ($this->getPrimarySubsite()) {
  166.                     return $this->getPrimarySubsite();
  167.                 } elseif ($this->getIsGeneralPrimary()) {
  168.                     return $default_general;
  169.                 } else {
  170.                     $subsites = $this->getSubsites();
  171.                     return $subsites[0]->getSubsite();
  172.                 }
  173.             }
  174.         }
  175.         return '';
  176.     }
  177.     /**
  178.      * Get id
  179.      *
  180.      * @return integer
  181.      */
  182.     public function getId()
  183.     {
  184.         return $this->id;
  185.     }
  186.     /**
  187.      * Set created
  188.      *
  189.      * @param \DateTime $created
  190.      * @return Brochure
  191.      */
  192.     public function setCreated($created)
  193.     {
  194.         $this->created = $created;
  195.         return $this;
  196.     }
  197.     /**
  198.      * Get created
  199.      *
  200.      * @return \DateTime
  201.      */
  202.     public function getCreated()
  203.     {
  204.         return $this->created;
  205.     }
  206.     /**
  207.      * Set updated
  208.      *
  209.      * @param \DateTime $updated
  210.      * @return Brochure
  211.      */
  212.     public function setUpdated($updated)
  213.     {
  214.         $this->updated = $updated;
  215.         return $this;
  216.     }
  217.     /**
  218.      * Get updated
  219.      *
  220.      * @return \DateTime
  221.      */
  222.     public function getUpdated()
  223.     {
  224.         return $this->updated;
  225.     }
  226.     /**
  227.      * Set locale
  228.      *
  229.      * @param string $locale
  230.      * @return Brochure
  231.      */
  232.     public function setLocale($locale)
  233.     {
  234.         $this->locale = $locale;
  235.         return $this;
  236.     }
  237.     /**
  238.      * Get locale
  239.      *
  240.      * @return string
  241.      */
  242.     public function getLocale()
  243.     {
  244.         return $this->locale;
  245.     }
  246.     /**
  247.      * Set title
  248.      *
  249.      * @param string $title
  250.      * @return Brochure
  251.      */
  252.     public function setTitle($title)
  253.     {
  254.         $this->title = $title;
  255.         return $this;
  256.     }
  257.     /**
  258.      * Get title
  259.      *
  260.      * @return string
  261.      */
  262.     public function getTitle()
  263.     {
  264.         return $this->title;
  265.     }
  266.     /**
  267.      * Set description
  268.      *
  269.      * @param string $description
  270.      * @return Brochure
  271.      */
  272.     public function setDescription($description)
  273.     {
  274.         $this->description = $description;
  275.         return $this;
  276.     }
  277.     /**
  278.      * Get description
  279.      *
  280.      * @return string
  281.      */
  282.     public function getDescription()
  283.     {
  284.         return $this->description;
  285.     }
  286.     /**
  287.      * Set pages
  288.      *
  289.      * @param integer $pages
  290.      * @return Brochure
  291.      */
  292.     public function setPages($pages)
  293.     {
  294.         $this->pages = $pages;
  295.         return $this;
  296.     }
  297.     /**
  298.      * Get pages
  299.      *
  300.      * @return integer
  301.      */
  302.     public function getPages()
  303.     {
  304.         return $this->pages;
  305.     }
  306.     /**
  307.      * Set edition
  308.      *
  309.      * @param \DateTime $edition
  310.      * @return Brochure
  311.      */
  312.     public function setEdition($edition)
  313.     {
  314.         $this->edition = $edition;
  315.         return $this;
  316.     }
  317.     /**
  318.      * Get edition
  319.      *
  320.      * @return \DateTime
  321.      */
  322.     public function getEdition()
  323.     {
  324.         return $this->edition;
  325.     }
  326.     /**
  327.      * Set publisher
  328.      *
  329.      * @param string $publisher
  330.      * @return Brochure
  331.      */
  332.     public function setPublisher($publisher)
  333.     {
  334.         $this->publisher = $publisher;
  335.         return $this;
  336.     }
  337.     /**
  338.      * Get publisher
  339.      *
  340.      * @return string
  341.      */
  342.     public function getPublisher()
  343.     {
  344.         return $this->publisher;
  345.     }
  346.     /**
  347.      * Set isActive
  348.      *
  349.      * @param boolean $isActive
  350.      * @return Brochure
  351.      */
  352.     public function setIsActive($isActive)
  353.     {
  354.         $this->isActive = $isActive;
  355.         return $this;
  356.     }
  357.     /**
  358.      * Get isActive
  359.      *
  360.      * @return boolean
  361.      */
  362.     public function getIsActive()
  363.     {
  364.         return $this->isActive;
  365.     }
  366.     /**
  367.      * Set publicationDate
  368.      *
  369.      * @param \DateTime $publicationDate
  370.      * @return Brochure
  371.      */
  372.     public function setPublicationDate($publicationDate)
  373.     {
  374.         $this->publicationDate = $publicationDate;
  375.         return $this;
  376.     }
  377.     /**
  378.      * Get publicationDate
  379.      *
  380.      * @return \DateTime
  381.      */
  382.     public function getPublicationDate()
  383.     {
  384.         return $this->publicationDate;
  385.     }
  386.     /**
  387.      * Set isGeneral
  388.      *
  389.      * @param boolean $isGeneral
  390.      * @return Brochure
  391.      */
  392.     public function setIsGeneral($isGeneral)
  393.     {
  394.         $this->isGeneral = $isGeneral;
  395.         return $this;
  396.     }
  397.     /**
  398.      * Get isGeneral
  399.      *
  400.      * @return boolean
  401.      */
  402.     public function getIsGeneral()
  403.     {
  404.         return $this->isGeneral;
  405.     }
  406.     /**
  407.      * Set user
  408.      *
  409.      * @param \Notaris\AdminBundle\Entity\User $user
  410.      * @return Brochure
  411.      */
  412.     public function setUser(\Notaris\AdminBundle\Entity\User $user = null)
  413.     {
  414.         $this->user = $user;
  415.         return $this;
  416.     }
  417.     /**
  418.      * Get user
  419.      *
  420.      * @return \Notaris\AdminBundle\Entity\User
  421.      */
  422.     public function getUser()
  423.     {
  424.         return $this->user;
  425.     }
  426.     /**
  427.      * Set primarySubsite
  428.      *
  429.      * @param \Notaris\AdminBundle\Entity\Subsite $primarySubsite
  430.      * @return Brochure
  431.      */
  432.     public function setPrimarySubsite(\Notaris\AdminBundle\Entity\Subsite $primarySubsite = null)
  433.     {
  434.         $this->primarySubsite = $primarySubsite;
  435.         return $this;
  436.     }
  437.     /**
  438.      * Get primarySubsite
  439.      *
  440.      * @return \Notaris\AdminBundle\Entity\Subsite
  441.      */
  442.     public function getPrimarySubsite()
  443.     {
  444.         return $this->primarySubsite;
  445.     }
  446.     /**
  447.      * Set news
  448.      *
  449.      * @param \Notaris\AdminBundle\Entity\News $news
  450.      * @return Brochure
  451.      */
  452.     public function setNews(\Notaris\AdminBundle\Entity\News $news = null)
  453.     {
  454.         $this->news = $news;
  455.         return $this;
  456.     }
  457.     /**
  458.      * Get news
  459.      *
  460.      * @return \Notaris\AdminBundle\Entity\News
  461.      */
  462.     public function getNews()
  463.     {
  464.         return $this->news;
  465.     }
  466.     /**
  467.      * Add tags
  468.      *
  469.      * @param \Notaris\AdminBundle\Entity\Tag $tags
  470.      * @return Brochure
  471.      */
  472.     public function addTag(\Notaris\AdminBundle\Entity\Tag $tags)
  473.     {
  474.         $this->tags[] = $tags;
  475.         return $this;
  476.     }
  477.     /**
  478.      * Remove tags
  479.      *
  480.      * @param \Notaris\AdminBundle\Entity\Tag $tags
  481.      */
  482.     public function removeTag(\Notaris\AdminBundle\Entity\Tag $tags)
  483.     {
  484.         $this->tags->removeElement($tags);
  485.     }
  486.     /**
  487.      * Get tags
  488.      *
  489.      * @return \Doctrine\Common\Collections\Collection
  490.      */
  491.     public function getTags()
  492.     {
  493.         return $this->tags;
  494.     }
  495.     /**
  496.      * Add subsites
  497.      *
  498.      * @param \Notaris\AdminBundle\Entity\BrochureSubsite $subsites
  499.      * @return Brochure
  500.      */
  501.     public function addSubsite(\Notaris\AdminBundle\Entity\BrochureSubsite $subsites)
  502.     {
  503.         $this->subsites[] = $subsites;
  504.         return $this;
  505.     }
  506.     /**
  507.      * Remove subsites
  508.      *
  509.      * @param \Notaris\AdminBundle\Entity\BrochureSubsite $subsites
  510.      */
  511.     public function removeSubsite(\Notaris\AdminBundle\Entity\BrochureSubsite $subsites)
  512.     {
  513.         $this->subsites->removeElement($subsites);
  514.     }
  515.     /**
  516.      * Get subsites
  517.      *
  518.      * @return \Doctrine\Common\Collections\Collection
  519.      */
  520.     public function getSubsites()
  521.     {
  522.         return $this->subsites;
  523.     }
  524.     /**
  525.      * Set asset
  526.      *
  527.      * @param \Notaris\AdminBundle\Entity\Asset $asset
  528.      * @return Brochure
  529.      */
  530.     public function setAsset(\Notaris\AdminBundle\Entity\Asset $asset = null)
  531.     {
  532.         $this->asset = $asset;
  533.         return $this;
  534.     }
  535.     /**
  536.      * Get asset
  537.      *
  538.      * @return \Notaris\AdminBundle\Entity\Asset
  539.      */
  540.     public function getAsset()
  541.     {
  542.         return $this->asset;
  543.     }
  544.     /**
  545.      * Set isGeneralPrimary
  546.      *
  547.      * @param boolean $isGeneralPrimary
  548.      * @return Brochure
  549.      */
  550.     public function setIsGeneralPrimary($isGeneralPrimary)
  551.     {
  552.         $this->isGeneralPrimary = $isGeneralPrimary;
  553.         return $this;
  554.     }
  555.     /**
  556.      * Get isGeneralPrimary
  557.      *
  558.      * @return boolean
  559.      */
  560.     public function getIsGeneralPrimary()
  561.     {
  562.         return $this->isGeneralPrimary;
  563.     }
  564.     /**
  565.      * Set countClicked
  566.      *
  567.      * @param integer $countClicked
  568.      * @return Brochure
  569.      */
  570.     public function setCountClicked($countClicked)
  571.     {
  572.         $this->countClicked = $countClicked;
  573.         return $this;
  574.     }
  575.     /**
  576.      * Get countClicked
  577.      *
  578.      * @return integer
  579.      */
  580.     public function getCountClicked()
  581.     {
  582.         return $this->countClicked;
  583.     }
  584.     /**
  585.      * Set generalPosition
  586.      *
  587.      * @param integer $generalPosition
  588.      * @return Brochure
  589.      */
  590.     public function setGeneralPosition($generalPosition)
  591.     {
  592.         $this->generalPosition = $generalPosition;
  593.         return $this;
  594.     }
  595.     /**
  596.      * @param BrochureType $brochureType
  597.      */
  598.     public function setBrochureType($brochureType)
  599.     {
  600.         $this->brochureType = $brochureType;
  601.     }
  602.     /**
  603.      * Get generalPosition
  604.      *
  605.      * @return integer
  606.      */
  607.     public function getGeneralPosition()
  608.     {
  609.         return $this->generalPosition;
  610.     }
  611.     /**
  612.      * @return BrochureType
  613.      */
  614.     public function getBrochureType()
  615.     {
  616.         return $this->brochureType;
  617.     }
  618.     /**
  619.      * Add category
  620.      *
  621.      * @param \Notaris\AdminBundle\Entity\IzimiCategory $category
  622.      *
  623.      * @return Brochure
  624.      */
  625.     public function addCategory(\Notaris\AdminBundle\Entity\IzimiCategory $category)
  626.     {
  627.         $this->categories[] = $category;
  628.         return $this;
  629.     }
  630.     /**
  631.      * Remove category
  632.      *
  633.      * @param \Notaris\AdminBundle\Entity\IzimiCategory $category
  634.      */
  635.     public function removeCategory(\Notaris\AdminBundle\Entity\IzimiCategory $category)
  636.     {
  637.         $this->categories->removeElement($category);
  638.     }
  639.     /**
  640.      * Get categories
  641.      *
  642.      * @return \Doctrine\Common\Collections\Collection
  643.      */
  644.     public function getCategories()
  645.     {
  646.         return $this->categories;
  647.     }
  648.     /**
  649.      * Set isIzimi
  650.      *
  651.      * @param boolean $isIzimi
  652.      * @return Brochure
  653.      */
  654.     public function setIsIzimi(bool $isIzimi)
  655.     {
  656.         $this->isIzimi = $isIzimi;
  657.         return $this;
  658.     }
  659.     /**
  660.      * Get isIzimi
  661.      *
  662.      * @return boolean
  663.      */
  664.     public function getIsIzimi()
  665.     {
  666.         return $this->isIzimi;
  667.     }
  668. }