3 namespace Doctrine\Tests\Models\ECommerce;
7 * Represents a registered user of a shopping application.
9 * @author Giorgio Sironi
11 * @Table(name="ecommerce_customers")
13 class ECommerceCustomer
16 * @Column(type="integer")
18 * @GeneratedValue(strategy="AUTO")
23 * @Column(type="string", length=50)
28 * @OneToOne(targetEntity="ECommerceCart", mappedBy="customer", cascade={"persist"})
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.
37 * @OneToOne(targetEntity="ECommerceCustomer", cascade={"persist"}, fetch="EAGER")
38 * @JoinColumn(name="mentor_id", referencedColumnName="id")
42 public function getId() {
46 public function getName() {
50 public function setName($name) {
54 public function setCart(ECommerceCart $cart)
56 if ($this->cart !== $cart) {
58 $cart->setCustomer($this);
62 /* Does not properly maintain the bidirectional association! */
63 public function brokenSetCart(ECommerceCart $cart) {
67 public function getCart() {
71 public function removeCart()
73 if ($this->cart !== null) {
76 $cart->removeCustomer();
80 public function setMentor(ECommerceCustomer $mentor)
82 $this->mentor = $mentor;
85 public function removeMentor()
90 public function getMentor()