<?php
namespace Roothirsch\CoreBundle\Entity\Company;
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\CoreBundle\Entity\Company;
/**
* @ORM\Entity
*/
class CompanyAttributeValue extends AbstractAttributeValue
{
use AttributeAwareTrait;
use AttributeOptionAwareTrait;
/**
* @ORM\ManyToOne(targetEntity=Company::class, inversedBy="attributeValues")
* @ORM\JoinColumn(nullable=false)
*/
private $company;
/**
* @ORM\ManyToOne(targetEntity=CompanyAttribute::class, inversedBy="attributeValues")
* @ORM\JoinColumn(nullable=false)
*/
private $attribute;
/**
* @ORM\ManyToMany(targetEntity=CompanyAttributeOption::class, cascade={"persist"})
* @ORM\JoinTable(name="company_attribute_value_company_attribute_option")
*/
private $attributeOptions;
public function __construct(AttributeInterface $attribute)
{
$this->attributeOptions = new ArrayCollection();
$this->attribute = $attribute;
}
function resolveExpression(): array
{
return [
"company" => $this->getAttributable()
];
}
public function getAttributable(): AttributableInterface
{
return $this->company;
}
public function setAttributable(AttributableInterface $attributable): AttributableAwareInterface
{
$this->company = $attributable;
return $this;
}
}