gedcomx-php
  • Namespace
  • Class

Namespaces

  • Gedcomx
    • Agent
    • Atom
    • Common
    • Conclusion
    • Extensions
      • FamilySearch
        • Platform
          • Artifacts
          • Discussions
          • Tree
          • Users
        • Rt
        • Types
    • GedcomxFile
    • Links
    • Records
    • Rt
    • Search
    • Source
    • Support
    • Types
    • Util
    • Vocab

Classes

  • Gedcomx\Agent\Address
  • Gedcomx\Agent\Agent
  • Gedcomx\Agent\OnlineAccount
  • Gedcomx\Atom\Category
  • Gedcomx\Atom\CommonAttributes
  • Gedcomx\Atom\Content
  • Gedcomx\Atom\Entry
  • Gedcomx\Atom\ExtensibleElement
  • Gedcomx\Atom\Feed
  • Gedcomx\Atom\Generator
  • Gedcomx\Atom\Person
  • Gedcomx\Common\Attribution
  • Gedcomx\Common\CustomEntity
  • Gedcomx\Common\CustomKeyedItem
  • Gedcomx\Common\EvidenceReference
  • Gedcomx\Common\ExtensibleData
  • Gedcomx\Common\Note
  • Gedcomx\Common\Qualifier
  • Gedcomx\Common\ResourceReference
  • Gedcomx\Common\TextValue
  • Gedcomx\Common\UniqueCustomKeyedItem
  • Gedcomx\Conclusion\Conclusion
  • Gedcomx\Conclusion\DateInfo
  • Gedcomx\Conclusion\DisplayProperties
  • Gedcomx\Conclusion\Document
  • Gedcomx\Conclusion\Event
  • Gedcomx\Conclusion\EventRole
  • Gedcomx\Conclusion\Fact
  • Gedcomx\Conclusion\Gender
  • Gedcomx\Conclusion\Identifier
  • Gedcomx\Conclusion\Name
  • Gedcomx\Conclusion\NameForm
  • Gedcomx\Conclusion\NamePart
  • Gedcomx\Conclusion\Person
  • Gedcomx\Conclusion\PlaceDescription
  • Gedcomx\Conclusion\PlaceDisplayProperties
  • Gedcomx\Conclusion\PlaceReference
  • Gedcomx\Conclusion\Relationship
  • Gedcomx\Conclusion\Subject
  • Gedcomx\Extensions\FamilySearch\Error
  • Gedcomx\Extensions\FamilySearch\FamilySearchPlatform
  • Gedcomx\Extensions\FamilySearch\Feature
  • Gedcomx\Extensions\FamilySearch\HealthConfig
  • Gedcomx\Extensions\FamilySearch\OAuth2
  • Gedcomx\Extensions\FamilySearch\Platform\Artifacts\ArtifactMetadata
  • Gedcomx\Extensions\FamilySearch\Platform\Artifacts\ArtifactType
  • Gedcomx\Extensions\FamilySearch\Platform\Discussions\Comment
  • Gedcomx\Extensions\FamilySearch\Platform\Discussions\Discussion
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeInfo
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeObjectModifier
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeObjectType
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeOperation
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChildAndParentsRelationship
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\DiscussionReference
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MatchInfo
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MatchStatus
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\Merge
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MergeAnalysis
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MergeConflict
  • Gedcomx\Extensions\FamilySearch\Platform\Users\User
  • Gedcomx\Extensions\FamilySearch\Rt\FamilySearchPlatformLocalReferenceResolver
  • Gedcomx\Extensions\FamilySearch\Rt\FamilySearchPlatformModelVisitorBase
  • Gedcomx\Extensions\FamilySearch\Tag
  • Gedcomx\Extensions\FamilySearch\Types\FactType
  • Gedcomx\Gedcomx
  • Gedcomx\GedcomxFile\DefaultJsonSerialization
  • Gedcomx\GedcomxFile\DefaultXMLSerialization
  • Gedcomx\GedcomxFile\GedcomxFile
  • Gedcomx\GedcomxFile\GedcomxFileEntry
  • Gedcomx\GedcomxFile\GedcomxOutput
  • Gedcomx\GedcomxFile\Manifest
  • Gedcomx\GedcomxFile\ManifestAttribute
  • Gedcomx\Links\HypermediaEnabledData
  • Gedcomx\Links\Link
  • Gedcomx\Records\Collection
  • Gedcomx\Records\CollectionContent
  • Gedcomx\Records\Field
  • Gedcomx\Records\FieldDescriptor
  • Gedcomx\Records\FieldValue
  • Gedcomx\Records\FieldValueDescriptor
  • Gedcomx\Records\RecordDescriptor
  • Gedcomx\Records\RecordSet
  • Gedcomx\Records\RecordSetIterator
  • Gedcomx\Rt\GedcomxLocalReferenceResolver
  • Gedcomx\Rt\GedcomxModelVisitorBase
  • Gedcomx\Search\ResultConfidence
  • Gedcomx\Source\CitationField
  • Gedcomx\Source\Coverage
  • Gedcomx\Source\SourceCitation
  • Gedcomx\Source\SourceDescription
  • Gedcomx\Source\SourceReference
  • Gedcomx\Types\ConfidenceLevel
  • Gedcomx\Types\DocumentType
  • Gedcomx\Types\EventRoleType
  • Gedcomx\Types\EventType
  • Gedcomx\Types\FactType
  • Gedcomx\Types\FieldType
  • Gedcomx\Types\FieldValueType
  • Gedcomx\Types\GenderType
  • Gedcomx\Types\IdentifierType
  • Gedcomx\Types\NamePartType
  • Gedcomx\Types\NameType
  • Gedcomx\Types\RecordType
  • Gedcomx\Types\RelationshipType
  • Gedcomx\Types\ResourceType
  • Gedcomx\Util\Collection
  • Gedcomx\Util\Duration
  • Gedcomx\Util\FormalDate
  • Gedcomx\Util\JsonMapper
  • Gedcomx\Util\SimpleDate
  • Gedcomx\Util\XmlMapper
  • Gedcomx\Vocab\VocabElement
  • Gedcomx\Vocab\VocabElementList

Interfaces

  • Gedcomx\Common\Attributable
  • Gedcomx\Common\HasNotes
  • Gedcomx\Conclusion\HasFacts
  • Gedcomx\Extensions\FamilySearch\Rt\FamilySearchPlatformModelVisitor
  • Gedcomx\GedcomxFile\GedcomxEntryDeserializer
  • Gedcomx\GedcomxFile\GedcomxEntrySerializer
  • Gedcomx\Links\SupportsLinks
  • Gedcomx\Records\HasFields
  • Gedcomx\Rt\GedcomxModelVisitor
  • Gedcomx\Source\ReferencesSources
  • Gedcomx\Support\HasJsonKey

Exceptions

  • Gedcomx\GedcomxFile\GedcomxFileException
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 
<?php
/**
 *
 * 
 *
 * Generated by <a href="http://enunciate.codehaus.org">Enunciate</a>.
 *
 */

namespace Gedcomx\Agent;
use Gedcomx\Common\ResourceReference;
use Gedcomx\Common\TextValue;
use Gedcomx\Conclusion\Identifier;
use Gedcomx\Links\HypermediaEnabledData;
use Gedcomx\Rt\GedcomxModelVisitor;

/**
 * An agent, e.g. person, organization, or group. In genealogical research, an agent often
     * takes the role of a contributor.
 */
class Agent extends HypermediaEnabledData
{
    /**
     * The accounts that belong to this person or organization.
     *
     * @var OnlineAccount[]
     */
    private $accounts;

    /**
     * The addresses that belong to this person or organization.
     *
     * @var Address[]
     */
    private $addresses;

    /**
     * The emails that belong to this person or organization.
     *
     * @var ResourceReference[]
     */
    private $emails;

    /**
     * The homepage.
     *
     * @var ResourceReference
     */
    private $homepage;

    /**
     * The list of identifiers for the agent.
     *
     * @var Identifier[]
     */
    private $identifiers;

    /**
     * The list of names for the agent.
     *
     * @var TextValue[]
     */
    private $names;

    /**
     * The &lt;a href=&quot;http://openid.net/&quot;&gt;openid&lt;/a&gt; of the person or organization.
     *
     * @var ResourceReference
     */
    private $openid;

    /**
     * The phones that belong to this person or organization.
     *
     * @var ResourceReference[]
     */
    private $phones;

    /**
     * Constructs a Agent from a (parsed) JSON hash
     *
     * @param mixed $o Either an array (JSON) or an XMLReader.
     *
     * @throws \Exception
     */
    public function __construct($o = null)
    {
        if (is_array($o)) {
            $this->initFromArray($o);
        }
        else if ($o instanceof \XMLReader) {
            $success = true;
            while ($success && $o->nodeType != \XMLReader::ELEMENT) {
                $success = $o->read();
            }
            if ($o->nodeType != \XMLReader::ELEMENT) {
                throw new \Exception("Unable to read XML: no start element found.");
            }

            $this->initFromReader($o);
        }
    }

    /**
     * The accounts that belong to this person or organization.
     *
     * @return OnlineAccount[]
     */
    public function getAccounts()
    {
        return $this->accounts;
    }

    /**
     * The accounts that belong to this person or organization.
     *
     * @param OnlineAccount[] $accounts
     */
    public function setAccounts($accounts)
    {
        $this->accounts = $accounts;
    }
    /**
     * The addresses that belong to this person or organization.
     *
     * @return Address[]
     */
    public function getAddresses()
    {
        return $this->addresses;
    }

    /**
     * The addresses that belong to this person or organization.
     *
     * @param Address[] $addresses
     */
    public function setAddresses($addresses)
    {
        $this->addresses = $addresses;
    }
    /**
     * The emails that belong to this person or organization.
     *
     * @return ResourceReference[]
     */
    public function getEmails()
    {
        return $this->emails;
    }

    /**
     * The emails that belong to this person or organization.
     *
     * @param ResourceReference[] $emails
     */
    public function setEmails($emails)
    {
        $this->emails = $emails;
    }
    /**
     * The homepage.
     *
     * @return ResourceReference
     */
    public function getHomepage()
    {
        return $this->homepage;
    }

    /**
     * The homepage.
     *
     * @param ResourceReference $homepage
     */
    public function setHomepage($homepage)
    {
        $this->homepage = $homepage;
    }
    /**
     * The list of identifiers for the agent.
     *
     * @return Identifier[]
     */
    public function getIdentifiers()
    {
        return $this->identifiers;
    }

    /**
     * The list of identifiers for the agent.
     *
     * @param Identifier[] $identifiers
     */
    public function setIdentifiers($identifiers)
    {
        $this->identifiers = $identifiers;
    }
    /**
     * The list of names for the agent.
     *
     * @return TextValue[]
     */
    public function getNames()
    {
        return $this->names;
    }

    /**
     * The list of names for the agent.
     *
     * @param TextValue[] $names
     */
    public function setNames($names)
    {
        $this->names = $names;
    }
    /**
     * The &lt;a href=&quot;http://openid.net/&quot;&gt;openid&lt;/a&gt; of the person or organization.
     *
     * @return ResourceReference
     */
    public function getOpenid()
    {
        return $this->openid;
    }

    /**
     * The &lt;a href=&quot;http://openid.net/&quot;&gt;openid&lt;/a&gt; of the person or organization.
     *
     * @param ResourceReference $openid
     */
    public function setOpenid($openid)
    {
        $this->openid = $openid;
    }
    /**
     * The phones that belong to this person or organization.
     *
     * @return ResourceReference[]
     */
    public function getPhones()
    {
        return $this->phones;
    }

    /**
     * The phones that belong to this person or organization.
     *
     * @param ResourceReference[] $phones
     */
    public function setPhones($phones)
    {
        $this->phones = $phones;
    }
    /**
     * Returns the associative array for this Agent
     *
     * @return array
     */
    public function toArray()
    {
        $a = parent::toArray();
        if ($this->accounts) {
            $ab = array();
            foreach ($this->accounts as $i => $x) {
                $ab[$i] = $x->toArray();
            }
            $a['accounts'] = $ab;
        }
        if ($this->addresses) {
            $ab = array();
            foreach ($this->addresses as $i => $x) {
                $ab[$i] = $x->toArray();
            }
            $a['addresses'] = $ab;
        }
        if ($this->emails) {
            $ab = array();
            foreach ($this->emails as $i => $x) {
                $ab[$i] = $x->toArray();
            }
            $a['emails'] = $ab;
        }
        if ($this->homepage) {
            $a["homepage"] = $this->homepage->toArray();
        }
        if ($this->identifiers) {
            $ab = array();
            foreach ($this->identifiers as $i => $x) {
                $ab[$i] = array();
                foreach ($x as $j => $y) {
                    $ab[$i][$j] = $y->getValue();
                }
            }
            $a['identifiers'] = $ab;
        }
        if ($this->names) {
            $ab = array();
            foreach ($this->names as $i => $x) {
                $ab[$i] = $x->toArray();
            }
            $a['names'] = $ab;
        }
        if ($this->openid) {
            $a["openid"] = $this->openid->toArray();
        }
        if ($this->phones) {
            $ab = array();
            foreach ($this->phones as $i => $x) {
                $ab[$i] = $x->toArray();
            }
            $a['phones'] = $ab;
        }
        return $a;
    }


    /**
     * Initializes this Agent from an associative array
     *
     * @param array $o
     */
    public function initFromArray(array $o)
    {
        $this->accounts = array();
        if (isset($o['accounts'])) {
            foreach ($o['accounts'] as $i => $x) {
                $this->accounts[$i] = new OnlineAccount($x);
            }
            unset($o['accounts']);
        }
        $this->addresses = array();
        if (isset($o['addresses'])) {
            foreach ($o['addresses'] as $i => $x) {
                $this->addresses[$i] = new Address($x);
            }
            unset($o['addresses']);
        }
        $this->emails = array();
        if (isset($o['emails'])) {
            foreach ($o['emails'] as $i => $x) {
                $this->emails[$i] = new ResourceReference($x);
            }
            unset($o['emails']);
        }
        if (isset($o['homepage'])) {
            $this->homepage = new ResourceReference($o["homepage"]);
            unset($o['homepage']);
        }
        $this->identifiers = array();
        if (isset($o['identifiers'])) {
            foreach ($o['identifiers'] as $i => $x) {
                if (is_array($x)) {
                    $this->identifiers[$i] = array();
                    foreach ($x as $j => $y) {
                        $this->identifiers[$i][$j] = new Identifier();
                        $this->identifiers[$i][$j]->setValue($y);
                    }
                }
                else {
                    $this->identifiers[$i] = new Identifier($x);
                }
            }
            unset($o['identifiers']);
        }
        $this->names = array();
        if (isset($o['names'])) {
            foreach ($o['names'] as $i => $x) {
                $this->names[$i] = new TextValue($x);
            }
            unset($o['names']);
        }
        if (isset($o['openid'])) {
            $this->openid = new ResourceReference($o["openid"]);
            unset($o['openid']);
        }
        $this->phones = array();
        if (isset($o['phones'])) {
            foreach ($o['phones'] as $i => $x) {
                $this->phones[$i] = new ResourceReference($x);
            }
            unset($o['phones']);
        }
        parent::initFromArray($o);
    }

    public function accept(GedcomxModelVisitor $visitor)
    {
        $visitor->visitAgent($this);
    }

    /**
     * Sets a known child element of Agent from an XML reader.
     *
     * @param \XMLReader $xml The reader.
     *
     * @return bool Whether a child element was set.
     */
    protected function setKnownChildElement(\XMLReader $xml) {
        $happened = parent::setKnownChildElement($xml);
        if ($happened) {
          return true;
        }
        else if (($xml->localName == 'account') && ($xml->namespaceURI == 'http://gedcomx.org/v1/')) {
            $child = new OnlineAccount($xml);
            if (!isset($this->accounts)) {
                $this->accounts = array();
            }
            array_push($this->accounts, $child);
            $happened = true;
        }
        else if (($xml->localName == 'address') && ($xml->namespaceURI == 'http://gedcomx.org/v1/')) {
            $child = new Address($xml);
            if (!isset($this->addresses)) {
                $this->addresses = array();
            }
            array_push($this->addresses, $child);
            $happened = true;
        }
        else if (($xml->localName == 'email') && ($xml->namespaceURI == 'http://gedcomx.org/v1/')) {
            $child = new ResourceReference($xml);
            if (!isset($this->emails)) {
                $this->emails = array();
            }
            array_push($this->emails, $child);
            $happened = true;
        }
        else if (($xml->localName == 'homepage') && ($xml->namespaceURI == 'http://gedcomx.org/v1/')) {
            $child = new ResourceReference($xml);
            $this->homepage = $child;
            $happened = true;
        }
        else if (($xml->localName == 'identifier') && ($xml->namespaceURI == 'http://gedcomx.org/v1/')) {
            $child = new Identifier($xml);
            if (!isset($this->identifiers)) {
                $this->identifiers = array();
            }
            array_push($this->identifiers, $child);
            $happened = true;
        }
        else if (($xml->localName == 'name') && ($xml->namespaceURI == 'http://gedcomx.org/v1/')) {
            $child = new TextValue($xml);
            if (!isset($this->names)) {
                $this->names = array();
            }
            array_push($this->names, $child);
            $happened = true;
        }
        else if (($xml->localName == 'openid') && ($xml->namespaceURI == 'http://gedcomx.org/v1/')) {
            $child = new ResourceReference($xml);
            $this->openid = $child;
            $happened = true;
        }
        else if (($xml->localName == 'phone') && ($xml->namespaceURI == 'http://gedcomx.org/v1/')) {
            $child = new ResourceReference($xml);
            if (!isset($this->phones)) {
                $this->phones = array();
            }
            array_push($this->phones, $child);
            $happened = true;
        }
        return $happened;
    }

    /**
     * Sets a known attribute of Agent from an XML reader.
     *
     * @param \XMLReader $xml The reader.
     *
     * @return bool Whether an attribute was set.
     */
    protected function setKnownAttribute(\XMLReader $xml) {
        if (parent::setKnownAttribute($xml)) {
            return true;
        }

        return false;
    }

    /**
     * Writes this Agent to an XML writer.
     *
     * @param \XMLWriter $writer The XML writer.
     *
     * @param bool $includeNamespaces Whether to write out the namespaces in the element.
     */
    public function toXml(\XMLWriter $writer, $includeNamespaces = true)
    {
        $writer->startElementNS('gx', 'agent', null);
        if ($includeNamespaces) {
            $writer->writeAttributeNs('xmlns', 'gx', null, 'http://gedcomx.org/v1/');
        }
        $this->writeXmlContents($writer);
        $writer->endElement();
    }

    /**
     * Writes the contents of this Agent to an XML writer. The startElement is expected to be already provided.
     *
     * @param \XMLWriter $writer The XML writer.
     */
    public function writeXmlContents(\XMLWriter $writer)
    {
        parent::writeXmlContents($writer);
        if ($this->accounts) {
            foreach ($this->accounts as $i => $x) {
                $writer->startElementNs('gx', 'account', null);
                $x->writeXmlContents($writer);
                $writer->endElement();
            }
        }
        if ($this->addresses) {
            foreach ($this->addresses as $i => $x) {
                $writer->startElementNs('gx', 'address', null);
                $x->writeXmlContents($writer);
                $writer->endElement();
            }
        }
        if ($this->emails) {
            foreach ($this->emails as $i => $x) {
                $writer->startElementNs('gx', 'email', null);
                $x->writeXmlContents($writer);
                $writer->endElement();
            }
        }
        if ($this->homepage) {
            $writer->startElementNs('gx', 'homepage', null);
            $this->homepage->writeXmlContents($writer);
            $writer->endElement();
        }
        if ($this->identifiers) {
            foreach ($this->identifiers as $i => $x) {
                $writer->startElementNs('gx', 'identifier', null);
                $x->writeXmlContents($writer);
                $writer->endElement();
            }
        }
        if ($this->names) {
            foreach ($this->names as $i => $x) {
                $writer->startElementNs('gx', 'name', null);
                $x->writeXmlContents($writer);
                $writer->endElement();
            }
        }
        if ($this->openid) {
            $writer->startElementNs('gx', 'openid', null);
            $this->openid->writeXmlContents($writer);
            $writer->endElement();
        }
        if ($this->phones) {
            foreach ($this->phones as $i => $x) {
                $writer->startElementNs('gx', 'phone', null);
                $x->writeXmlContents($writer);
                $writer->endElement();
            }
        }
    }
}
gedcomx-php API documentation generated by ApiGen