$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"); } /** * @ORM\PreUpdate */ public function setUpdateTime() { $this->updated = new \DateTime("now"); } /** * Convert the object to an array. * @param array $expand * @param array $intersect * @param boolean $showIdentifiers * @param integer $expandAll * @return array */ public function toArray( array $expand = array(), array $intersect = array(), $showIdentifiers = false, $expandAll = 0 ) { $intersect = array_flip($intersect); $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat'); $includeAll = empty($intersect); $recExpand = $expand; foreach($recExpand as $i => $val) { if ('company' == $val || 'tradeCenter' == $val) { unset($recExpand[$i]); } } $data = array(); ($includeAll || isset($intersect['id'])) && $data['id'] = $this->id; ($includeAll || isset($intersect['pushKey'])) && $data['pushKey'] = $this->pushKey; ($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['profile'])) && $data['profile'] = (in_array('profile', $expand) || $expandAll || $showIdentifiers) && !is_null($this->profile) ? (!$showIdentifiers || in_array('profile', $expand) ? $this->profile->toArray( $expand, $intersect, $showIdentifiers, ($expandAll - 1) ) : $this->profile->id) : null; ($includeAll || isset($intersect['device'])) && $data['device'] = (in_array('device', $expand) || $expandAll || $showIdentifiers) && !is_null($this->device) ? (!$showIdentifiers || in_array('device', $expand) ? $this->device->toArray( $expand, $intersect, $showIdentifiers, ($expandAll - 1) ) : $this->device->id) : null; ($includeAll || isset($intersect['created'])) && $data['created'] = !is_null($this->created) ? $this->created->format($dateTimeFormat) : null; ($includeAll || isset($intersect['updated'])) && $data['updated'] = !is_null($this->updated) ? $this->updated->format($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['pushKey']) && $this->pushKey = $data['pushKey']; isset($data['company']) && $this->company = $data['company']; isset($data['profile']) && $this->profile = $data['profile']; isset($data['device']) && $this->device = $data['device']; } }