2 namespace Valuation\Entity;
4 use Doctrine\ORM\Mapping as ORM;
12 * @ORM\HasLifecycleCallbacks
13 * @ORM\Table(name="xmlrpc_auth")
19 * Can archive records.
23 * Pull Synchronization Strategy for this table.
25 const PULL_SYNCH_STRATEGY = false;
27 * Push Synchronization Strategy for this table.
29 const PUSH_SYNCH_STRATEGY = false;
33 /* ------------------------------------ Identification ------------------------------------ */
36 * @ORM\Column(type="integer");
37 * @ORM\GeneratedValue(strategy="AUTO")
42 * @ORM\Column(type="string", length=50, nullable=false, name="client_name");
44 protected $clientName;
47 * @ORM\Column(type="string", length=42, nullable=false, name="client_api_id");
49 protected $clientApiId;
52 * @ORM\Column(type="string", length=42, nullable=false, name="password_hash");
54 protected $passwordHash;
57 * @ORM\Column(type="string", length=42, nullable=true, name="auth_token");
62 * @ORM\Column(type="string", length=40, nullable=true, name="ip_address");
67 * @ORM\Column(type="string", length=250, nullable=false, name="callback_url");
69 protected $callbackUrl;
72 * @ORM\Column(type="boolean", name="trigger_sent_to_sales");
74 protected $triggerSentToSales = true;
77 * @ORM\Column(type="datetime");
82 * @ORM\Column(type="datetime", nullable=true);
87 * @ORM\Column(type="boolean");
89 protected $archived = false;
94 * Magic getter to expose protected properties.
96 * @param string $property
99 public function __get($property)
101 return $this->$property;
105 * Magic setter to save protected properties.
107 * @param string $property
108 * @param mixed $value
110 public function __set($property, $value)
112 if ('password' == $property)
114 $this->passwordHash = md5($value);
117 if ('ipAddress' == $property)
119 $this->authToken = md5($this->clientApiId . time() . $this->passwordHash);
120 $this->ipAddress = $value;
123 $this->$property = $value;
129 public function setCreateTime()
131 $this->created = new \DateTime("now");
132 $this->clientApiId = md5(time() . 'xmlrpc-client');
138 public function setUpdateTime()
140 $this->updated = new \DateTime("now");
144 * Convert the object to an array.
145 * @param array $expand
146 * @param array $intersect
147 * @param boolean $showIdentifiers
148 * @param integer $expandAll
151 public function toArray(
152 array $expand = array(), array $intersect = array(),
153 $showIdentifiers = false, $expandAll = 0
156 $intersect = array_flip($intersect);
157 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
158 $includeAll = empty($intersect);
160 ($includeAll || isset($intersect['id']))
161 && $data['id'] = $this->id;
162 ($includeAll || isset($intersect['clientName']))
163 && $data['clientName'] = $this->clientName;
164 ($includeAll || isset($intersect['clientApiId']))
165 && $data['clientApiId'] = $this->clientApiId;
166 ($includeAll || isset($intersect['ipAddress']))
167 && $data['ipAddress'] = $this->ipAddress;
168 ($includeAll || isset($intersect['callbackUrl']))
169 && $data['callbackUrl'] = $this->callbackUrl;
170 ($includeAll || isset($intersect['triggerSentToSales']))
171 && $data['triggerSentToSales'] = $this->triggerSentToSales;
172 ($includeAll || isset($intersect['created']))
173 && $data['created'] = !is_null($this->created)
174 ? $this->created->format($dateTimeFormat)
176 ($includeAll || isset($intersect['updated']))
177 && $data['updated'] = !is_null($this->updated)
178 ? $this->updated->format($dateTimeFormat)
180 ($includeAll || isset($intersect['archived']))
181 && $data['archived'] = $this->archived;
186 * Populate from an array.
189 public function fromArray($data = array())
192 && $this->id = $data['id'];
193 isset($data['clientName'])
194 && $this->clientName = $data['clientName'];
195 isset($data['password'])
196 && $this->passwordHash = md5($data['password']);
197 isset($data['callbackUrl'])
198 && $this->callbackUrl = $data['callbackUrl'];
199 isset($data['triggerSentToSales'])
200 && $this->triggerSentToSales = $data['triggerSentToSales'];
201 isset($data['ipAddress'])
202 && $this->ipAddress = $data['ipAddress'];
203 isset($data['ipAddress'])
204 && $this->authToken = md5($this->clientApiId . time() . $this->passwordHash);