Skip to content

Improve website settings and get #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev-2112
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
450 changes: 447 additions & 3 deletions samples/BucketWebsite.php

Large diffs are not rendered by default.

122 changes: 122 additions & 0 deletions src/OSS/Model/WebsiteCondition.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php

namespace OSS\Model;

use OSS\Core\OssException;

/**
* Class WebsiteCondition
* @package OSS\Model
* @link https://help.aliyun.com/document_detail/31970.html
*/
class WebsiteCondition {

/**
* @var string
*/
private $keyPrefixEquals;

/**
* @var int
*/
private $httpErrorCodeReturnedEquals;

/**
* @var WebsiteIncludeHeader[]
*/
private $includeHeader;

/**
* @var string
*/
private $keySuffixEquals;


const OSS_MAX_HEADER = 10;

/**
* @return string
*/
public function getHttpErrorCodeReturnedEquals(){
return $this->httpErrorCodeReturnedEquals;
}

/**
* @param $httpErrorCodeReturnedEquals int
*/
public function setHttpErrorCodeReturnedEquals($httpErrorCodeReturnedEquals){
$this->httpErrorCodeReturnedEquals = $httpErrorCodeReturnedEquals;
}

/**
* @return string
*/
public function getKeyPrefixEquals(){
return $this->keyPrefixEquals;
}

/**
* @param $keyPrefixEquals string
*/
public function setKeyPrefixEquals($keyPrefixEquals){
$this->keyPrefixEquals = $keyPrefixEquals;
}

/**
* @return string
*/
public function getKeySuffixEquals(){
return $this->keySuffixEquals;
}


/**
* @param $keySuffixEquals string
*/
public function setKeySuffixEquals($keySuffixEquals){
$this->keySuffixEquals = $keySuffixEquals;
}

/**
* @return WebsiteIncludeHeader[]
*/
public function getIncludeHeader(){
return $this->includeHeader;
}


/**
* @param $includeHeaders WebsiteIncludeHeader
* @throws OssException
*/
public function addIncludeHeader($includeHeaders){
if (isset($this->includeHeader) && count($this->includeHeader) >= self::OSS_MAX_HEADER) {
throw new OssException(
"num of include header in the config exceeds : " . strval(self::OSS_MAX_HEADER));
}
$this->includeHeader[] = $includeHeaders;
}

/**
* @param \SimpleXMLElement $xmlCondition
*/
public function appendToXml(&$xmlCondition)
{
if (isset($this->keyPrefixEquals)){
$xmlCondition->addChild('KeyPrefixEquals', $this->keyPrefixEquals);
}
if (isset($this->httpErrorCodeReturnedEquals)){
$xmlCondition->addChild('HttpErrorCodeReturnedEquals', $this->httpErrorCodeReturnedEquals);
}
if (isset($this->includeHeader)){
foreach ($this->includeHeader as $includeHeader){
$xmlIncludeHeader = $xmlCondition->addChild('IncludeHeader');
$includeHeader->appendToXml($xmlIncludeHeader);
}
}
if (isset($this->keySuffixEquals)){
$xmlCondition->addChild('KeySuffixEquals', $this->keySuffixEquals);
}
}

}
Loading