<?phpnamespace Roothirsch\PimBundle\Entity;use ApiPlatform\Core\Annotation\ApiResource;use Roothirsch\CoreBundle\Behaviors\Attributable\AttributeOption\AttributeOptionAwareTrait;use Roothirsch\CoreBundle\Behaviors\Attributable\AttributeValue\AttributeValueAwareTrait;use Roothirsch\CoreBundle\Behaviors\Attributable\MappedSuperclass\AbstractAttribute;use Roothirsch\CoreBundle\Behaviors\Translatable\TranslatableFieldInterface;use Roothirsch\PimBundle\Entity\AttributeOption;use Roothirsch\PimBundle\Repository\AttributeRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use \Roothirsch\PimBundle\Entity\AttributeGroup;/** * @ApiResource(shortName="Pim/Attribute") * @ORM\Entity(repositoryClass=AttributeRepository::class) * @ORM\Table(name="pim_attribute") */class Attribute extends AbstractAttribute implements TranslatableFieldInterface{ use AttributeOptionAwareTrait; use AttributeValueAwareTrait; /** * @ORM\OneToMany(targetEntity=AttributeValue::class, mappedBy="attribute", orphanRemoval=true) */ private $attributeValues; /** * @ORM\OneToMany(targetEntity=AttributeOption::class, mappedBy="attribute", orphanRemoval=true, cascade={"persist"}) */ private $attributeOptions; /** * @ORM\ManyToOne(targetEntity=AttributeGroup::class, inversedBy="attributes") * @ORM\JoinColumn(nullable=false, onDelete="CASCADE") */ private $attributeGroup; /** * @ORM\Column(type="boolean") */ private $valuePerChannel = false; /** * @ORM\Column(type="boolean") */ private $valuePerLanguage = false; public function __toString() { return $this->title; } public function getValuePerChannel(): ?bool { return $this->valuePerChannel; } public function setValuePerChannel(bool $valuePerChannel): self { $this->valuePerChannel = $valuePerChannel; return $this; } public function getValuePerLanguage(): ?bool { return $this->valuePerLanguage; } public function setValuePerLanguage(bool $valuePerLanguage): self { $this->valuePerLanguage = $valuePerLanguage; return $this; } public function getAttributeGroup(): ?AttributeGroup { return $this->attributeGroup; } public function setAttributeGroup(?AttributeGroup $attributeGroup): self { $this->attributeGroup = $attributeGroup; return $this; } public function isTranslatable(): bool { return $this->getValuePerLanguage(); } public function getTranslatableKey(): string { return $this->getName(); }}