<?php
namespace Roothirsch\PimBundle\Entity;
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\PimBundle\Entity\AttributeOption;
use Roothirsch\PimBundle\Repository\AttributeValueRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use \Roothirsch\PimBundle\Entity\Attribute;
use \Roothirsch\PimBundle\Entity\Article;
use \Roothirsch\CoreBundle\Translation\Entity\Language;
use \Roothirsch\PimBundle\Entity\Channel;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=AttributeValueRepository::class)
* @ORM\Table(name="pim_attribute_value")
*/
class AttributeValue extends AbstractAttributeValue
{
use AttributeAwareTrait;
use AttributeOptionAwareTrait;
/**
* @ORM\ManyToOne(targetEntity=Attribute::class, inversedBy="attributeValues")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $attribute;
/**
* @ORM\ManyToOne(targetEntity=Product::class, inversedBy="attributeValues")
* @ORM\JoinColumn(nullable=false)
*/
private $product;
/**
* @ORM\ManyToOne(targetEntity=Language::class)
* @Groups({"list"})
*/
private $language;
/**
* @ORM\ManyToOne(targetEntity=Channel::class)
* @Groups({"list"})
*/
private $channel;
/**
* @ORM\ManyToMany(targetEntity=AttributeOption::class, cascade={"persist"})
* @ORM\JoinTable(name="pim_attribute_value_attribute_option")
* @Groups({"list"})
*/
private $attributeOptions;
public function __construct(AttributeInterface $attribute)
{
$this->attributeOptions = new ArrayCollection();
$this->attribute = $attribute;
}
function resolveExpression(): array
{
return [
"product" => $this->getAttributable(),
// 'owner' => $this->declaration->getOwner()
];
}
public function getAttributable(): AttributableInterface
{
return $this->product;
}
public function setAttributable(AttributableInterface $attributable): AttributableAwareInterface
{
$this->product = $attributable;
return $this;
}
public function getLanguage(): ?Language
{
return $this->language;
}
public function setLanguage(?Language $language): self
{
$this->language = $language;
return $this;
}
public function getChannel(): ?Channel
{
return $this->channel;
}
public function setChannel(?Channel $channel): self
{
$this->channel = $channel;
return $this;
}
}