Sindbad~EG File Manager
<?php
namespace O2switch\CpanelLib\DataEntity;
class ApiVhost
{
/**
* @var string
*/
private $mainDomain;
/**
* @var string
*/
private $domainAliases;
/**
* @var string
*/
private $originalBackendIp;
/**
* @var string
*/
private $cpUser;
/**
* @var string
*/
private $isSslAvailable;
/**
* @var string
*/
private $proxyPassPort;
/**
* @var string
*/
private $proxyPassIp;
/**
* @var string
*/
private $templateName;
/**
* @var string
*/
private $listenToIp;
/**
* @var string
*/
private $listenToPort;
/**
* @var string
*/
private $listenToSslPort;
/**
* @var string
*/
private $proxyPassProtocol;
/**
* @var string
*/
private $sslKeyFile;
/**
* @var string|null
*/
private $sslCrtFile;
/**
* @var string|null
*/
private $sslCaBundleFile;
/**
* @var string|null
*/
private $proxyPassSslProtocol;
/**
* @var string|null
*/
private $proxyPassSslIp;
/**
* @var string|null
*/
private $proxyPassSslPort;
/**
* @var array|null
*/
private $additionalsParams = null;
public function __construct(?array $data = null){
$this->setIsSslAvailable(false);
$this->setFromArray($data);
}
/**
* Used to cast the object to an array, the API is using array in the low-level code.
* @return array
*/
public function toArray() : array {
$r = array_filter(get_object_vars($this), function($e){
return !is_null($e);
}); // Dont pass null value, is cause trouble with the hash calculation.
ksort($r);
return $r;
}
public function setFromArray(?array $data) : ApiVhost {
if(!is_array($data)){
return $this;
}
foreach($data as $k => $v){
$setter = 'set' . ucfirst($k);
if(in_array($k, ['domainAliases'])){
continue;
}
if(method_exists($this, $setter) && !is_null($v)){
$this->{$setter}($v);
}
}
if(isset($data['mainDomain'])){
$this->setDomainAliases('www.' . $data['mainDomain']);
}
return $this;
}
/**
* Shortcut. Will set all the domain/ip/cpuser/template stuff from the IpxtenderForm object.
* @param \App\DataEntity\IpxtenderForm $data
* @return ApiVhost
*/
public function setIpxtenderFormConfiguration(\App\DataEntity\IpxtenderForm $data) : ApiVhost{
$this->setMainDomain($data->getDomain());
$this->setDomainAliases('www.' . $data->getDomain());
$this->setTemplateName($data->getTemplateName());
$this->setCpUser($data->getCpUser());
return $this;
}
/**
* Shortcut. Will set all the proxyPass stuff from the ProxyPassInfo object.
* @param ProxyPassInfo $proxyPassInfo
* @return $this
*/
public function setProxyPassConfiguration(ProxyPassInfo $proxyPassInfo): ApiVhost{
foreach(get_class_methods($proxyPassInfo) as $method) {
if (strpos($method, 'get') !== 0) {
continue;
}
$setter = substr_replace($method, 's', 0,1);
if (method_exists($this, $setter)) {
$this->$setter( $proxyPassInfo->$method() );
}
}
return $this;
}
/**
* Short cut. Set the SSL from the SSL array returned by the detectAndGetSsl() helper.
* @param array|null $ssl
* @return $this
*/
public function setSslConfiguration(?array $ssl) : ApiVhost {
if(is_null($ssl)){
$this->setIsSslAvailable(false);
}
if(isset($ssl['certificate'], $ssl['key']) && !empty($ssl['certificate']) && !empty($ssl['key'])){
$this
->setIsSslAvailable(true)
->setSslCrtFile($ssl['certificate'])
->setSslKeyFile($ssl['key'])
;
}
if(isset($ssl['cabundle']) && !empty($ssl['cabundle'])){
$this->setSslCaBundleFile($ssl['cabundle']);
}
return $this;
}
/**
* @return string
*/
public function getMainDomain(): string
{
return $this->mainDomain;
}
/**
* @param string $mainDomain
* @return ApiVhost
*/
public function setMainDomain(string $mainDomain): ApiVhost
{
$this->mainDomain = $mainDomain;
return $this;
}
/**
* @return string
*/
public function getDomainAliases(): string
{
return $this->domainAliases;
}
/**
* @param string $domainAliases
* @return ApiVhost
*/
public function setDomainAliases(string $domainAliases): ApiVhost
{
$this->domainAliases = $domainAliases;
return $this;
}
/**
* @return string
*/
public function getOriginalBackendIp(): string
{
return $this->originalBackendIp;
}
/**
* @param string $originalBackendIp
* @return ApiVhost
*/
public function setOriginalBackendIp(string $originalBackendIp): ApiVhost
{
$this->originalBackendIp = $originalBackendIp;
return $this;
}
/**
* @return string
*/
public function getCpUser(): string
{
return $this->cpUser;
}
/**
* @param string $cpUser
* @return ApiVhost
*/
public function setCpUser(string $cpUser): ApiVhost
{
$this->cpUser = $cpUser;
return $this;
}
/**
* @return string
*/
public function getIsSslAvailable(): string
{
return $this->isSslAvailable;
}
/**
* @param string|bool $isSslAvailable
* @return ApiVhost
*/
public function setIsSslAvailable($isSslAvailable): ApiVhost
{
$this->isSslAvailable = ($isSslAvailable === true || (int) $isSslAvailable === 1) ? '1' : '0';
return $this;
}
/**
* @return string
*/
public function getProxyPassPort(): string
{
return $this->proxyPassPort;
}
/**
* @param string $proxyPassPort
* @return ApiVhost
*/
public function setProxyPassPort(string $proxyPassPort): ApiVhost
{
$this->proxyPassPort = $proxyPassPort;
return $this;
}
/**
* @return string
*/
public function getProxyPassIp(): string
{
return $this->proxyPassIp;
}
/**
* @param string $proxyPassIp
* @return ApiVhost
*/
public function setProxyPassIp(string $proxyPassIp): ApiVhost
{
$this->proxyPassIp = $proxyPassIp;
return $this;
}
/**
* @return string
*/
public function getTemplateName(): string
{
return $this->templateName;
}
/**
* @param string $templateName
* @return ApiVhost
*/
public function setTemplateName(string $templateName): ApiVhost
{
$this->templateName = $templateName;
return $this;
}
/**
* @return string
*/
public function getListenToIp(): string
{
return $this->listenToIp;
}
/**
* @param string $listenToIp
* @return ApiVhost
*/
public function setListenToIp(string $listenToIp): ApiVhost
{
$this->listenToIp = $listenToIp;
return $this;
}
/**
* @return string
*/
public function getListenToPort(): string
{
return $this->listenToPort;
}
/**
* @param string $listenToPort
* @return ApiVhost
*/
public function setListenToPort(string $listenToPort): ApiVhost
{
$this->listenToPort = $listenToPort;
return $this;
}
/**
* @return string
*/
public function getListenToSslPort(): string
{
return $this->listenToSslPort;
}
/**
* @param string $listenToSslPort
* @return ApiVhost
*/
public function setListenToSslPort(string $listenToSslPort): ApiVhost
{
$this->listenToSslPort = $listenToSslPort;
return $this;
}
/**
* @return string
*/
public function getProxyPassProtocol(): string
{
return $this->proxyPassProtocol;
}
/**
* @param string $proxyPassProtocol
* @return ApiVhost
*/
public function setProxyPassProtocol(string $proxyPassProtocol): ApiVhost
{
$this->proxyPassProtocol = $proxyPassProtocol;
return $this;
}
/**
* @return string
*/
public function getSslKeyFile(): string
{
return $this->sslKeyFile;
}
/**
* @param string|null $sslKeyFile
* @return ApiVhost
*/
public function setSslKeyFile(?string $sslKeyFile): ApiVhost
{
$this->sslKeyFile = $sslKeyFile;
return $this;
}
/**
* @return string|null
*/
public function getSslCrtFile(): ?string
{
return $this->sslCrtFile;
}
/**
* @param string|null $sslCrtFile
* @return ApiVhost
*/
public function setSslCrtFile(?string $sslCrtFile): ApiVhost
{
$this->sslCrtFile = $sslCrtFile;
return $this;
}
/**
* @return string|null
*/
public function getSslCaBundleFile(): ?string
{
return $this->sslCaBundleFile;
}
/**
* @param string|null $sslCaBundleFile
* @return ApiVhost
*/
public function setSslCaBundleFile(?string $sslCaBundleFile): ApiVhost
{
$this->sslCaBundleFile = $sslCaBundleFile;
return $this;
}
/**
* @return string|null
*/
public function getProxyPassSslProtocol(): ?string
{
return $this->proxyPassSslProtocol;
}
/**
* @param string|null $proxyPassSslProtocol
* @return ApiVhost
*/
public function setProxyPassSslProtocol(?string $proxyPassSslProtocol): ApiVhost
{
$this->proxyPassSslProtocol = $proxyPassSslProtocol;
return $this;
}
/**
* @return string|null
*/
public function getProxyPassSslIp(): ?string
{
return $this->proxyPassSslIp;
}
/**
* @param string|null $proxyPassSslIp
* @return ApiVhost
*/
public function setProxyPassSslIp(?string $proxyPassSslIp): ApiVhost
{
$this->proxyPassSslIp = $proxyPassSslIp;
return $this;
}
/**
* @return string|null
*/
public function getProxyPassSslPort(): ?string
{
return $this->proxyPassSslPort;
}
/**
* @param string|null $proxyPassSslPort
* @return ApiVhost
*/
public function setProxyPassSslPort(?string $proxyPassSslPort): ApiVhost
{
$this->proxyPassSslPort = $proxyPassSslPort;
return $this;
}
/**
* @return array|null
*/
public function getAdditionalsParams(): ?array
{
return $this->additionalsParams;
}
/**
* @param array|null $additionalsParams
* @return ApiVhost
*/
public function setAdditionalsParams(?array $additionalsParams): ApiVhost
{
$this->additionalsParams = $additionalsParams;
return $this;
}
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists