public function InvoiceRestModel::getArrayCopy in Invoice 7
Returns this object as array
File
- ./
invoice_classes.inc, line 58
Class
- InvoiceRestModel
- REST invoice model that is used for binding request data and returning the entity result
Code
public function getArrayCopy() {
// Set invoice ID and node ID at the top
$data = (array) $this;
$invoiceId = null;
$nid = null;
foreach ($data as $key => $value) {
if ('id' == $key) {
$invoiceId = $value;
}
elseif ('nid' == $key) {
$nid = $value;
}
}
unset($data['id']);
unset($data['nid']);
$data = array_merge(array(
'nid' => $nid,
), $data);
$data = array_merge(array(
'id' => $invoiceId,
), $data);
// Set customer ID at the top
$customerId = $data['customer']['id'];
unset($data['customer']['id']);
$customer = array_merge(array(
'id' => $customerId,
), $data['customer']);
$data['customer'] = $customer;
return $data;
}