39 public $archivingDuration;
70 $attributes = array(),
71 $archivingDuration = null,
77 $this->attributes = $attributes;
78 $this->archivingDuration = $archivingDuration;
79 $this->storeOnly = $storeOnly;
80 $this->description = $description;
91 if (isset($xmlElement->id)) $this->
id = (int)$xmlElement->id;
92 if (isset($xmlElement->name)) $this->name = (
string)$xmlElement->name;
93 if (isset($xmlElement->description)) $this->description = (
string)$xmlElement->description;
94 if (isset($xmlElement->archivingDuration)) $this->archivingDuration = (
int)$xmlElement->archivingDuration;
95 if (isset($xmlElement->storeOnly))$this->storeOnly = (
string)$xmlElement->storeOnly;
97 if (isset($xmlElement->attributes)) {
98 $this->attributes = array();
99 foreach ($xmlElement->attributes->children() as $xmlAttribute) {
100 $attribute =
new stdClass();
101 if (isset($xmlAttribute->id)) $attribute->id = (int)$xmlAttribute->id;
102 if (isset($xmlAttribute->name)) $attribute->name = trim((
string)$xmlAttribute->name);
103 if (isset($xmlAttribute->description)) $attribute->description = trim((
string)$xmlAttribute->description);
105 if (isset($xmlAttribute->required)) $attribute->required = (
string)$xmlAttribute->required;
106 array_push($this->attributes, $attribute);
119 if (isset($this->attributes)) {
120 foreach ($this->attributes as $index => $value) {
121 echo $value[
'name'].
"<br />";
122 $attributes .=
"attribute (id=" . $value[
'id'] .
", name=" . $value[
'name'] .
", description=" . ((!empty($value[
'description']))?$value[
'description']:
"") .
", type=" . $value[
'type']->getValue() .
", required=" . (($value[
'required'] ==
true) ?
"true" :
"false") .
"), ";
124 $attributes = rtrim($attributes,
' ');
125 $attributes = rtrim($attributes,
',');
129 return "TransactionType [id=" . $this->
id .
", name=" . $this->name .
", description=" . $this->description .
", archivingDuration=" . $this->archivingDuration .
", storeOnly=" . $this->storeOnly .
", attributes=" . $attributes .
"]";
138 $xml =
new SimpleXMLElement(
"<?xml version=\"1.0\"?><transaction_type></transaction_type>");
141 if (isset($this->
id)) $xml->addChild(
"id", $this->
id);
142 if (isset($this->name)) $xml->addChild(
"name", $this->name);
143 if (isset($this->name)) $xml->addChild(
"description", $this->description);
144 if (isset($this->archivingDuration)) $xml->addChild(
"archivingDuration", $this->archivingDuration);
145 if (isset($this->storeOnly)) $xml->addChild(
"storeOnly", ($this->storeOnly ===
true || $this->storeOnly ===
"true")?
"true":
"false");
147 if (isset($this->attributes) &&
sizeof($this->attributes) > 0) {
149 $attributes = $xml->addChild(
"attributes");
150 foreach ($this->attributes as $index => $value) {
151 $field = $attributes->addChild(
"attribute");
152 if (!empty($value->id)) $field->addChild(
"id", $value->id);
153 if (!empty($value->name)) $field->addChild(
"name", $value->name);
154 if (!empty($value->description)) $field->addChild(
"description", $value->description);
155 if (!empty($value->type)) $field->addChild(
"type", $value->type->getValue());
156 if (!empty($value->required)) $field->addChild(
"required", ($value->required ===
true || $value->required ===
"true") ?
"true" :
"false");
169 $xml = $this->
toXML();
170 return $xml->asXML();
static getDataType($value)
__construct($id=null, $name=null, $attributes=array(), $archivingDuration=null, $storeOnly=false, $description=null)