Skip to content

Commit

Permalink
Merge pull request #8 from cultuurnet/feature/III-578
Browse files Browse the repository at this point in the history
III-578: Move common cdbxml item attributes to Base class
  • Loading branch information
cyberwolf committed Jan 6, 2016
2 parents 7d45b12 + edef4ad commit 661d9ed
Show file tree
Hide file tree
Showing 8 changed files with 1,579 additions and 1,305 deletions.
213 changes: 60 additions & 153 deletions lib/CultureFeed/Cdb/Item/Actor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,145 +4,127 @@
* @class
* Representation of an actor on the culturefeed.
*/
class CultureFeed_Cdb_Item_Actor extends CultureFeed_Cdb_Item_Base implements CultureFeed_Cdb_IElement {
class CultureFeed_Cdb_Item_Actor extends CultureFeed_Cdb_Item_Base implements CultureFeed_Cdb_IElement
{

/**
* Is the actor object centrally guarded for uniqueness
* @var bool
*/
protected $asset;

/**
* @var CultureFeed_Cdb_Data_ActorDetailList
*/
protected $details;

/**
* Contact info for an actor.
*
* @var CultureFeed_Cdb_Data_ContactInfo
*/
protected $contactInfo;

/**
* @var CultureFeed_Cdb_Data_ActorDetailList
*/
protected $details;

/**
* Week scheme for the opening times from the actor.
* @var CultureFeed_Cdb_Data_Calendar_WeekScheme
*/
protected $weekScheme;

/**
* @var string
* Construct the actor.
*/
protected $availableFrom;
public function __construct()
{
$this->details = new CultureFeed_Cdb_Data_ActorDetailList();
}

/**
* @var string
* @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement)
* @throws CultureFeed_Cdb_ParseException
* @return CultureFeed_Cdb_Item_Actor
*/
protected $availableTo;
public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
{
if (empty($xmlElement->categories)) {
throw new CultureFeed_Cdb_ParseException('Categories missing for actor element');
}

/**
* @var string
*/
protected $createdBy;
if (empty($xmlElement->actordetails)) {
throw new CultureFeed_Cdb_ParseException('Actordetails missing for actor element');
}

/**
* @var string
*/
protected $creationDate;
$actor = new self();

/**
* @var string
*/
protected $owner;
CultureFeed_Cdb_Item_Base::parseCommonAttributes($actor, $xmlElement);

/**
* Construct the actor.
*/
public function __construct() {
$this->details = new CultureFeed_Cdb_Data_ActorDetailList();
$actor->setDetails(CultureFeed_Cdb_Data_ActorDetailList::parseFromCdbXml($xmlElement->actordetails));

// Set categories
$actor->setCategories(CultureFeed_Cdb_Data_CategoryList::parseFromCdbXml($xmlElement->categories));

// Set contact information.
if (!empty($xmlElement->contactinfo)) {
$actor->setContactInfo(CultureFeed_Cdb_Data_ContactInfo::parseFromCdbXml($xmlElement->contactinfo));
}

// Set the keywords.
self::parseKeywords($xmlElement, $actor);

// Set the weekscheme.
if (!empty($xmlElement->weekscheme)) {
$actor->setWeekScheme(CultureFeed_Cdb_Data_Calendar_Weekscheme::parseFromCdbXml($xmlElement->weekscheme));
}

return $actor;
}

/**
* Get the contact info of this actor.
*/
public function getContactInfo() {
public function getContactInfo()
{
return $this->contactInfo;
}

/**
* Get the weekscheme of this actor.
*/
public function getWeekScheme() {
return $this->weekScheme;
}

/**
* Set the contact info of this contact.
* @param CultureFeed_Cdb_Data_Calendar $contactInfo
* Contact info to set.
*/
public function setContactInfo(CultureFeed_Cdb_Data_ContactInfo $contactInfo) {
public function setContactInfo(CultureFeed_Cdb_Data_ContactInfo $contactInfo)
{
$this->contactInfo = $contactInfo;
}

/**
* Get the weekscheme of this actor.
*/
public function setWeekScheme(CultureFeed_Cdb_Data_Calendar_Weekscheme $weekScheme) {
$this->weekScheme = $weekScheme;
}

public function setAvailableFrom($value) {
$this->availableFrom = $value;
}

public function getAvailableFrom() {
return $this->availableFrom;
}

public function setAvailableTo($value) {
$this->availableTo = $value;
}

public function getAvailableTo() {
return $this->availableTo;
}

public function setCreatedBy($author) {
$this->createdBy = $author;
}

public function getCreatedBy() {
return $this->createdBy;
}

public function setCreationDate($value) {
$this->creationDate = $value;
}

public function getCreationDate() {
return $this->creationDate;
}

public function getOwner() {
return $this->owner;
public function getWeekScheme()
{
return $this->weekScheme;
}

public function setOwner($owner) {
$this->owner = $owner;
/**
* Get the weekscheme of this actor.
*/
public function setWeekScheme(CultureFeed_Cdb_Data_Calendar_Weekscheme $weekScheme)
{
$this->weekScheme = $weekScheme;
}

/**
* Appends the current object to the passed DOM tree.
*
* @param DOMElement $element
* The DOM tree to append to.
* @param string $cdbScheme
* @param string $cdbScheme
* The cdb schema version.
*
* @see CultureFeed_Cdb_IElement::appendToDOM()
*/
public function appendToDOM(DOMElement $element, $cdbScheme = '3.2') {
public function appendToDOM(DOMElement $element, $cdbScheme = '3.2')
{

$dom = $element->ownerDocument;

Expand Down Expand Up @@ -181,79 +163,4 @@ public function appendToDOM(DOMElement $element, $cdbScheme = '3.2') {
$element->appendChild($actorElement);

}

/**
* @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement)
* @return CultureFeed_Cdb_Item_Actor
*/
public static function parseFromCdbXml(SimpleXMLElement $xmlElement) {

if (empty($xmlElement->categories)) {
throw new CultureFeed_Cdb_ParseException('Categories missing for actor element');
}

if (empty($xmlElement->actordetails)) {
throw new CultureFeed_Cdb_ParseException('Actordetails missing for actor element');
}

$actor = new self();

$actor_attributes = $xmlElement->attributes();

if (isset($actor_attributes['cdbid'])) {
$actor->setCdbId((string)$actor_attributes['cdbid']);
}

if (isset($actor_attributes['externalid'])) {
$actor->setExternalId((string)$actor_attributes['externalid']);
}

if (isset($actor_attributes['availablefrom'])) {
$actor->setAvailableFrom((string)$actor_attributes['availablefrom']);
}

if (isset($actor_attributes['availableto'])) {
$actor->setAvailableTo((string)$actor_attributes['availableto']);
}

if (isset($actor_attributes['createdby'])) {
$actor->setCreatedBy((string)$actor_attributes['createdby']);
}

if (isset($actor_attributes['creationdate'])) {
$actor->setCreationDate((string)$actor_attributes['creationdate']);
}

if (isset($actor_attributes['lastupdated'])) {
$actor->setLastUpdated((string)$actor_attributes['lastupdated']);
}

if (isset($actor_attributes['lastupdatedby'])) {
$actor->setLastUpdatedBy((string)$actor_attributes['lastupdatedby']);
}

if (isset($actor_attributes['owner'])) {
$actor->setOwner((string)$actor_attributes['owner']);
}

$actor->setDetails(CultureFeed_Cdb_Data_ActorDetailList::parseFromCdbXml($xmlElement->actordetails));

// Set categories
$actor->setCategories(CultureFeed_Cdb_Data_CategoryList::parseFromCdbXml($xmlElement->categories));

// Set contact information.
if (!empty($xmlElement->contactinfo)) {
$actor->setContactInfo(CultureFeed_Cdb_Data_ContactInfo::parseFromCdbXml($xmlElement->contactinfo));
}

// Set the keywords.
self::parseKeywords($xmlElement, $actor);

// Set the weekscheme.
if (!empty($xmlElement->weekscheme)) {
$actor->setWeekScheme(CultureFeed_Cdb_Data_Calendar_Weekscheme::parseFromCdbXml($xmlElement->weekscheme));
}

return $actor;
}
}
Loading

0 comments on commit 661d9ed

Please sign in to comment.