Sindbad~EG File Manager
<?php
namespace App\Entity\Redis;
/**
* In memory equivalent of a Vhost for OpenResty
*/
class VhostEntity implements RedisEntityInterface
{
private $key;
private $mainDomain;
private $isSslAvailable;
private $sslKey;
private $sslCrt;
private $sslCaBundle;
private $listenToIp;
private $proxyPassProtocol = "http://";
private $proxyPassSslProtocol = "https://";
private $proxyPassIp;
private $proxyPassSslIp;
private $proxyPassPort = 8081;
private $proxyPassSslPort = 4430;
private $rawSslContent = '';
private $rawServerAlias;
private $ocsp;
private $additionalsParams = null;
public function createFromArray(string $key, array $data) : VhostEntity {
$this->setKey($key);
$this->setMainDomain($data['serverName']);
$this->setIsSslAvailable(isset($data['sslCertificateFilepath']));
$this->setSslKey($data['sslCertificateFilepath'] ?? null);
$this->setSslCrt($data['sslCertificateFilepath'] ?? null);
$this->setSslCaBundle($data['sslCertificateFilepath'] ?? null);
$this->setListenToIp($data['ip'] ?? null);
$this->setProxyPassProtocol($data['proxyPassProtocol'] ?? 'http');
$this->setProxyPassSslProtocol($data['proxyPassSslProtocol'] ?? 'https');
$this->setProxyPassIp($data['proxyPassIp'] ?? $data['ip'] ?? '127.0.0.1');
$this->setProxyPassSslIp($data['proxyPassSslIp'] ?? $this->getProxyPassIp());
$this->setProxyPassPort($data['proxyPassPort'] ?? '8081');
$this->setProxyPassSslPort($data['proxyPassSslPort'] ?? '4430');
$this->setRawSslContent($data['rawSslContent'] ?? null);
$this->setOcsp($data['ocsp'] ?? null);
$this->setAdditionalsParams(
isset($data['additionalsParams']) && !empty($data['additionalsParams'])
? $data['additionalsParams']
: null
);
// TODO : custom customer conf / option
return $this;
}
/**
* @return string
*/
public function getRawSslContent(): ?string
{
return $this->rawSslContent;
}
/**
* @param string $rawSslContent
* @return VhostEntity
*/
public function setRawSslContent(?string $rawSslContent): VhostEntity
{
$this->rawSslContent = $rawSslContent;
return $this;
}
/**
* @return string
*/
public function getKey() : string
{
return $this->key;
}
/**
* @return string
*/
public function setKey(string $key) : VhostEntity
{
$this->key = $key;
return $this;
}
/**
* @return mixed
*/
public function getMainDomain() : string
{
return $this->mainDomain;
}
/**
* @param mixed $mainDomain
* @return VhostEntity
*/
public function setMainDomain($mainDomain) : VhostEntity
{
$this->mainDomain = $mainDomain;
return $this;
}
/**
* @return mixed
*/
public function getisSslAvailable()
{
return $this->isSslAvailable;
}
/**
* @param mixed $isSslAvailable
* @return VhostEntity
*/
public function setIsSslAvailable($isSslAvailable) : VhostEntity
{
$this->isSslAvailable = $isSslAvailable;
return $this;
}
/**
* @return mixed
*/
public function getSslKey() : ?string
{
return $this->sslKey;
}
/**
* @param mixed $sslKey
* @return VhostEntity
*/
public function setSslKey($sslKey) : VhostEntity
{
$this->sslKey = $sslKey;
return $this;
}
/**
* @return mixed
*/
public function getSslCrt() : ?string
{
return $this->sslCrt;
}
/**
* @param mixed $sslCrt
* @return VhostEntity
*/
public function setSslCrt($sslCrt) : VhostEntity
{
$this->sslCrt = $sslCrt;
return $this;
}
/**
* @return mixed
*/
public function getSslCaBundle() : ?string
{
return $this->sslCaBundle;
}
/**
* @param mixed $sslCaBundle
* @return VhostEntity
*/
public function setSslCaBundle($sslCaBundle) : VhostEntity
{
$this->sslCaBundle = $sslCaBundle;
return $this;
}
/**
* @return mixed
*/
public function getListenToIp() : ?string
{
return $this->listenToIp;
}
/**
* @param mixed $listenToIp
* @return VhostEntity
*/
public function setListenToIp($listenToIp) : VhostEntity
{
$this->listenToIp = $listenToIp;
return $this;
}
/**
* @return string
*/
public function getProxyPassProtocol() : ?string
{
return $this->proxyPassProtocol;
}
/**
* @param string $proxyPassProtocol
* @return VhostEntity
*/
public function setProxyPassProtocol($proxyPassProtocol) : VhostEntity
{
$this->proxyPassProtocol = $proxyPassProtocol;
return $this;
}
/**
* @return string
*/
public function getProxyPassSslProtocol() : ?string
{
return $this->proxyPassSslProtocol;
}
/**
* @param string $proxyPassSslProtocol
* @return VhostEntity
*/
public function setProxyPassSslProtocol($proxyPassSslProtocol) : VhostEntity
{
$this->proxyPassSslProtocol = $proxyPassSslProtocol;
return $this;
}
/**
* @return mixed
*/
public function getProxyPassIp() : ?string
{
return $this->proxyPassIp;
}
/**
* @param mixed $proxyPassIp
* @return VhostEntity
*/
public function setProxyPassIp($proxyPassIp) : VhostEntity
{
$this->proxyPassIp = $proxyPassIp;
return $this;
}
/**
* @return mixed
*/
public function getProxyPassSslIp() : ?string
{
return $this->proxyPassSslIp;
}
/**
* @param mixed $proxyPassSslIp
* @return VhostEntity
*/
public function setProxyPassSslIp($proxyPassSslIp) : VhostEntity
{
$this->proxyPassSslIp = $proxyPassSslIp;
return $this;
}
/**
* @return int
*/
public function getProxyPassPort() : int
{
return $this->proxyPassPort;
}
/**
* @param int $proxyPassPort
* @return VhostEntity
*/
public function setProxyPassPort($proxyPassPort) : VhostEntity
{
$this->proxyPassPort = (int) $proxyPassPort;
return $this;
}
/**
* @return int
*/
public function getProxyPassSslPort() : int
{
return $this->proxyPassSslPort;
}
/**
* @param int $proxyPassSslPort
* @return VhostEntity
*/
public function setProxyPassSslPort($proxyPassSslPort) : VhostEntity
{
$this->proxyPassSslPort = (int) $proxyPassSslPort;
return $this;
}
/**
* @return mixed
*/
public function getRawServerAlias()
{
return $this->rawServerAlias;
}
/**
* @param mixed $rawServerAlias
* @return VhostEntity
*/
public function setRawServerAlias($rawServerAlias)
{
$this->rawServerAlias = $rawServerAlias;
return $this;
}
/**
* @return mixed
*/
public function getAdditionalsParams() : ?string
{
return $this->additionalsParams;
}
/**
* @param mixed $additionalsParams
*
* @return Template
*/
public function setAdditionalsParams($additionalsParams) : VhostEntity
{
if(is_null($additionalsParams)){
$this->additionalsParams = null;
} elseif (is_array($additionalsParams)) {
$this->additionalsParams = json_encode($additionalsParams);
} elseif (is_string($additionalsParams)) {
$this->additionalsParams = !empty($additionalsParams) ? json_encode($additionalsParams) : null;
} else {
throw new \UnexpectedValueException("additionalsParams must be an array or a string");
}
return $this;
}
/**
* @return string|null
*/
public function getOcsp(): ?string
{
return $this->ocsp;
}
/**
* @param string $ocsp
* @return VhostEntity
*/
public function setOcsp(?string $ocsp): VhostEntity
{
$this->ocsp = $ocsp;
return $this;
}
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists