src/Entity/Produit/Service/Service.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Produit\Service;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Validator\Validatortext\Taillemin;
  5. use App\Validator\Validatortext\Taillemax;
  6. use App\Validator\Validatortext\Siteweb;
  7. use App\Service\Servicetext\GeneralServicetext;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Doctrine\ORM\EntityManager;
  10. use App\Repository\Produit\Service\ServiceRepository;
  11. use App\Entity\Produit\Service\Typearticle;
  12. use App\Entity\Users\User\User;
  13. use App\Entity\Produit\Service\Imgservice;
  14. use App\Entity\Produit\Service\Evenement;
  15. use App\Entity\Produit\Produit\Produit;
  16. use Doctrine\Common\Collections\Collection;
  17. /**
  18.  * Service
  19.  *
  20.  * @ORM\Table("service")
  21.  * @ORM\Entity(repositoryClass=ServiceRepository::class)
  22.  */
  23. class Service
  24. {
  25.     /**
  26.      * @var integer
  27.      *
  28.      * @ORM\Column(name="id", type="integer")
  29.      * @ORM\Id
  30.      * @ORM\GeneratedValue(strategy="AUTO")
  31.      */
  32.     private $id;
  33.     /**
  34.      * @var string
  35.      *
  36.      * @ORM\Column(name="nom", type="string", length=255)
  37.      *@Taillemin(valeur=3, message="Au moins 3 caractères")
  38.      *@Taillemax(valeur=100, message="Au plus 100 caractès")
  39.      */
  40.     private $nom;
  41.     
  42.     /**
  43.      * @var string
  44.      *
  45.      * @ORM\Column(name="breve", type="string", length=255, nullable=true)
  46.      *@Taillemin(valeur=3, message="Au moins 3 caractères")
  47.      *@Taillemax(valeur=40, message="Au plus 40 caractès")
  48.      */
  49.     private $breve;
  50.     
  51.     /**
  52.      * @var string
  53.      *
  54.      * @ORM\Column(name="keyword", type="string", length=255, nullable=true)
  55.      *@Taillemax(valeur=250, message="Au plus 250 caractès")
  56.      */
  57.     private $keyword;
  58.     
  59.     /**
  60.      * @var string
  61.      *
  62.      * @ORM\Column(name="link", type="string", length=255, nullable=true)
  63.      *@Siteweb()
  64.      */
  65.     private $link;
  66.     
  67.     /**
  68.      * @var string
  69.      *
  70.      * @ORM\Column(name="nomcompte", type="string", length=255, nullable=true)
  71.      */
  72.     private $nomcompte;
  73.     
  74.     /**
  75.      * @var string
  76.      *
  77.      * @ORM\Column(name="numcompte", type="string", length=255, nullable=true)
  78.      */
  79.     private $numcompte;
  80.     /**
  81.      * @var string
  82.      *
  83.      * @ORM\Column(name="description", type="text")
  84.      * @Taillemin(valeur=3, message="Au moins 3 caractères")
  85.      * @Taillemax(valeur=200, message="Au plus 200 caractès")
  86.      */
  87.     private $description;
  88.     
  89.     /**
  90.      * @var integer
  91.      *
  92.      * @ORM\Column(name="rang", type="integer")
  93.      */
  94.     private $rang;
  95.     /**
  96.      * @var \DateTime
  97.      *
  98.      * @ORM\Column(name="date", type="datetime")
  99.      */
  100.     private $date;
  101.     
  102.     /**
  103.      * @var string
  104.      *
  105.      * @ORM\Column(name="typearticle", type="string", length=255)
  106.      */
  107.     private $typearticle;
  108.     
  109.     /**
  110.      * @ORM\ManyToOne(targetEntity=Typearticle::class, inversedBy="services")
  111.      * @ORM\JoinColumn(nullable=true)
  112.     */
  113.     private $type;
  114.     
  115.     /**
  116.      * @ORM\ManyToOne(targetEntity=User::class)
  117.      * @ORM\JoinColumn(nullable=false)
  118.     */
  119.     private $user;
  120.     
  121.     /**
  122.      * @ORM\OneToOne(targetEntity=Imgservice::class,  cascade={"persist","remove"})
  123.      * @ORM\JoinColumn(nullable=false)
  124.      * @Assert\Valid()
  125.     */
  126.     private $imgservice;
  127.     
  128.     /**
  129.      * @ORM\OneToMany(targetEntity=Evenement::class, mappedBy="service")
  130.      */
  131.     private $evenements;
  132.     
  133.     /**
  134.      * @ORM\ManyToOne(targetEntity=Produit::class, inversedBy="services")
  135.      * @ORM\JoinColumn(nullable=true)
  136.     */
  137.     private $produit;
  138.     
  139.     // variable du service de normalisation des noms des pays.
  140.     private $servicetext;
  141.     
  142.     private $em;
  143.     
  144.     public function __construct(GeneralServicetext $service)
  145.     {
  146.         $this->servicetext $service;
  147.         $this->date = new \Datetime();
  148.         $this->rang 0;
  149.         $this->evenements = new \Doctrine\Common\Collections\ArrayCollection();
  150.     }
  151.     public function setServicetextGeneralServicetext $service)
  152.     {
  153.     $this->servicetext $service;
  154.     }
  155.     public function getServicetext()
  156.     {
  157.     return $this->servicetext;
  158.     }
  159.     
  160.     public function setEm($em)
  161.     {
  162.     $this->em $em;
  163.     }
  164.     public function getEm()
  165.     {
  166.     return $this->em;
  167.     }
  168.     /**
  169.      * Get id
  170.      *
  171.      * @return integer 
  172.      */
  173.     public function getId()
  174.     {
  175.         return $this->id;
  176.     }
  177.     /**
  178.      * Set nom
  179.      *
  180.      * @param string $nom
  181.      * @return Service
  182.      */
  183.     public function setNom($nom)
  184.     {
  185.         $this->nom $nom;
  186.         return $this;
  187.     }
  188.     /**
  189.      * Get nom
  190.      *
  191.      * @return string 
  192.      */
  193.     public function getNom()
  194.     {
  195.         return $this->nom;
  196.     }
  197.     /**
  198.      * Set description
  199.      *
  200.      * @param string $description
  201.      * @return Service
  202.      */
  203.     public function setDescription($description)
  204.     {
  205.         $this->description $description;
  206.         return $this;
  207.     }
  208.     /**
  209.      * Get description
  210.      *
  211.      * @return string 
  212.      */
  213.     public function getDescription()
  214.     {
  215.         return $this->description;
  216.     }
  217.     /**
  218.      * Set date
  219.      *
  220.      * @param \DateTime $date
  221.      * @return Service
  222.      */
  223.     public function setDate($date)
  224.     {
  225.         $this->date $date;
  226.         return $this;
  227.     }
  228.     /**
  229.      * Get date
  230.      *
  231.      * @return \DateTime 
  232.      */
  233.     public function getDate()
  234.     {
  235.         return $this->date;
  236.     }
  237.     
  238.     
  239.     /**
  240.      * Set user
  241.      * @return Service
  242.      */
  243.     public function setUser(User $user): self
  244.     {
  245.         $this->user $user;
  246.         return $this;
  247.     }
  248.     /**
  249.      * Get user
  250.      */
  251.     public function getUser(): ?User
  252.     {
  253.         return $this->user;
  254.     }
  255.     /**
  256.      * Set imgservice
  257.      * @return Service
  258.      */
  259.     public function setImgservice(Imgservice $imgservice): self
  260.     {
  261.         $this->imgservice $imgservice;
  262.         return $this;
  263.     }
  264.     /**
  265.      * Get imgservice
  266.      */
  267.     public function getImgservice(): ?Imgservice
  268.     {
  269.         return $this->imgservice;
  270.     }
  271.     /**
  272.      * Add evenements
  273.      * @return Service
  274.      */
  275.     public function addEvenement(Evenement $evenements): self
  276.     {
  277.         $this->evenements[] = $evenements;
  278.         return $this;
  279.     }
  280.     /**
  281.      * Remove evenements
  282.      */
  283.     public function removeEvenement(Evenement $evenements)
  284.     {
  285.         $this->evenements->removeElement($evenements);
  286.     }
  287.     /**
  288.      * Get evenements 
  289.      */
  290.     public function getEvenements(): ?Collection
  291.     {
  292.         return $this->evenements;
  293.     }
  294.     /**
  295.      * Set rang
  296.      *
  297.      * @param integer $rang
  298.      * @return Service
  299.      */
  300.     public function setRang($rang)
  301.     {
  302.         $this->rang $rang;
  303.         return $this;
  304.     }
  305.     /**
  306.      * Get rang
  307.      *
  308.      * @return integer 
  309.      */
  310.     public function getRang()
  311.     {
  312.         return $this->rang;
  313.     }
  314.     
  315.     public function subdescription($tail)
  316.     {
  317.         if(strlen($this->description) <= $tail)
  318.         {
  319.             return $this->description;
  320.         }else{
  321.             $text wordwrap($this->description,$tail,'~',true);
  322.             $tab explode('~',$text);
  323.             $text $tab[0];
  324.             return $text.'...';
  325.         }
  326.     }
  327.     /**
  328.      * Set breve
  329.      *
  330.      * @param string $breve
  331.      * @return Service
  332.      */
  333.     public function setBreve($breve)
  334.     {
  335.         $this->breve $breve;
  336.         return $this;
  337.     }
  338.     /**
  339.      * Get breve
  340.      *
  341.      * @return string 
  342.      */
  343.     public function getBreve()
  344.     {
  345.         return $this->breve;
  346.     }
  347.     /**
  348.      * Set keyword
  349.      *
  350.      * @param string $keyword
  351.      * @return Service
  352.      */
  353.     public function setKeyword($keyword)
  354.     {
  355.         $this->keyword $keyword;
  356.         return $this;
  357.     }
  358.     /**
  359.      * Get keyword
  360.      *
  361.      * @return string 
  362.      */
  363.     public function getKeyword()
  364.     {
  365.         return $this->keyword;
  366.     }
  367.     
  368.     public function getPartiearticles()
  369.     {
  370.         $liste_partie $this->em->getRepository(Evenement::class)
  371.                             ->findBy(array('service'=>$this'typearticle'=>'autres'),array('rang'=>'asc'));
  372.         return $liste_partie;
  373.     }
  374.     
  375.     public function getLogo()
  376.     {
  377.         $logo $this->em->getRepository(Evenement::class)
  378.                             ->findOneBy(array('service'=>$this'typearticle'=>'logo'),array('rang'=>'asc'));
  379.         return $logo;
  380.     }
  381.     
  382.     public function getFacebook()
  383.     {
  384.         $facebook $this->em->getRepository(Evenement::class)
  385.                             ->findOneBy(array('service'=>$this'typearticle'=>'facebook'),array('rang'=>'asc'));
  386.         return $facebook;
  387.     }
  388.     public function getTwitter()
  389.     {
  390.         $twitter $this->em->getRepository(Evenement::class)
  391.                             ->findOneBy(array('service'=>$this'typearticle'=>'twitter'),array('rang'=>'asc'));
  392.         return $twitter;
  393.     }
  394.     public function getGoogle()
  395.     {
  396.         $google $this->em->getRepository(Evenement::class)
  397.                             ->findOneBy(array('service'=>$this'typearticle'=>'google'),array('rang'=>'asc'));
  398.         return $google;
  399.     }
  400.     public function getLinkedin()
  401.     {
  402.         $linkedin $this->em->getRepository(Evenement::class)
  403.                             ->findOneBy(array('service'=>$this'typearticle'=>'linkedin'),array('rang'=>'asc'));
  404.         return $linkedin;
  405.     }
  406.     /**
  407.      * Set nomcompte
  408.      *
  409.      * @param string $nomcompte
  410.      * @return Service
  411.      */
  412.     public function setNomcompte($nomcompte)
  413.     {
  414.         $this->nomcompte $nomcompte;
  415.         return $this;
  416.     }
  417.     /**
  418.      * Get nomcompte
  419.      *
  420.      * @return string 
  421.      */
  422.     public function getNomcompte()
  423.     {
  424.         return $this->nomcompte;
  425.     }
  426.     /**
  427.      * Set numcompte
  428.      *
  429.      * @param string $numcompte
  430.      * @return Service
  431.      */
  432.     public function setNumcompte($numcompte)
  433.     {
  434.         $this->numcompte $numcompte;
  435.         return $this;
  436.     }
  437.     /**
  438.      * Get numcompte
  439.      *
  440.      * @return string 
  441.      */
  442.     public function getNumcompte()
  443.     {
  444.         return $this->numcompte;
  445.     }
  446.     /**
  447.      * Set typearticle
  448.      *
  449.      * @param string $typearticle
  450.      * @return Service
  451.      */
  452.     public function setTypearticle($typearticle)
  453.     {
  454.         $this->typearticle $typearticle;
  455.         return $this;
  456.     }
  457.     /**
  458.      * Get typearticle
  459.      *
  460.      * @return string 
  461.      */
  462.     public function getTypearticle()
  463.     {
  464.         return $this->typearticle;
  465.     }
  466.     /**
  467.      * Set produit
  468.      * @return Service
  469.      */
  470.     public function setProduit(Produit $produit null): self
  471.     {
  472.         $this->produit $produit;
  473.         if($produit != null)
  474.         {
  475.             $produit->addService($this);
  476.         }
  477.         return $this;
  478.     }
  479.     /**
  480.      * Get produit
  481.      */
  482.     public function getProduit(): ?Produit
  483.     {
  484.         return $this->produit;
  485.     }
  486.     /**
  487.      * Set type
  488.      * @return Service
  489.      */
  490.     public function setType(Typearticle $type null): self
  491.     {
  492.         $this->type $type;
  493.         if($type != null)
  494.         {
  495.             $type->addService($this);
  496.         }
  497.         return $this;
  498.     }
  499.     /**
  500.      * Get type
  501.      */
  502.     public function getType(): ?Typearticle
  503.     {
  504.         return $this->type;
  505.     }
  506.     /**
  507.      * Set link
  508.      *
  509.      * @param string $link
  510.      * @return Service
  511.      */
  512.     public function setLink($link)
  513.     {
  514.         $this->link $link;
  515.         return $this;
  516.     }
  517.     /**
  518.      * Get link
  519.      *
  520.      * @return string 
  521.      */
  522.     public function getLink()
  523.     {
  524.         return $this->link;
  525.     }
  526. }