<?php
namespace Roothirsch\ShopBundle\Entity\Order;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Roothirsch\CoreBundle\Behaviors\Attributable\AttributableAwareInterface;
use Roothirsch\CoreBundle\Behaviors\Attributable\AttributableInterface;
use Roothirsch\CoreBundle\Behaviors\Attributable\Attribute\AttributeAwareTrait;
use Roothirsch\CoreBundle\Behaviors\Attributable\Attribute\AttributeInterface;
use Roothirsch\CoreBundle\Behaviors\Attributable\AttributeOption\AttributeOptionAwareTrait;
use Roothirsch\CoreBundle\Behaviors\Attributable\MappedSuperclass\AbstractAttributeValue;
use Roothirsch\ShopBundle\Entity\Order\OrderAttributeOption;
use Roothirsch\ShopBundle\Entity\Order\OrderAttribute;
use Roothirsch\ShopBundle\Entity\Order;
/**
* @ORM\Entity(repositoryClass=OrderAttributeValueRepositor::class)
* @ORM\Table(name="shop_order_attribute_value")
*/
class OrderAttributeValue extends AbstractAttributeValue
{
use AttributeAwareTrait;
use AttributeOptionAwareTrait;
/**
* @ORM\ManyToOne(targetEntity=Order::class, inversedBy="attributeValues")
* @ORM\JoinColumn(nullable=false)
*/
private $order;
/**
* @ORM\ManyToOne(targetEntity=OrderAttribute::class, inversedBy="attributeValues")
* @ORM\JoinColumn(nullable=false)
*/
private $attribute;
/**
* @ORM\ManyToMany(targetEntity=OrderAttributeOption::class, cascade={"persist"})
* @ORM\JoinTable(name="shop_order_attribute_value_order_attribute_option")
*/
private $attributeOptions;
public function __construct(AttributeInterface $attribute)
{
$this->attributeOptions = new ArrayCollection();
$this->attribute = $attribute;
}
function resolveExpression(): array
{
return [
"order" => $this->getAttributable()
];
}
public function getAttributable(): AttributableInterface
{
return $this->order;
}
public function setAttributable(AttributableInterface $attributable): AttributableAwareInterface
{
$this->order = $attributable;
return $this;
}
}