ECommerceFeature.php 1.17 KB
Newer Older
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
<?php

namespace Doctrine\Tests\Models\ECommerce;

/**
 * Describes a product feature.
 *
 * @author Giorgio Sironi
 * @Entity
 * @Table(name="ecommerce_features")
 */
class ECommerceFeature
{
    /**
     * @Column(type="integer")
     * @Id
     * @GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @Column(type="string", length=50)
     */
    private $description;

    /**
     * @ManyToOne(targetEntity="ECommerceProduct")
     * @JoinColumn(name="product_id", referencedColumnName="id")
     */
    private $product;

    public function getId() {
        return $this->id;
    }
    
    public function getDescription() {
        return $this->description;
    }
    
    public function setDescription($description) {
        $this->description = $description;
    }
    
    public function setProduct(ECommerceProduct $product) {
45
        $this->product = $product;
46 47 48 49 50 51 52 53 54 55 56 57 58 59
    }
    
    public function removeProduct() {
        if ($this->product !== null) {
            $product = $this->product;
            $this->product = null;
            $product->removeFeature($this);
        }
    }
    
    public function getProduct() {
        return $this->product;
    }
}