vendor/roothirsch/core-bundle/Entity/Company/CompanyAttributeValue.php line 20

Open in your IDE?
  1. <?php
  2. namespace Roothirsch\CoreBundle\Entity\Company;
  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\CoreBundle\Entity\Company;
  13. /**
  14. * @ORM\Entity
  15. */
  16. class CompanyAttributeValue extends AbstractAttributeValue
  17. {
  18. use AttributeAwareTrait;
  19. use AttributeOptionAwareTrait;
  20. /**
  21. * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="attributeValues")
  22. * @ORM\JoinColumn(nullable=false)
  23. */
  24. private $company;
  25. /**
  26. * @ORM\ManyToOne(targetEntity=CompanyAttribute::class, inversedBy="attributeValues")
  27. * @ORM\JoinColumn(nullable=false)
  28. */
  29. private $attribute;
  30. /**
  31. * @ORM\ManyToMany(targetEntity=CompanyAttributeOption::class, cascade={"persist"})
  32. * @ORM\JoinTable(name="company_attribute_value_company_attribute_option")
  33. */
  34. private $attributeOptions;
  35. public function __construct(AttributeInterface $attribute)
  36. {
  37. $this->attributeOptions = new ArrayCollection();
  38. $this->attribute = $attribute;
  39. }
  40. function resolveExpression(): array
  41. {
  42. return [
  43. "company" => $this->getAttributable()
  44. ];
  45. }
  46. public function getAttributable(): AttributableInterface
  47. {
  48. return $this->company;
  49. }
  50. public function setAttributable(AttributableInterface $attributable): AttributableAwareInterface
  51. {
  52. $this->company = $attributable;
  53. return $this;
  54. }
  55. }