src/Entity/Insight.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Business\Context;
  4. use App\Business\ContextableEntity;
  5. use App\Application\Sonata\MediaBundle\Entity\Gallery;
  6. use App\Application\Sonata\MediaBundle\Entity\Media;
  7. use DateTime;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * Event
  15.  *
  16.  * @ORM\Table(name="insight")
  17.  * @ORM\Entity(repositoryClass="App\Repository\InsightRepository")
  18.  */
  19. class Insight implements ContextableEntity
  20. {
  21.     /**
  22.      * @var int
  23.      *
  24.      * @ORM\Column(name="id", type="integer")
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue(strategy="AUTO")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @var string
  31.      * @ORM\Column(name="title", type="string", length=256)
  32.      */
  33.     private $title;
  34.     /**
  35.      * @Gedmo\Slug(fields={"title"})
  36.      * @ORM\Column(length=128, unique=true)
  37.      */
  38.     private $url;
  39.     /**
  40.      * @ORM\ManyToMany(targetEntity="App\Entity\Team")
  41.      * @ORM\JoinTable(name="insight_contacts",
  42.      *      joinColumns={@ORM\JoinColumn(name="insight_id", referencedColumnName="id")},
  43.      *      inverseJoinColumns={@ORM\JoinColumn(name="team_id", referencedColumnName="id")}
  44.      *   )
  45.      */
  46.     private $contacts;
  47.     /**
  48.      * @ORM\ManyToMany(targetEntity="App\Entity\Product")
  49.      * @ORM\JoinTable(name="insight_products",
  50.      *      joinColumns={@ORM\JoinColumn(name="insight_id", referencedColumnName="id")},
  51.      *      inverseJoinColumns={@ORM\JoinColumn(name="product_id", referencedColumnName="id")}
  52.      *   )
  53.      */
  54.     private $products;
  55.     /**
  56.      * @var ArrayCollection
  57.      * @ORM\ManyToMany(targetEntity="App\Entity\QuickLink", cascade={"persist"})
  58.      * @ORM\JoinTable(name="insight_links",
  59.      *     joinColumns={@ORM\JoinColumn(name="insight_id", referencedColumnName="id")},
  60.      *     inverseJoinColumns={@ORM\JoinColumn(name="link_id", referencedColumnName="id")}
  61.      * )
  62.      */
  63.     private $links;
  64.     /**
  65.      * @var string
  66.      * @ORM\Column(name="meta_description", type="string", length=255, nullable=true)
  67.      */
  68.     private $meta_description;
  69.     /**
  70.      * @var string
  71.      * @ORM\Column(name="meta_keywords", type="string", length=255, nullable=true)
  72.      */
  73.     private $meta_keywords;
  74.     /**
  75.      * @var string
  76.      * @Assert\Length(max=140)
  77.      * @ORM\Column(name="teaser", type="string", length=140,nullable=true)
  78.      */
  79.     private $teaser;
  80.     /**
  81.      * @var string
  82.      * @ORM\Column(name="text", type="text")
  83.      */
  84.     private $text;
  85.     /**
  86.      * @ORM\ManyToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"})
  87.      */
  88.     private $imageCaption;
  89.     /**
  90.      * @var string
  91.      * @ORM\Column(name="photo_credit",type="string", length=255, nullable=true)
  92.      */
  93.     private $photoCredit;
  94.     /**
  95.      * @ORM\ManyToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"})
  96.      */
  97.     private $banner;
  98.     /**
  99.      * @ORM\OneToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Gallery", cascade={"persist"}, fetch="LAZY")
  100.      */
  101.     private $gallery;
  102.     /**
  103.      * @ORM\Column(name="featured", type="boolean")
  104.      */
  105.     private $featured false;
  106.     /**
  107.      * @ORM\Column(name="use_grey_background_banner", type="boolean")
  108.      */
  109.     private $useGreyBackgroundOnBanner false;
  110.     /**
  111.      * @ORM\ManyToOne(targetEntity="App\Entity\SonataClassificationCategory", cascade={"persist"})
  112.      */
  113.     private $category;
  114.     /**
  115.      * @ORM\ManyToMany(targetEntity="App\Entity\SonataClassificationTag")
  116.      */
  117.     private $tags;
  118.     /**
  119.      * @var boolean
  120.      * @ORM\Column(name="publish", type="boolean")
  121.      */
  122.     private $publish false;
  123.     /**
  124.      * @var DateTime
  125.      * @ORM\Column(name="publish_date_end", type="datetime", nullable=true)
  126.      */
  127.     private $publish_date_end;
  128.     /**
  129.      * @var DateTime
  130.      * @ORM\Column(name="date", type="datetime", nullable=true)
  131.      */
  132.     private $date;
  133.     public function __construct()
  134.     {
  135.         $this->contacts = new ArrayCollection();
  136.         $this->products = new ArrayCollection();
  137.         $this->tags = new ArrayCollection();
  138.         $this->links = new ArrayCollection();
  139.         $this->date = new DateTime();
  140.     }
  141.     /**
  142.      * @return string
  143.      */
  144.     public function getPhotoCredit(): ?string
  145.     {
  146.         return $this->photoCredit;
  147.     }
  148.     /**
  149.      * @param string $photoCredit
  150.      */
  151.     public function setPhotoCredit(string $photoCredit null): void
  152.     {
  153.         $this->photoCredit $photoCredit;
  154.     }
  155.     /**
  156.      * @return mixed
  157.      */
  158.     public function getUseGreyBackgroundOnBanner()
  159.     {
  160.         return $this->useGreyBackgroundOnBanner;
  161.     }
  162.     /**
  163.      * @param mixed $useGreyBackgroundOnBanner
  164.      */
  165.     public function setUseGreyBackgroundOnBanner($useGreyBackgroundOnBanner): void
  166.     {
  167.         $this->useGreyBackgroundOnBanner $useGreyBackgroundOnBanner;
  168.     }
  169.     public function __toString()
  170.     {
  171.         return (string)$this->getTitle();
  172.     }
  173.     /**
  174.      * Get title
  175.      *
  176.      * @return string
  177.      */
  178.     public function getTitle()
  179.     {
  180.         return $this->title;
  181.     }
  182.     /**
  183.      * Set title
  184.      *
  185.      * @param string $title
  186.      *
  187.      * @return Insight
  188.      */
  189.     public function setTitle($title)
  190.     {
  191.         $this->title $title;
  192.         return $this;
  193.     }
  194.     /**
  195.      * @return string Context::INSIGHTS
  196.      */
  197.     public function getContextId(): string
  198.     {
  199.         return Context::INSIGHTS;
  200.     }
  201.     public function getContextCategoryId(): string
  202.     {
  203.         return "";
  204.     }
  205.     public function getContextMainCategoryId(): string
  206.     {
  207.         return $this->getCategory()->getName();
  208.     }/** @noinspection PhpLanguageLevelInspection */
  209.     /**
  210.      * Get category
  211.      *
  212.      * @return SonataClassificationCategory
  213.      */
  214.     public function getCategory()
  215.     {
  216.         return $this->category;
  217.     }
  218.     /**
  219.      * Set category
  220.      *
  221.      * @param SonataClassificationCategory $category
  222.      *
  223.      * @return Insight
  224.      */
  225.     public function setCategory(SonataClassificationCategory $category null)
  226.     {
  227.         $this->category $category;
  228.         return $this;
  229.     }
  230.     /**
  231.      * @return DateTime
  232.      */
  233.     public function getDate(): ?DateTime
  234.     {
  235.         return $this->date;
  236.     }
  237.     /**
  238.      * @param DateTime $date
  239.      */
  240.     public function setDate(DateTime $date null)
  241.     {
  242.         $this->date $date;
  243.     }
  244.     public function toString(): string
  245.     {
  246.         return "{id=" $this->id "}";
  247.     }
  248.     /**
  249.      * Get id
  250.      *
  251.      * @return integer
  252.      */
  253.     public function getId()
  254.     {
  255.         return $this->id;
  256.     }
  257.     /**
  258.      * Get teaser
  259.      *
  260.      * @return string
  261.      */
  262.     public function getTeaser()
  263.     {
  264.         return $this->teaser;
  265.     }
  266.     /**
  267.      * Set teaser
  268.      *
  269.      * @param string $teaser
  270.      *
  271.      * @return Insight
  272.      */
  273.     public function setTeaser($teaser)
  274.     {
  275.         $this->teaser $teaser;
  276.         return $this;
  277.     }
  278.     /**
  279.      * Get text
  280.      *
  281.      * @return string
  282.      */
  283.     public function getText()
  284.     {
  285.         return $this->text;
  286.     }
  287.     /**
  288.      * Set text
  289.      *
  290.      * @param string $text
  291.      *
  292.      * @return Insight
  293.      */
  294.     public function setText($text)
  295.     {
  296.         $this->text $text;
  297.         return $this;
  298.     }
  299.     /**
  300.      * Get publish
  301.      *
  302.      * @return boolean
  303.      */
  304.     public function getPublish()
  305.     {
  306.         return $this->publish;
  307.     }
  308.     /**
  309.      * Set publish
  310.      *
  311.      * @param boolean $publish
  312.      *
  313.      * @return Insight
  314.      */
  315.     public function setPublish($publish)
  316.     {
  317.         $this->publish $publish;
  318.         return $this;
  319.     }
  320.     /**
  321.      * Get imageCaption
  322.      *
  323.      * @return Media
  324.      */
  325.     public function getImageCaption(): ?Media
  326.     {
  327.         return $this->imageCaption;
  328.     }
  329.     /**
  330.      * Set imageCaption
  331.      *
  332.      * @param Media $imageCaption
  333.      *
  334.      * @return Insight
  335.      */
  336.     public function setImageCaption(Media $imageCaption null)
  337.     {
  338.         $this->imageCaption $imageCaption;
  339.         return $this;
  340.     }
  341.     /**
  342.      * Get publishDateEnd
  343.      *
  344.      * @return DateTime
  345.      */
  346.     public function getPublishDateEnd()
  347.     {
  348.         return $this->publish_date_end;
  349.     }
  350.     /**
  351.      * Set publishDateEnd
  352.      *
  353.      * @param DateTime $publishDateEnd
  354.      *
  355.      * @return Insight
  356.      */
  357.     public function setPublishDateEnd($publishDateEnd)
  358.     {
  359.         $this->publish_date_end $publishDateEnd;
  360.         return $this;
  361.     }
  362.     /**
  363.      * Get url
  364.      *
  365.      * @return string
  366.      */
  367.     public function getUrl()
  368.     {
  369.         return $this->url;
  370.     }
  371.     /**
  372.      * Set url
  373.      *
  374.      * @param string $url
  375.      *
  376.      * @return Insight
  377.      */
  378.     public function setUrl($url)
  379.     {
  380.         $this->url $url;
  381.         return $this;
  382.     }
  383.     /**
  384.      * Get metaDescription
  385.      *
  386.      * @return string
  387.      */
  388.     public function getMetaDescription()
  389.     {
  390.         return $this->meta_description;
  391.     }
  392.     /**
  393.      * Set metaDescription
  394.      *
  395.      * @param string $metaDescription
  396.      *
  397.      * @return Insight
  398.      */
  399.     public function setMetaDescription($metaDescription)
  400.     {
  401.         $this->meta_description $metaDescription;
  402.         return $this;
  403.     }
  404.     /**
  405.      * Get metaKeywords
  406.      *
  407.      * @return string
  408.      */
  409.     public function getMetaKeywords()
  410.     {
  411.         return $this->meta_keywords;
  412.     }
  413.     /**
  414.      * Set metaKeywords
  415.      *
  416.      * @param string $metaKeywords
  417.      *
  418.      * @return Insight
  419.      */
  420.     public function setMetaKeywords($metaKeywords)
  421.     {
  422.         $this->meta_keywords $metaKeywords;
  423.         return $this;
  424.     }
  425.     /**
  426.      * Add contact
  427.      *
  428.      * @param Team $contact
  429.      *
  430.      * @return Insight
  431.      */
  432.     public function addContact(Team $contact)
  433.     {
  434.         $this->contacts[] = $contact;
  435.         return $this;
  436.     }
  437.     /**
  438.      * Add product
  439.      *
  440.      * @param Product $product
  441.      * @return Insight
  442.      */
  443.     public function addProduct(Product $product)
  444.     {
  445.         $this->products[] = $product;
  446.         return $this;
  447.     }
  448.     /**
  449.      * Remove contact
  450.      *
  451.      * @param Team $contact
  452.      */
  453.     public function removeContact(Team $contact)
  454.     {
  455.         $this->contacts->removeElement($contact);
  456.     }
  457.     /**
  458.      * Get contacts
  459.      *
  460.      * @return Collection
  461.      */
  462.     public function getContacts()
  463.     {
  464.         return $this->contacts;
  465.     }
  466.     /**
  467.      * Get contacts
  468.      *
  469.      * @return Collection
  470.      */
  471.     public function getProducts()
  472.     {
  473.         return $this->products;
  474.     }
  475.     /**
  476.      * @param mixed $products
  477.      */
  478.     public function setProducts($products): void
  479.     {
  480.         $this->products $products;
  481.     }
  482.     /**
  483.      * Get featured
  484.      *
  485.      * @return boolean
  486.      */
  487.     public function getFeatured()
  488.     {
  489.         return $this->featured;
  490.     }
  491.     /**
  492.      * Set featured
  493.      *
  494.      * @param boolean $featured
  495.      *
  496.      * @return Insight
  497.      */
  498.     public function setFeatured($featured)
  499.     {
  500.         $this->featured $featured;
  501.         return $this;
  502.     }
  503.     /**
  504.      * Add tag
  505.      *
  506.      * @param SonataClassificationTag $tag
  507.      *
  508.      * @return Insight
  509.      */
  510.     public function addTag(SonataClassificationTag $tag)
  511.     {
  512.         $this->tags[] = $tag;
  513.         return $this;
  514.     }
  515.     /**
  516.      * Remove tag
  517.      *
  518.      * @param SonataClassificationTag $tag
  519.      */
  520.     public function removeTag(SonataClassificationTag $tag)
  521.     {
  522.         $this->tags->removeElement($tag);
  523.     }
  524.     /**
  525.      * Get tags
  526.      *
  527.      * @return Collection
  528.      */
  529.     public function getTags()
  530.     {
  531.         return $this->tags;
  532.     }
  533.     /**
  534.      * Get banner
  535.      *
  536.      * @return Media
  537.      */
  538.     public function getBanner()
  539.     {
  540.         return $this->banner;
  541.     }
  542.     /**
  543.      * Set banner
  544.      *
  545.      * @param Media $banner
  546.      *
  547.      * @return Insight
  548.      */
  549.     public function setBanner(Media $banner null)
  550.     {
  551.         $this->banner $banner;
  552.         return $this;
  553.     }
  554.     /**
  555.      * Add link
  556.      *
  557.      * @param QuickLink $link
  558.      *
  559.      * @return Insight
  560.      */
  561.     public function addLink(QuickLink $link)
  562.     {
  563.         $this->links[] = $link;
  564.         return $this;
  565.     }
  566.     /**
  567.      * Remove link
  568.      *
  569.      * @param QuickLink $link
  570.      */
  571.     public function removeLink(QuickLink $link)
  572.     {
  573.         $this->links->removeElement($link);
  574.     }
  575.     /**
  576.      * Get links
  577.      *
  578.      * @return Collection
  579.      */
  580.     public function getLinks()
  581.     {
  582.         return $this->links;
  583.     }
  584.     /**
  585.      * Get gallery
  586.      *
  587.      * @return Gallery
  588.      */
  589.     public function getGallery()
  590.     {
  591.         return $this->gallery;
  592.     }
  593.     /**
  594.      * Set gallery
  595.      *
  596.      * @param Gallery $gallery
  597.      *
  598.      * @return Insight
  599.      */
  600.     public function setGallery(Gallery $gallery null)
  601.     {
  602.         $this->gallery $gallery;
  603.         return $this;
  604.     }
  605. }