CompanyPerson.php 1.19 KB
Newer Older
1 2 3 4 5 6 7 8
<?php

namespace Doctrine\Tests\Models\Company;

/**
 * Description of CompanyPerson
 *
 * @author robo
9 10 11 12 13 14
 * @Entity
 * @Table(name="company_persons")
 * @DiscriminatorValue("person")
 * @InheritanceType("joined")
 * @DiscriminatorColumn(name="discr", type="string")
 * @SubClasses({"Doctrine\Tests\Models\Company\CompanyEmployee",
15 16 17 18 19
        "Doctrine\Tests\Models\Company\CompanyManager"})
 */
class CompanyPerson
{
    /**
20 21 22
     * @Id
     * @Column(type="integer")
     * @GeneratedValue(strategy="auto")
23 24 25
     */
    private $id;
    /**
26
     * @Column(type="string")
27 28 29
     */
    private $name;
    /**
30 31
     * @OneToOne(targetEntity="CompanyPerson")
     * @JoinColumn(name="spouse_id", referencedColumnName="id")
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
     */
    private $spouse;

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

    public function getName() {
        return $this->name;
    }

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

    public function getSpouse() {
        return $this->spouse;
    }

    public function setSpouse(CompanyPerson $spouse) {
        if ($spouse !== $this->spouse) {
            $this->spouse = $spouse;
            $this->spouse->setSpouse($this);
        }
    }
}