1
0
mirror of synced 2024-12-14 23:26:04 +03:00
doctrine2/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php

102 lines
2.2 KiB
PHP
Raw Normal View History

<?php
namespace Doctrine\Tests\Models\ECommerce;
/**
* ECommerceProduct
* Represents a type of product of a shopping application.
*
* @author Giorgio Sironi
* @Entity
* @Table(name="ecommerce_products")
*/
class ECommerceProduct
{
/**
* @Column(type="integer")
* @Id
* @GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @Column(type="string", length=50)
*/
private $name;
/**
* @OneToOne(targetEntity="ECommerceShipping", cascade={"save"})
* @JoinColumn(name="shipping_id", referencedColumnName="id")
*/
private $shipping;
/**
* @OneToMany(targetEntity="ECommerceFeature", mappedBy="product", cascade={"save"})
*/
private $features;
/**
* @ManyToMany(targetEntity="ECommerceCategory", cascade={"save"})
* @JoinTable(name="ecommerce_products_categories",
joinColumns={{"name"="product_id", "referencedColumnName"="id"}},
inverseJoinColumns={{"name"="category_id", "referencedColumnName"="id"}})
private $categories;
*/
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getShipping()
{
return $this->shipping;
}
public function setShipping(ECommerceShipping $shipping)
{
$this->shipping = $shipping;
}
public function removeShipping()
{
$this->shipping = null;
}
public function getFeatures()
{
return $this->features;
}
public function addFeature(ECommerceFeature $feature) {
$this->features[] = $feature;
$feature->setProduct($this);
}
/** does not set the owning side */
public function brokenAddFeature(ECommerceFeature $feature) {
$this->features[] = $feature;
}
public function removeFeature(ECommerceFeature $feature) {
foreach ($this->features as $index => $current) {
if ($current === $feature) {
unset($this->features[$index]);
$current->removeProduct();
return true;
}
}
return false;
}
}