<?php
namespace App\Admin\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
/**
* StdAttributesValues
*/
#[ORM\Table(name: 'std_attributes_values')]
#[ORM\Entity(repositoryClass: 'App\Admin\Repository\StdAttributesValuesRepository')]
#[ORM\HasLifecycleCallbacks]
class StdAttributesValues
{
/**
* @var int
*/
#[ORM\Column(name: 'id', type: 'integer', nullable: false, options: ['unsigned' => true, 'comment' => 'Attribute value unique identifier'])]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private $id;
/**
* @var string
*/
#[ORM\Column(name: 'attribute_machine_name', type: 'string', length: 50, nullable: false, options: ['comment' => 'Attribute machine name'])]
private $attributeMachineName;
/**
* @var string
*/
#[ORM\Column(name: 'label', type: 'string', length: 50, nullable: false, options: ['comment' => 'Attribute value label'])]
private $label;
/**
* @var string
*/
#[ORM\Column(name: 'value', type: 'string', length: 20, nullable: false, options: ['comment' => 'Attribute value'])]
private $value;
/**
* @var int
*/
#[ORM\Column(name: 'order_value', type: 'integer', nullable: true, options: ['comment' => 'Attribute value order'])]
private $orderValue;
/**
* @var string
*/
#[ORM\Column(name: 'color', type: 'string', length: 20, nullable: true, options: ['comment' => 'Attribute color'])]
private $color;
/**
* @var string
*/
#[ORM\Column(name: 'image', type: 'string', length: 100, nullable: true, options: ['comment' => 'Attribute image'])]
private $image;
/**
* @var \StdAttributes
*/
#[ORM\JoinColumn(name: 'attribute_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: 'StdAttributes', inversedBy: 'contents')]
private $attribute;
/**
* @var \StdUsers
*/
#[ORM\JoinColumn(name: 'created_by', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: 'StdUsers')]
private $createdBy;
/**
* @var \DateTime
*/
#[ORM\Column(name: 'created_date', type: 'datetime', nullable: false, options: ['comment' => 'Date and time of the record creation'])]
private $createdDate;
/**
* @var \StdUsers
*/
#[ORM\JoinColumn(name: 'updated_by', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: 'StdUsers')]
private $updatedBy;
/**
* @var \DateTime
*/
#[ORM\Column(name: 'updated_date', type: 'datetime', nullable: false, options: ['comment' => 'Date and time the record was last updated'])]
private $updatedDate;
/**
* @var Doctrine\Common\Collections\ArrayCollection|null
*/
#[ORM\OneToMany(targetEntity: 'StdAttributesValuesContent', mappedBy: 'attributeValue', cascade: ['persist'], orphanRemoval: true)]
private $contents;
public function __construct()
{
$this->contents = new ArrayCollection();
}
/**
* @return Collection|StdAttributesValuesContent[]
*/
public function getContents(): ?Collection
{
return $this->contents;
}
/**
* @return StdAttributesValuesContent
*/
public function getLocalizedContents(StdLanguages $locale): ?StdAttributesValuesContent
{
$criteria = Criteria::create()
->where(Criteria::expr()->eq("languageCode", $locale))
->setMaxResults(1);
if($this->getContents()){
$contents = $this->getContents()->matching($criteria);
if(count($contents)){
$contents = array_values($contents->toArray());
return $contents[0];
}else{
return null;
}
}else{
return null;
}
}
public function getId(): ?int
{
return $this->id;
}
public function getAttributeMachineName(): ?string
{
return $this->attributeMachineName;
}
public function setAttributeMachineName(string $attributeMachineName): self
{
$this->attributeMachineName = $attributeMachineName;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(string $value): self
{
$this->value = $value;
return $this;
}
public function getOrderValue(): ?int
{
return $this->orderValue;
}
public function setOrderValue(int $orderValue): self
{
$this->orderValue = $orderValue;
return $this;
}
public function getColor(): ?string
{
return $this->color;
}
public function setColor(string $color): self
{
$this->color = $color;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(string $image): self
{
$this->image = $image;
return $this;
}
public function getAttribute(): ?StdAttributes
{
return $this->attribute;
}
public function setAttribute(StdAttributes $attribute): self
{
$this->attribute = $attribute;
return $this;
}
public function getCreatedDate(): ?\DateTimeInterface
{
return $this->createdDate;
}
public function setCreatedDate(\DateTimeInterface $createdDate): self
{
$this->createdDate = $createdDate;
return $this;
}
public function getUpdatedDate(): ?\DateTimeInterface
{
return $this->updatedDate;
}
public function setUpdatedDate(\DateTimeInterface $updatedDate): self
{
$this->updatedDate = $updatedDate;
return $this;
}
public function getCreatedBy(): ?StdUsers
{
return $this->createdBy;
}
public function setCreatedBy(?StdUsers $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getUpdatedBy(): ?StdUsers
{
return $this->updatedBy;
}
public function setUpdatedBy(?StdUsers $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function removeContent(StdAttributesValuesContent $content): self
{
if ($this->contents->contains($content)) {
$this->contents->removeElement($content);
// set the owning side to null (unless already changed)
if ($content->getAttributeValue() === $this) {
$content->setAttributeValue(null);
}
}
return $this;
}
public function addContent(StdAttributesValuesContent $content): self
{
if (!$this->contents->contains($content)) {
$this->contents[] = $content;
$content->setAttributeValue($this);
}
return $this;
}
#[ORM\PreUpdate]
public function setUpdated()
{
$this->setUpdatedDate(new \DateTime());
}
#[ORM\PrePersist]
public function setCreated()
{
$this->setUpdatedDate(new \DateTime());
$this->setCreatedDate(new \DateTime());
}
public function __toString() {
return $this->label;
}
}