<?php
namespace Roothirsch\ShopBundle\Entity;
use Roothirsch\CoreBundle\Entity\Traits\TimetrackedTrait;
use Roothirsch\ShopBundle\Repository\EstimatePositionAttributeRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="shop_position_template_attribute")
*/
class PositionTemplateAttribute
{
use TimetrackedTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=PositionTemplate::class, inversedBy="attributes")
* @ORM\JoinColumn(nullable=false)
*/
private $position;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $title;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $data;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $value;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $amount;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $amountFormat;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $price;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $total;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $article;
public function getId(): ?int
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle($title): self
{
$this->title = $title;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getData(): ?string
{
return $this->data;
}
public function setData(?string $data): self
{
$this->data = $data;
return $this;
}
public function getPosition(): ?PositionTemplate
{
return $this->position;
}
public function setPosition(?PositionTemplate $position): self
{
$this->position = $position;
return $this;
}
const ZERO_VALUE = '833dd2fc-c713-11ed-afa1-0242ac120002';
/**
* @return mixed
*/
public function getValue()
{
if ($this->value == self::ZERO_VALUE) {
return 0;
}
return $this->value;
}
/**
* @param mixed $value
*/
public function setValue($value): void
{
$this->value = $value;
}
public function getAmount(): ?string
{
return $this->amount;
}
public function setAmount($amount): self
{
$this->amount = $amount;
return $this;
}
public function getAmountFormat(): ?string
{
return $this->amountFormat;
}
public function setAmountFormat(?string $amountFormat): self
{
$this->amountFormat = $amountFormat;
return $this;
}
public function getPrice(): ?int
{
return $this->price;
}
public function setPrice(?int $price): self
{
$this->price = $price;
return $this;
}
public function getTotal(): ?int
{
return $this->total;
}
public function setTotal(?int $total): self
{
$this->total = $total;
return $this;
}
public function getArticle(): ?string
{
return $this->article;
}
public function setArticle(?string $article): self
{
$this->article = $article;
return $this;
}
public function convertToOrderPositionAttribute() {
$attribute = new OrderPositionAttribute();
$attribute->setTitle($this->getTitle());
$attribute->setName($this->getName());
$attribute->setData($this->getData());
$attribute->setValue($this->getValue());
$attribute->setAmount($this->getAmount());
$attribute->setAmountFormat($this->getAmountFormat());
$attribute->setPrice($this->getPrice());
$attribute->setTotal($this->getTotal());
$attribute->setArticle($this->getArticle());
return $attribute;
}
public function convertToEstimatePositionAttribute() {
$attribute = new EstimatePositionAttribute();
$attribute->setTitle($this->getTitle());
$attribute->setName($this->getName());
$attribute->setData($this->getData());
$attribute->setValue($this->getValue());
$attribute->setAmount($this->getAmount());
$attribute->setAmountFormat($this->getAmountFormat());
$attribute->setPrice($this->getPrice());
$attribute->setTotal($this->getTotal());
$attribute->setArticle($this->getArticle());
return $attribute;
}
}