$property; } /** * Magic setter to save protected properties. * * @param string $property * @param mixed $value */ public function __set($property, $value) { if ('password' == $property) { $this->passwordHash = md5($value); return; } if ('ipAddress' == $property) { $this->authToken = md5($this->clientApiId . time() . $this->passwordHash); $this->ipAddress = $value; return; } $this->$property = $value; } /** * @ORM\PrePersist */ public function setCreateTime() { $this->created = new \DateTime("now"); $this->clientApiId = md5(time() . 'xmlrpc-client'); } /** * @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); $data = array(); ($includeAll || isset($intersect['id'])) && $data['id'] = $this->id; ($includeAll || isset($intersect['clientName'])) && $data['clientName'] = $this->clientName; ($includeAll || isset($intersect['clientApiId'])) && $data['clientApiId'] = $this->clientApiId; ($includeAll || isset($intersect['ipAddress'])) && $data['ipAddress'] = $this->ipAddress; ($includeAll || isset($intersect['callbackUrl'])) && $data['callbackUrl'] = $this->callbackUrl; ($includeAll || isset($intersect['triggerSentToSales'])) && $data['triggerSentToSales'] = $this->triggerSentToSales; ($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; ($includeAll || isset($intersect['archived'])) && $data['archived'] = $this->archived; return $data; } /** * Populate from an array. * @param array $data */ public function fromArray($data = array()) { isset($data['id']) && $this->id = $data['id']; isset($data['clientName']) && $this->clientName = $data['clientName']; isset($data['password']) && $this->passwordHash = md5($data['password']); isset($data['callbackUrl']) && $this->callbackUrl = $data['callbackUrl']; isset($data['triggerSentToSales']) && $this->triggerSentToSales = $data['triggerSentToSales']; isset($data['ipAddress']) && $this->ipAddress = $data['ipAddress']; isset($data['ipAddress']) && $this->authToken = md5($this->clientApiId . time() . $this->passwordHash); } }