<?php
namespace Roothirsch\ShopBundle\Entity;
use Roothirsch\CoreBundle\Entity\Traits\TimetrackedTrait;
use App\Repository\Shop\Entity\OrderPositionAttributeRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=OrderPositionAttributeRepository::class)
* @ORM\Table(name="shop_order_position_attribute")
*/
class OrderPositionAttribute
{
use TimetrackedTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=OrderPosition::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;
}
/**
* @return mixed
*/
public function getPosition()
{
return $this->position;
}
/**
* @param mixed $position
*/
public function setPosition($position): void
{
$this->position = $position;
}
/**
* @return mixed
*/
public function getTitle()
{
return $this->title;
}
/**
* @param mixed $title
*/
public function setTitle($title): void
{
$this->title = $title;
}
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name): void
{
$this->name = $name;
}
/**
* @return mixed
*/
public function getData()
{
return $this->data;
}
/**
* @param mixed $data
*/
public function setData($data): void
{
$this->data = $data;
}
const ZERO_VALUE = '833dd2fc-c713-11ed-afa1-0242ac120002';
/**
* @return mixed
*/
public function getValue(): string
{
if ($this->value == self::ZERO_VALUE) {
return '0';
}
return strval($this->value);
}
/**
* @param mixed $value
*/
public function setValue($value): void
{
$this->value = $value;
}
/**
* @return mixed
*/
public function getAmount()
{
return $this->amount;
}
/**
* @param mixed $amount
*/
public function setAmount($amount): void
{
$this->amount = $amount;
}
/**
* @return mixed
*/
public function getAmountFormat()
{
return $this->amountFormat;
}
/**
* @param mixed $amountFormat
*/
public function setAmountFormat($amountFormat): void
{
$this->amountFormat = $amountFormat;
}
/**
* @return mixed
*/
public function getPrice()
{
return $this->price;
}
/**
* @param mixed $price
*/
public function setPrice($price): void
{
$this->price = $price;
}
/**
* @return mixed
*/
public function getTotal()
{
return $this->total;
}
/**
* @param mixed $total
*/
public function setTotal($total): void
{
$this->total = $total;
}
/**
* @return mixed
*/
public function getArticle()
{
return $this->article;
}
/**
* @param mixed $article
*/
public function setArticle($article): void
{
$this->article = $article;
}
public function convertToTemplatePositionAttribute() {
$attribute = new PositionTemplateAttribute();
$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;
}
}