Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / Models / ECommerce / ECommerceCustomer.php
1 <?php
2
3 namespace Doctrine\Tests\Models\ECommerce;
4
5 /**
6  * ECommerceCustomer
7  * Represents a registered user of a shopping application.
8  *
9  * @author Giorgio Sironi
10  * @Entity
11  * @Table(name="ecommerce_customers")
12  */
13 class ECommerceCustomer
14 {
15     /**
16      * @Column(type="integer")
17      * @Id
18      * @GeneratedValue(strategy="AUTO")
19      */
20     private $id;
21
22     /**
23      * @Column(type="string", length=50)
24      */
25     private $name;
26
27     /**
28      * @OneToOne(targetEntity="ECommerceCart", mappedBy="customer", cascade={"persist"})
29      */
30     private $cart;
31
32     /**
33      * Example of a one-one self referential association. A mentor can follow
34      * only one customer at the time, while a customer can choose only one
35      * mentor. Not properly appropriate but it works.
36      *
37      * @OneToOne(targetEntity="ECommerceCustomer", cascade={"persist"}, fetch="EAGER")
38      * @JoinColumn(name="mentor_id", referencedColumnName="id")
39      */
40     private $mentor;
41
42     public function getId() {
43         return $this->id;
44     }
45
46     public function getName() {
47         return $this->name;
48     }
49
50     public function setName($name) {
51         $this->name = $name;
52     }
53
54     public function setCart(ECommerceCart $cart)
55     {
56         if ($this->cart !== $cart) {
57             $this->cart = $cart;
58             $cart->setCustomer($this);
59         }
60     }
61
62     /* Does not properly maintain the bidirectional association! */
63     public function brokenSetCart(ECommerceCart $cart) {
64         $this->cart = $cart;
65     }
66
67     public function getCart() {
68         return $this->cart;
69     }
70
71     public function removeCart()
72     {
73         if ($this->cart !== null) {
74             $cart = $this->cart;
75             $this->cart = null;
76             $cart->removeCustomer();
77         }
78     }
79
80     public function setMentor(ECommerceCustomer $mentor)
81     {
82         $this->mentor = $mentor;
83     }
84
85     public function removeMentor()
86     {
87         $this->mentor = null;
88     }
89
90     public function getMentor()
91     {
92         return $this->mentor;
93     }
94 }