<?php
namespace App\Entity\Produit\Service;
use Doctrine\ORM\Mapping as ORM;
use App\Validator\Validatortext\Taillemin;
use App\Validator\Validatortext\Taillemax;
use App\Validator\Validatortext\Siteweb;
use App\Service\Servicetext\GeneralServicetext;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\EntityManager;
use App\Repository\Produit\Service\ServiceRepository;
use App\Entity\Produit\Service\Typearticle;
use App\Entity\Users\User\User;
use App\Entity\Produit\Service\Imgservice;
use App\Entity\Produit\Service\Evenement;
use App\Entity\Produit\Produit\Produit;
use Doctrine\Common\Collections\Collection;
/**
* Service
*
* @ORM\Table("service")
* @ORM\Entity(repositoryClass=ServiceRepository::class)
*/
class Service
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="nom", type="string", length=255)
*@Taillemin(valeur=3, message="Au moins 3 caractères")
*@Taillemax(valeur=100, message="Au plus 100 caractès")
*/
private $nom;
/**
* @var string
*
* @ORM\Column(name="breve", type="string", length=255, nullable=true)
*@Taillemin(valeur=3, message="Au moins 3 caractères")
*@Taillemax(valeur=40, message="Au plus 40 caractès")
*/
private $breve;
/**
* @var string
*
* @ORM\Column(name="keyword", type="string", length=255, nullable=true)
*@Taillemax(valeur=250, message="Au plus 250 caractès")
*/
private $keyword;
/**
* @var string
*
* @ORM\Column(name="link", type="string", length=255, nullable=true)
*@Siteweb()
*/
private $link;
/**
* @var string
*
* @ORM\Column(name="nomcompte", type="string", length=255, nullable=true)
*/
private $nomcompte;
/**
* @var string
*
* @ORM\Column(name="numcompte", type="string", length=255, nullable=true)
*/
private $numcompte;
/**
* @var string
*
* @ORM\Column(name="description", type="text")
* @Taillemin(valeur=3, message="Au moins 3 caractères")
* @Taillemax(valeur=200, message="Au plus 200 caractès")
*/
private $description;
/**
* @var integer
*
* @ORM\Column(name="rang", type="integer")
*/
private $rang;
/**
* @var \DateTime
*
* @ORM\Column(name="date", type="datetime")
*/
private $date;
/**
* @var string
*
* @ORM\Column(name="typearticle", type="string", length=255)
*/
private $typearticle;
/**
* @ORM\ManyToOne(targetEntity=Typearticle::class, inversedBy="services")
* @ORM\JoinColumn(nullable=true)
*/
private $type;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
*/
private $user;
/**
* @ORM\OneToOne(targetEntity=Imgservice::class, cascade={"persist","remove"})
* @ORM\JoinColumn(nullable=false)
* @Assert\Valid()
*/
private $imgservice;
/**
* @ORM\OneToMany(targetEntity=Evenement::class, mappedBy="service")
*/
private $evenements;
/**
* @ORM\ManyToOne(targetEntity=Produit::class, inversedBy="services")
* @ORM\JoinColumn(nullable=true)
*/
private $produit;
// variable du service de normalisation des noms des pays.
private $servicetext;
private $em;
public function __construct(GeneralServicetext $service)
{
$this->servicetext = $service;
$this->date = new \Datetime();
$this->rang = 0;
$this->evenements = new \Doctrine\Common\Collections\ArrayCollection();
}
public function setServicetext( GeneralServicetext $service)
{
$this->servicetext = $service;
}
public function getServicetext()
{
return $this->servicetext;
}
public function setEm($em)
{
$this->em = $em;
}
public function getEm()
{
return $this->em;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set nom
*
* @param string $nom
* @return Service
*/
public function setNom($nom)
{
$this->nom = $nom;
return $this;
}
/**
* Get nom
*
* @return string
*/
public function getNom()
{
return $this->nom;
}
/**
* Set description
*
* @param string $description
* @return Service
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set date
*
* @param \DateTime $date
* @return Service
*/
public function setDate($date)
{
$this->date = $date;
return $this;
}
/**
* Get date
*
* @return \DateTime
*/
public function getDate()
{
return $this->date;
}
/**
* Set user
* @return Service
*/
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
/**
* Get user
*/
public function getUser(): ?User
{
return $this->user;
}
/**
* Set imgservice
* @return Service
*/
public function setImgservice(Imgservice $imgservice): self
{
$this->imgservice = $imgservice;
return $this;
}
/**
* Get imgservice
*/
public function getImgservice(): ?Imgservice
{
return $this->imgservice;
}
/**
* Add evenements
* @return Service
*/
public function addEvenement(Evenement $evenements): self
{
$this->evenements[] = $evenements;
return $this;
}
/**
* Remove evenements
*/
public function removeEvenement(Evenement $evenements)
{
$this->evenements->removeElement($evenements);
}
/**
* Get evenements
*/
public function getEvenements(): ?Collection
{
return $this->evenements;
}
/**
* Set rang
*
* @param integer $rang
* @return Service
*/
public function setRang($rang)
{
$this->rang = $rang;
return $this;
}
/**
* Get rang
*
* @return integer
*/
public function getRang()
{
return $this->rang;
}
public function subdescription($tail)
{
if(strlen($this->description) <= $tail)
{
return $this->description;
}else{
$text = wordwrap($this->description,$tail,'~',true);
$tab = explode('~',$text);
$text = $tab[0];
return $text.'...';
}
}
/**
* Set breve
*
* @param string $breve
* @return Service
*/
public function setBreve($breve)
{
$this->breve = $breve;
return $this;
}
/**
* Get breve
*
* @return string
*/
public function getBreve()
{
return $this->breve;
}
/**
* Set keyword
*
* @param string $keyword
* @return Service
*/
public function setKeyword($keyword)
{
$this->keyword = $keyword;
return $this;
}
/**
* Get keyword
*
* @return string
*/
public function getKeyword()
{
return $this->keyword;
}
public function getPartiearticles()
{
$liste_partie = $this->em->getRepository(Evenement::class)
->findBy(array('service'=>$this, 'typearticle'=>'autres'),array('rang'=>'asc'));
return $liste_partie;
}
public function getLogo()
{
$logo = $this->em->getRepository(Evenement::class)
->findOneBy(array('service'=>$this, 'typearticle'=>'logo'),array('rang'=>'asc'));
return $logo;
}
public function getFacebook()
{
$facebook = $this->em->getRepository(Evenement::class)
->findOneBy(array('service'=>$this, 'typearticle'=>'facebook'),array('rang'=>'asc'));
return $facebook;
}
public function getTwitter()
{
$twitter = $this->em->getRepository(Evenement::class)
->findOneBy(array('service'=>$this, 'typearticle'=>'twitter'),array('rang'=>'asc'));
return $twitter;
}
public function getGoogle()
{
$google = $this->em->getRepository(Evenement::class)
->findOneBy(array('service'=>$this, 'typearticle'=>'google'),array('rang'=>'asc'));
return $google;
}
public function getLinkedin()
{
$linkedin = $this->em->getRepository(Evenement::class)
->findOneBy(array('service'=>$this, 'typearticle'=>'linkedin'),array('rang'=>'asc'));
return $linkedin;
}
/**
* Set nomcompte
*
* @param string $nomcompte
* @return Service
*/
public function setNomcompte($nomcompte)
{
$this->nomcompte = $nomcompte;
return $this;
}
/**
* Get nomcompte
*
* @return string
*/
public function getNomcompte()
{
return $this->nomcompte;
}
/**
* Set numcompte
*
* @param string $numcompte
* @return Service
*/
public function setNumcompte($numcompte)
{
$this->numcompte = $numcompte;
return $this;
}
/**
* Get numcompte
*
* @return string
*/
public function getNumcompte()
{
return $this->numcompte;
}
/**
* Set typearticle
*
* @param string $typearticle
* @return Service
*/
public function setTypearticle($typearticle)
{
$this->typearticle = $typearticle;
return $this;
}
/**
* Get typearticle
*
* @return string
*/
public function getTypearticle()
{
return $this->typearticle;
}
/**
* Set produit
* @return Service
*/
public function setProduit(Produit $produit = null): self
{
$this->produit = $produit;
if($produit != null)
{
$produit->addService($this);
}
return $this;
}
/**
* Get produit
*/
public function getProduit(): ?Produit
{
return $this->produit;
}
/**
* Set type
* @return Service
*/
public function setType(Typearticle $type = null): self
{
$this->type = $type;
if($type != null)
{
$type->addService($this);
}
return $this;
}
/**
* Get type
*/
public function getType(): ?Typearticle
{
return $this->type;
}
/**
* Set link
*
* @param string $link
* @return Service
*/
public function setLink($link)
{
$this->link = $link;
return $this;
}
/**
* Get link
*
* @return string
*/
public function getLink()
{
return $this->link;
}
}