Maileon PHP client  1.5.0
Easily integrate your PHP application with Maileon.
Contacts.php
1 <?php
2 
8 {
9  private $contacts;
10 
17  function __construct(
18  $contacts = array())
19  {
20  $this->contacts = $contacts;
21  }
22 
28  function addContact($contact)
29  {
30  array_push($this->contacts, $contact);
31  }
32 
37  public function getIterator()
38  {
39  return new ArrayIterator($this->contacts);
40  }
41 
48  function fromXML($xmlElement)
49  {
50  if ($xmlElement->getName() == "contacts") {
51  foreach ($xmlElement->children() as $contactXml) {
52  $contact = new com_maileon_api_contacts_Contact();
53  $contact->fromXML($contactXml);
54  $this->contacts[] = $contact;
55  }
56  }
57  }
58 
65  function toXML()
66  {
67  $xml = new SimpleXMLElement("<?xml version=\"1.0\"?><contacts></contacts>");
68  $contactsDom = dom_import_simplexml($xml);
69 
70  foreach ($this->contacts as $contact) {
71  $contactDom = dom_import_simplexml($contact->toXML(false));
72  $contactsDom->appendChild($contactsDom->ownerDocument->importNode($contactDom, true));
73  }
74 
75  return new SimpleXMLElement($contactsDom->ownerDocument->saveXML());
76  }
77 
84  function toXMLString()
85  {
86  $xml = $this->toXML();
87  return $xml->asXML();
88  }
89 
96  function toString()
97  {
98  $result = "[\n";
99  foreach ($this->contacts as $contact) {
100  $result .= ' ' . $contact->toString() . "\n";
101  }
102  $result .= ']';
103  return $result;
104  }
105 }
__construct($contacts=array())
Definition: Contacts.php:17