Created
May 14, 2012 09:52
-
-
Save patie/2693006 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Author: Patrik Gmitter <[email protected]> | |
* Date: 4/24/12 | |
*/ | |
namespace Eshop\Model; | |
use Doctrine\Common\Collections\ArrayCollection; | |
/** | |
* @Entity | |
*/ | |
class ProductAttribute extends \Nette\Object | |
{ | |
/** | |
* @Id | |
* @Column(type="integer") | |
* @GeneratedValue | |
*/ | |
private $id; | |
/** | |
* @Column(type="string") | |
*/ | |
private $name; | |
public function getId() | |
{ | |
return $this->id; | |
} | |
public function getName() | |
{ | |
return $this->name; | |
} | |
public function setName($name) | |
{ | |
$this->name = $name; | |
} | |
# V A L U E S | |
public function getValues() | |
{ | |
return $this->values; | |
} | |
public function addValue(ProductAttributeValue $value) | |
{ | |
$value->setAttribute($this); | |
$this->values[] = $value; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Eshop\Model; | |
use Doctrine\Common\Collections\ArrayCollection; | |
/** | |
* @Entity(repositoryClass="Eshop\Model\ProductRepository") | |
*/ | |
class Product extends \Nette\Object | |
{ | |
/** | |
* @Id | |
* @Column(type="integer") | |
* @GeneratedValue | |
*/ | |
private $id; | |
/** | |
* @Column(type="string") | |
*/ | |
protected $name; | |
# next properties ... | |
/** | |
* UNI | |
* | |
* @ManyToMany(targetEntity="ProductAttributeValue") | |
* @JoinTable(name="Product_ProductAttributeValue", | |
* joinColumns={@JoinColumn(name="Product_id", referencedColumnName="id")}, | |
* inverseJoinColumns={@JoinColumn(name="ProductAttributeValue_id", referencedColumnName="id")} | |
* ) | |
**/ | |
protected $attributes; | |
# A T T R I B U T E S | |
public function getAttributes() | |
{ | |
return $this->attributes; | |
} | |
public function addAttribute(ProductAttributeValue $attribute) | |
{ | |
$this->attributes[] = $attribute; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Author: Patrik Gmitter <[email protected]> | |
* Date: 5/14/12 | |
*/ | |
namespace Eshop\Model; | |
/** | |
* @Entity | |
*/ | |
class ProductAttributeValue extends \Nette\Object | |
{ | |
/** | |
* @Id | |
* @Column(type="integer") | |
* @GeneratedValue | |
*/ | |
private $id; | |
/** | |
* @Column(type="string") | |
*/ | |
protected $value; | |
/** | |
* @ManyToOne(targetEntity="ProductAttribute", inversedBy="values") | |
* @JoinColumn(name="ProductAttribute_id", referencedColumnName="id") | |
**/ | |
protected $attribute; | |
public function __construct(ProductAttribute $attribute, $value ) | |
{ | |
$this->attribute = $attribute; | |
$this->value = $value; | |
} | |
public function getId() | |
{ | |
return $this->id; | |
} | |
public function getValue() | |
{ | |
return $this->value; | |
} | |
public function setValue($value) | |
{ | |
$this->value = $value; | |
} | |
# A T T R I B U T E | |
public function setAttribute(ProductAttribute $attribute) | |
{ | |
$this->attribute = $attribute; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment