Skip to content

Commit

Permalink
Merge 0470e2d into 4f6839d
Browse files Browse the repository at this point in the history
  • Loading branch information
rockuw committed Mar 18, 2016
2 parents 4f6839d + 0470e2d commit 3526443
Show file tree
Hide file tree
Showing 10 changed files with 821 additions and 19 deletions.
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<testsuite name="FunctionTest">
<directory>./tests</directory>
<exclude>./tests/OSS/Tests/BucketCnameTest.php</exclude>
<exclude>./tests/OSS/Tests/BucketLiveChannelTest.php</exclude>
</testsuite>
</testsuites>
</phpunit>
135 changes: 135 additions & 0 deletions src/OSS/Model/LiveChannelConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?php

namespace OSS\Model;


use OSS\Core\OssException;

/**
* Class LiveChannelConfig
* @package OSS\Model
*
* TODO: fix link
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
*/
class LiveChannelConfig implements XmlConfig
{
private $id;
private $description;
private $status;
private $type;
private $fragDuration;
private $fragCount;
private $playListName;

public function __construct($option = array())
{
if (isset($option['id'])) {
$this->id = $option['id'];
}
if (isset($option['description'])) {
$this->description = $option['description'];
}
if (isset($option['status'])) {
$this->status = $option['status'];
}
if (isset($option['type'])) {
$this->type = $option['type'];
}
if (isset($option['fragDuration'])) {
$this->fragDuration = $option['fragDuration'];
}
if (isset($option['fragCount'])) {
$this->fragCount = $option['fragCount'];
}
if (isset($option['playListName'])) {
$this->playListName = $option['playListName'];
}
}

public function getId()
{
return $this->id;
}

public function getDescription()
{
return $this->description;
}

public function getStatus()
{
return $this->status;
}

public function getType()
{
return $this->type;
}

public function getFragDuration()
{
return $this->fragDuration;
}

public function getFragCount()
{
return $this->fragCount;
}

public function getPlayListName()
{
return $this->playListName;
}

public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
$this->description = strval($xml->Description);
$this->status = strval($xml->Status);
$target = $xml->Target;
$this->type = strval($target->Type);
$this->fragDuration = intval($target->FragDuration);
$this->fragCount = intval($target->FragCount);
$this->playListName = strval($target->PlayListName);
}

public function serializeToXml()
{
$strXml = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<BucketLiveChannelConfiguration>
</BucketLiveChannelConfiguration>
EOF;
$xml = new \SimpleXMLElement($strXml);
if (isset($this->description)) {
$xml->addChild('Description', $this->description);
}

if (isset($this->status)) {
$xml->addChild('Status', $this->status);
}

$node = $xml->addChild('Target');
$node->addChild('Type', $this->type);

if (isset($this->fragDuration)) {
$node->addChild('FragDuration', $this->fragDuration);
}

if (isset($this->fragCount)) {
$node->addChild('FragCount', $this->fragCount);
}

if (isset($this->playListName)) {
$node->addChild('PlayListName', $this->playListName);
}

return $xml->asXML();
}

public function __toString()
{
return $this->serializeToXml();
}
}
107 changes: 107 additions & 0 deletions src/OSS/Model/LiveChannelInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

namespace OSS\Model;
/**
* Class LiveChannelInfo
* @package OSS\Model
*
*/
class LiveChannelInfo implements XmlConfig
{
private $id;
private $description;
private $publishUrls;
private $playUrls;
private $status;
private $lastModified;

public function __construct($id = null, $description = null)
{
$this->id = $id;
$this->description = $description;
$this->publishUrls = array();
$this->playUrls = array();
}

public function getId()
{
return $this->id;
}

public function setId($id)
{
$this->id = $id;
}

public function getPublishUrls()
{
return $this->publishUrls;
}

public function getPlayUrls()
{
return $this->playUrls;
}

public function getStatus()
{
return $this->status;
}

public function getLastModified()
{
return $this->lastModified;
}

public function getDescription()
{
return $this->description;
}

public function setDescription($description)
{
$this->description = $description;
}

public function parseFromXmlNode($xml)
{
if (isset($xml->Id)) {
$this->id = strval($xml->Id);
}

if (isset($xml->Description)) {
$this->description = strval($xml->Description);
}

if (isset($xml->Status)) {
$this->status = strval($xml->Status);
}

if (isset($xml->LastModified)) {
$this->lastModified = strval($xml->LastModified);
}

if (isset($xml->PublishUrls)) {
foreach ($xml->PublishUrls as $url) {
$this->publishUrls[] = strval($url->Url);
}
}

if (isset($xml->PlayUrls)) {
foreach ($xml->PlayUrls as $url) {
$this->playUrls[] = strval($url->Url);
}
}
}

public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
$this->parseFromXmlNode($xml);
}

public function serializeToXml()
{
throw new OssException("Not implemented.");
}
}
108 changes: 108 additions & 0 deletions src/OSS/Model/LiveChannelListInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php

namespace OSS\Model;

/**
* Class LiveChannelListInfo
*
* ListBucketLiveChannels接口返回数据
*
* TODO fix link
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html
*/
class LiveChannelListInfo implements XmlConfig
{
private $bucketName;
private $prefix;
private $marker;
private $nextMarker;
private $maxKeys;
private $isTruncated;
private $channelList = array();

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

public function setBucketName($name)
{
$this->bucketName = $name;
}

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

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

/**
* @return int
*/
public function getMaxKeys()
{
return $this->maxKeys;
}

/**
* @return mixed
*/
public function getIsTruncated()
{
return $this->isTruncated;
}

/**
* @return LiveChannelInfo[]
*/
public function getChannelList()
{
return $this->channelList;
}

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

public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);

$this->prefix = strval($xml->Prefix);
$this->marker = strval($xml->Marker);
$this->maxKeys = intval($xml->MaxKeys);
$this->isTruncated = (strval($xml->IsTruncated) == 'true');
$this->nextMarker = strval($xml->NextMarker);

if (isset($xml->LiveChannel)) {
foreach ($xml->LiveChannel as $chan) {
$channel = new LiveChannelInfo();
$channel->parseFromXmlNode($chan);
$this->channelList[] = $channel;
}
}
}

public function serializeToXml()
{
throw new OssException("Not implemented.");
}
}

0 comments on commit 3526443

Please sign in to comment.