2 namespace Valuation\Entity;
4 use Doctrine\ORM\Mapping as ORM;
12 * @ORM\HasLifecycleCallbacks
13 * @ORM\Table(name="customer_public_valuation")
15 class CustomerPublicValuation
19 * Can archive records.
23 * Pull Synchronization Strategy for this table.
25 const PULL_SYNCH_STRATEGY = 'Build';
27 * Push Synchronization Strategy for this table.
29 const PUSH_SYNCH_STRATEGY = 'Update';
31 * Post insert action must be called after new entity is flushed to database.
33 const HAVE_POST_INSERT = true;
35 * Handle as a job queue for mobile devices.
37 const JOB_QUEUE = true;
42 /* ------------------------------------ Identification ------------------------------------ */
45 * @ORM\Column(type="integer");
46 * @ORM\GeneratedValue(strategy="AUTO")
51 * @ORM\Column(type="string", length=255, nullable=true, name="customer_hash");
53 protected $customerHash;
56 /* ------------------------------------ Ownership ------------------------------------ */
58 * @ORM\ManyToOne(targetEntity="\Stock\Entity\Stock", cascade={"all"})
59 * @ORM\JoinColumn(nullable=false, name="stock_id")
64 * @ORM\ManyToOne(targetEntity="\Valuation\Entity\Valuation", cascade={"all"})
65 * @ORM\JoinColumn(nullable=false, name="valuation_id")
70 * @ORM\Column(type="datetime");
75 * @ORM\Column(type="datetime", nullable=true);
80 * @ORM\Column(type="boolean");
82 protected $archived = false;
85 * Magic getter to expose protected properties.
87 * @param string $property
90 public function __get($property)
92 return $this->$property;
96 // * Magic setter to save protected properties.
98 // * @param string $property
99 // * @param mixed $value
101 // public function __set($property, $value)
103 // if ('password' == $property)
105 // $this->customerHash = md5($value);
108 // $this->$property = $value;
114 public function setCreateTime()
116 $this->created = new \DateTime("now");
122 public function setUpdateTime()
124 $this->updated = new \DateTime("now");
128 * Convert the object to an array.
129 * @param array $expand
130 * @param array $intersect
131 * @param boolean $showIdentifiers
132 * @param integer $expandAll
135 public function toArray(
136 array $expand = array(), array $intersect = array(),
137 $showIdentifiers = false, $expandAll = 0
140 $intersect = array_flip($intersect);
141 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
142 $includeAll = empty($intersect);
144 ($includeAll || isset($intersect['id']))
145 && $data['id'] = $this->id;
146 ($includeAll || isset($intersect['customerHash']))
147 && $data['customerHash'] = $this->customerHash;
148 ($includeAll || isset($intersect['stock']))
149 && $data['stock'] = $this->stock;
150 ($includeAll || isset($intersect['valuation']))
151 && $data['valuation'] = $this->valuation;
152 ($includeAll || isset($intersect['created']))
153 && $data['created'] = !is_null($this->created)
154 ? $this->created->format($dateTimeFormat)
156 ($includeAll || isset($intersect['updated']))
157 && $data['updated'] = !is_null($this->updated)
158 ? $this->updated->format($dateTimeFormat)
160 ($includeAll || isset($intersect['archived']))
161 && $data['archived'] = $this->archived;
166 * Populate from an array.
169 public function fromArray($data = array())
172 && $this->id = $data['id'];
173 isset($data['customerHash'])
174 && $this->customerHash = $data['customerHash'];
175 isset($data['stock'])
176 && $this->stock = $data['stock'];
177 isset($data['valuation'])
178 && $this->valuation = $data['valuation'];