87 lines
1.6 KiB
PHP
87 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="customer_metadata")
|
|
* @UniqueEntity("customer")
|
|
*/
|
|
|
|
class CustomerMetadata
|
|
{
|
|
// unique id
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
protected $id;
|
|
|
|
// customer
|
|
/**
|
|
* @ORM\OneToOne(targetEntity="Customer")
|
|
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
|
|
*/
|
|
protected $customer;
|
|
|
|
// other information, like locations
|
|
/**
|
|
* @ORM\Column(type="json")
|
|
*/
|
|
protected $meta_info;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->meta_info = [];
|
|
}
|
|
|
|
public function getID()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function setCustomer(Customer $customer)
|
|
{
|
|
$this->customer = $customer;
|
|
return $this;
|
|
}
|
|
|
|
public function getCustomer()
|
|
{
|
|
return $this->customer;
|
|
}
|
|
|
|
public function addMetaInfo($id, $value)
|
|
{
|
|
$this->meta_info[$id] = $value;
|
|
return $this;
|
|
}
|
|
|
|
public function getMetaInfo($id)
|
|
{
|
|
// return null if we don't have it
|
|
if (!isset($this->meta_info[$id]))
|
|
return null;
|
|
|
|
return $this->meta_info[$id];
|
|
}
|
|
|
|
public function getAllMetaInfo()
|
|
{
|
|
return $this->meta_info;
|
|
}
|
|
|
|
public function popMetaInfo()
|
|
{
|
|
if (count($this->meta_info) > 0)
|
|
{
|
|
array_shift($this->meta_info);
|
|
}
|
|
}
|
|
}
|