<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* CacheConfiguration
*
* @ORM\Table(name="cacheconfiguration")
* @ORM\Entity(repositoryClass="App\Repository\CacheConfigurationRepository")
*/
class CacheConfiguration
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue()
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $url;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $userId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $pwkey;
/**
* @ORM\Column(type="string", length=500, nullable=true)
*/
private $pnames;
/**
* @ORM\Column(type="string", length=3000, nullable=true)
*/
private $exportedXmlFileUrl;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $exportedXmlTranslatedFilesUrls = [];
/**
* @ORM\Column(type="string", length=4000, nullable=true)
*/
private $pvalues;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $extraParams = [];
/**
* @var \DateTime|null
*
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="integer", options={"default" : 20})
*/
private $updateLimit;
/**
* @ORM\Column(type="integer", options={"default" : 50})
*/
private $totalLimit;
/**
* @ORM\Column(type="integer", options={"default" : 10})
*/
private $ordre;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function getUserId(): ?string
{
return $this->userId;
}
public function setUserId(?string $userId): self
{
$this->userId = $userId;
return $this;
}
public function getPwkey(): ?string
{
return $this->pwkey;
}
public function setPwkey(?string $pwkey): self
{
$this->pwkey = $pwkey;
return $this;
}
public function getPnames(): ?string
{
return $this->pnames;
}
public function setPnames(?string $pnames): self
{
$this->pnames = $pnames;
return $this;
}
public function getExportedXmlFileUrl(): ?string
{
return $this->exportedXmlFileUrl;
}
public function setExportedXmlFileUrl(?string $exportedXmlFileUrl): self
{
$this->exportedXmlFileUrl = $exportedXmlFileUrl;
return $this;
}
public function getExportedXmlTranslatedFilesUrls(): ?array
{
return $this->exportedXmlTranslatedFilesUrls;
}
public function setExportedXmlTranslatedFilesUrls(?array $exportedXmlTranslatedFilesUrls): self
{
$this->exportedXmlTranslatedFilesUrls = $exportedXmlTranslatedFilesUrls;
return $this;
}
public function getPvalues(): ?string
{
return $this->pvalues;
}
public function setPvalues(?string $pvalues): self
{
$this->pvalues = $pvalues;
return $this;
}
public function getExtraParams(): ?array
{
return $this->extraParams;
}
public function setExtraParams(?array $extraParams): self
{
$this->extraParams = $extraParams;
return $this;
}
public function getTotalUrl(): ?string
{
$userId = $this->getUserId();
$pwkey = $this->getPwkey();
$pnames = $this->getPnames();
$pvalues = $this->getPvalues();
$extraParams = $this->getExtraParams();
$url = $this->getUrl() . "/xml/exploitation/listeproduits.asp" .
"?lxml=sit_listereduite&latable=SIT_LISTEREDUITE&leschamps=Produit,MARQUAGE&tousprods=Y" .
"&user=$userId&pwkey=$pwkey&pnames=$pnames&pvalues=$pvalues";
foreach ($extraParams as $param)
{
$key = $param['key'];
$value = $param['value'];
$url .= "&$key=$value";
}
return $url;
}
public function getLieuxUrl(): ?string
{
$userId = $this->getUserId();
$pwkey = $this->getPwkey();
$url = $this->getUrl() . "/xml/exploitation/listelieux.asp" .
"?user=$userId&pwkey=$pwkey";
return $url;
}
public function getUpdateUrl($partialForLang = false): ?string
{
$userId = $this->getUserId();
$pwkey = $this->getPwkey();
$pnames = $this->getPnames();
$pvalues = $this->getPvalues();
$extraParams = $this->getExtraParams();
$defaultParams = [
'lxml' => 'sit_listecomplete',
'latable' => 'SIT_LISTECOMPLETE',
'tscrit' => 'Y',
'tshor' => 'Y',
'leshoraires' => '01/01/2000|@+36000',
'lescouplages' => 'Y',
'tousprods' => 'Y',
'marquages' => '0,3'
];
if($partialForLang) {
$defaultParams = [
'lxml' => 'sit_listecomplete',
'latable' => 'SIT_LISTECOMPLETE',
'tscrit' => 'Y',
'tousprods' => 'Y',
'marquages' => '0,3'
];
}
$url = $this->getUrl() . "/xml/exploitation/listeproduits.asp?user=$userId&pwkey=$pwkey&pnames=$pnames&pvalues=$pvalues";
/*
"?lxml=sit_listecomplete&latable=SIT_LISTECOMPLETE&tscrit=Y&tshor=Y" .
"&leshoraires=01/01/2000|@+36000&lescouplages=Y&tousprods=Y&marquages=0,3" .
*/
foreach ($extraParams as $param)
{
// Pour ne pas mettre le paramèrte en double dans l'URL
if(isset($defaultParams[$param['key']])) {
unset($defaultParams[$param['key']]);
}
$key = $param['key'];
$value = $param['value'];
$url .= "&$key=$value";
}
foreach($defaultParams as $key => $value) {
$url .= "&$key=$value";
}
return $url;
}
public function getCriterionUrl($lang = 'fr'): ?string
{
$userId = $this->getUserId();
$pwkey = $this->getPwkey();
$url = $this->getUrl() . "/xml/exploitation/listecrit.asp" .
"?tousprods=Y&marquages=0,3" .
"&user=$userId&pwkey=$pwkey";
if ($lang != 'fr') {
$url .= "&schema=WEBACCESS_" . strtoupper($lang);
}
return $url;
}
public function getNomenclatureUrl($lang = 'fr'): ?string
{
$userId = $this->getUserId();
$pwkey = $this->getPwkey();
$url = $this->getUrl() . "/xml/exploitation/listenomenc.asp" .
"?tousprods=Y&marquages=0,3" .
"&user=$userId&pwkey=$pwkey";
if ($lang != 'fr') {
$url .= "&schema=WEBACCESS_" . strtoupper($lang);
}
return $url;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdateLimit(): ?int
{
return $this->updateLimit;
}
public function setUpdateLimit(int $updateLimit): self
{
$this->updateLimit = $updateLimit;
return $this;
}
public function getTotalLimit(): ?int
{
return $this->totalLimit;
}
public function setTotalLimit(int $totalLimit): self
{
$this->totalLimit = $totalLimit;
return $this;
}
public function getOrdre(): ?int
{
return $this->ordre;
}
public function setOrdre(int $ordre): self
{
$this->ordre = $ordre;
return $this;
}
}