2 namespace Valuation\Entity;
4 use Doctrine\ORM\Mapping as ORM;
9 * An xml-rpc request log entry.
12 * @ORM\HasLifecycleCallbacks
13 * @ORM\Table(name="xmlrpc_callback_log")
15 class XmlRpcCallbackLog
19 * Cannot archive records.
21 const ARCHIVE = false;
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;
35 * @ORM\Column(type="integer");
36 * @ORM\GeneratedValue(strategy="AUTO")
41 * @ORM\ManyToOne(targetEntity="\Valuation\Entity\XmlRpc", cascade={"all"})
42 * @ORM\JoinColumn(nullable=false, name="xmlrpc_auth_id")
44 protected $xmlRpcClient;
47 * @ORM\ManyToOne(targetEntity="Valuation")
48 * @ORM\JoinColumn(nullable=true, name="stock_valuation_id", referencedColumnName="id")
53 * @ORM\Column(type="string", length=250, nullable=false, name="callback_url");
55 protected $callbackUrl;
58 * @ORM\Column(type="string", length=50, nullable=false, name="method_name");
60 protected $methodName;
63 * @ORM\Column(type="text", nullable=true, name="packet");
68 * @ORM\Column(type="text", nullable=true, name="response");
73 * @ORM\Column(type="string", length=50, nullable=false, name="status");
78 * @ORM\Column(type="integer", nullable=false, name="attempts");
80 protected $attempts = 1;
83 * @ORM\Column(type="datetime");
90 * Magic getter to expose protected properties.
92 * @param string $property
95 public function __get($property)
97 return $this->$property;
101 * Magic setter to save protected properties.
103 * @param string $property
104 * @param mixed $value
106 public function __set($property, $value)
108 $this->$property = $value;
114 public function setCreateTime()
116 $this->created = new \DateTime("now");
120 * Convert the object to an array.
121 * @param array $expand
122 * @param array $intersect
123 * @param boolean $showIdentifiers
124 * @param integer $expandAll
127 public function toArray(
128 array $expand = array(), array $intersect = array(),
129 $showIdentifiers = false, $expandAll = 0
132 $intersect = array_flip($intersect);
133 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
134 $includeAll = empty($intersect);
136 ($includeAll || isset($intersect['id']))
137 && $data['id'] = $this->id;
138 ($includeAll || isset($intersect['xmlRpcClient']))
139 && $data['xmlRpcClient'] = (in_array('xmlRpcClient', $expand) || $expandAll || $showIdentifiers)
140 && !is_null($this->xmlRpcClient)
141 ? (!$showIdentifiers || in_array('xmlRpcClient', $expand) ? $this->xmlRpcClient->toArray(
142 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
143 ) : $this->xmlRpcClient->id)
145 ($includeAll || isset($intersect['valuation']))
146 && $data['valuation'] = (in_array('valuation', $expand) || $expandAll || $showIdentifiers)
147 && !is_null($this->valuation)
148 ? (!$showIdentifiers || in_array('valuation', $expand) ? $this->valuation->toArray(
149 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
150 ) : $this->valuation->id)
152 ($includeAll || isset($intersect['callbackUrl']))
153 && $data['callbackUrl'] = $this->callbackUrl;
154 ($includeAll || isset($intersect['methodName']))
155 && $data['methodName'] = $this->methodName;
156 ($includeAll || isset($intersect['packet']))
157 && $data['packet'] = $this->packet;
158 ($includeAll || isset($intersect['response']))
159 && $data['response'] = $this->response;
160 ($includeAll || isset($intersect['status']))
161 && $data['status'] = $this->status;
162 ($includeAll || isset($intersect['created']))
163 && $data['created'] = !is_null($this->created)
164 ? $this->created->format($dateTimeFormat)
170 * Populate from an array.
173 public function fromArray($data = array())
176 && $this->id = $data['id'];
177 isset($data['xmlRpcClient'])
178 && $this->xmlRpcClient = $data['xmlRpcClient'];
179 isset($data['valuation'])
180 && $this->valuation = $data['valuation'];
181 isset($data['callbackUrl'])
182 && $this->callbackUrl = $data['callbackUrl'];
183 isset($data['methodName'])
184 && $this->methodName = $data['methodName'];
185 isset($data['packet'])
186 && $this->packet = is_array($data['packet'])
187 ? serialize($data['packet'])
189 isset($data['response'])
190 && $this->response = is_array($data['response'])
191 ? serialize($data['response'])
193 isset($data['status'])
194 && $this->status = $data['status'];