vendor/roothirsch/shop-bundle/Entity/Order/OrderAttributeValue.php line 22

Open in your IDE?
  1. <?php
  2. namespace Roothirsch\ShopBundle\Entity\Order;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Roothirsch\CoreBundle\Behaviors\Attributable\AttributableAwareInterface;
  7. use Roothirsch\CoreBundle\Behaviors\Attributable\AttributableInterface;
  8. use Roothirsch\CoreBundle\Behaviors\Attributable\Attribute\AttributeAwareTrait;
  9. use Roothirsch\CoreBundle\Behaviors\Attributable\Attribute\AttributeInterface;
  10. use Roothirsch\CoreBundle\Behaviors\Attributable\AttributeOption\AttributeOptionAwareTrait;
  11. use Roothirsch\CoreBundle\Behaviors\Attributable\MappedSuperclass\AbstractAttributeValue;
  12. use Roothirsch\ShopBundle\Entity\Order\OrderAttributeOption;
  13. use Roothirsch\ShopBundle\Entity\Order\OrderAttribute;
  14. use Roothirsch\ShopBundle\Entity\Order;
  15. /**
  16. * @ORM\Entity(repositoryClass=OrderAttributeValueRepositor::class)
  17. * @ORM\Table(name="shop_order_attribute_value")
  18. */
  19. class OrderAttributeValue extends AbstractAttributeValue
  20. {
  21. use AttributeAwareTrait;
  22. use AttributeOptionAwareTrait;
  23. /**
  24. * @ORM\ManyToOne(targetEntity=Order::class, inversedBy="attributeValues")
  25. * @ORM\JoinColumn(nullable=false)
  26. */
  27. private $order;
  28. /**
  29. * @ORM\ManyToOne(targetEntity=OrderAttribute::class, inversedBy="attributeValues")
  30. * @ORM\JoinColumn(nullable=false)
  31. */
  32. private $attribute;
  33. /**
  34. * @ORM\ManyToMany(targetEntity=OrderAttributeOption::class, cascade={"persist"})
  35. * @ORM\JoinTable(name="shop_order_attribute_value_order_attribute_option")
  36. */
  37. private $attributeOptions;
  38. public function __construct(AttributeInterface $attribute)
  39. {
  40. $this->attributeOptions = new ArrayCollection();
  41. $this->attribute = $attribute;
  42. }
  43. function resolveExpression(): array
  44. {
  45. return [
  46. "order" => $this->getAttributable()
  47. ];
  48. }
  49. public function getAttributable(): AttributableInterface
  50. {
  51. return $this->order;
  52. }
  53. public function setAttributable(AttributableInterface $attributable): AttributableAwareInterface
  54. {
  55. $this->order = $attributable;
  56. return $this;
  57. }
  58. }