$property; } /** * Magic setter to save protected properties. * * @param string $property * @param mixed $value */ public function __set($property, $value) { $this->$property = $value; } /** * @ORM\PrePersist */ public function setCreateTime() { $this->created = new \DateTime("now"); if (\Utility\Registry::isAuthenticated()) { $this->company = \Utility\Registry::resolveCompanyContext($this->company); $this->createdBy = \Utility\Registry::resolveProfileContext($this->createdBy); } } /** * @ORM\PreUpdate */ public function setUpdateTime() { $this->updated = new \DateTime("now"); } /** * Convert the object to an array. * @param array $expand * @param array $intersect * @return array */ public function toArray( array $expand = array(), array $intersect = array(), $showIdentifiers = false, $expandAll = 0 ) { $includeAll = empty($intersect); $data = array(); ($includeAll || isset($intersect['id'])) && $data['id'] = $this->id; ($includeAll || isset($intersect['company'])) && $data['company'] = (in_array('company', $expand) || $expandAll || $showIdentifiers) && !is_null($this->company) ? (!$showIdentifiers || in_array('company', $expand) ? $this->company->toArray( $expand, $intersect, $showIdentifiers, ($expandAll - 1) ) : $this->company->id) : null; ($includeAll || isset($intersect['createdBy'])) && $data['createdBy'] = (in_array('createdBy', $expand) || $expandAll || $showIdentifiers) && !is_null($this->createdBy) ? (!$showIdentifiers || in_array('createdBy', $expand) ? $this->createdBy->toArray( $expand, $intersect, $showIdentifiers, ($expandAll - 1) ) : $this->createdBy->id) : null; ($includeAll || isset($intersect['stock'])) && $data['stock'] = (in_array('stock', $expand) || $expandAll || $showIdentifiers) && !is_null($this->stock) ? (!$showIdentifiers || in_array('stock', $expand) ? $this->stock->toArray( $expand, $intersect, $showIdentifiers, ($expandAll - 1) ) : $this->stock->id) : null; ($includeAll || isset($intersect['tuhpi'])) && $data['tuhpi'] = (in_array('tuhpi', $expand) || $expandAll || $showIdentifiers) && !is_null($this->tuhpi) ? (!$showIdentifiers || in_array('tuhpi', $expand) ? $this->tuhpi->toArray( $expand, $intersect, $showIdentifiers, ($expandAll - 1) ) : $this->tuhpi->id) : null; ($includeAll || isset($intersect['status'])) && $data['status'] = $this->status; ($includeAll || isset($intersect['created'])) && $data['created'] = !is_null($this->created) ? $this->created->format(\Utility\Registry::getConfigParam('DateTimeFormat')) : null; return $data; } /** * Populate from an array. * @param array $data */ public function fromArray($data = array()) { isset($data['id']) && $this->id = $data['id']; isset($data['company']) && $this->company = $data['company']; isset($data['createdBy']) && $this->createdBy = $data['createdBy']; isset($data['stock']) && $this->stock = $data['stock']; isset($data['tuhpi']) && $this->tuhpi = $data['tuhpi']; isset($data['status']) && $this->status = $data['status']; } }