本文整理汇总了PHP中ActiveRecordModel::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecordModel::toArray方法的具体用法?PHP ActiveRecordModel::toArray怎么用?PHP ActiveRecordModel::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecordModel
的用法示例。
在下文中一共展示了ActiveRecordModel::toArray方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
protected function save(ActiveRecordModel $listGroup)
{
$validator = $this->buildValidator();
if ($validator->isValid()) {
$listGroup->loadRequestData($this->request);
$listGroup->save();
return new JSONResponse(array('ID' => $listGroup->getID(), 'data' => $listGroup->toArray()), 'success');
} else {
return new JSONResponse(array('errors' => $validator->getErrorList()), 'failure');
}
}
示例2: toArray
public function toArray()
{
$array = parent::toArray();
$array['newPassword'] = $this->newPassword;
$this->setArrayData($array);
return $array;
}
示例3: toArray
public function toArray()
{
$array = parent::toArray();
$currencyID = $array['OrderedItem']['CustomerOrder']['currencyID'];
$currency = Currency::getInstanceByID($currencyID);
$array['ProductPrice_setup']['formated_price'][$currencyID] = $currency->getFormattedPrice($array['setupPrice']);
$array['ProductPrice_period']['formated_price'][$currencyID] = $currency->getFormattedPrice($array['periodPrice']);
return $array;
}
示例4: toArray
public function toArray($amount = null)
{
$array = parent::toArray();
$array['formattedAmount'] = array();
$amountCurrency = $this->shipment->get()->getCurrency();
// get and format prices
$array['formattedAmount'][$amountCurrency->getID()] = $amountCurrency->getFormattedPrice($this->getAmount($amount));
if (!is_null($amount)) {
$array['amount'] = $amount;
}
return $array;
}
示例5: toArray
/**
* Creates an array representation of the shopping cart
*/
public function toArray($options = array())
{
$currency = $this->getCurrency();
$id = $currency->getID();
if (is_array($this->orderedItems)) {
foreach ($this->orderedItems as $item) {
if (!$item->getProduct()->isPricingLoaded()) {
if (!isset($products)) {
$products = new ARSet();
}
$products->unshift($item->getProduct());
}
}
}
$array = parent::toArray();
$array['cartItems'] = array();
$array['wishListItems'] = array();
if (is_array($this->orderedItems)) {
foreach ($this->orderedItems as $item) {
if ($item->isSavedForLater->get()) {
$array['wishListItems'][] = $item->toArray();
} else {
$array['cartItems'][] = $item->toArray();
}
}
}
$array['basketCount'] = $this->getShoppingCartItemCount();
$array['wishListCount'] = $this->getWishListItemCount();
// shipments
$array['shipments'] = array();
if ($this->shipments) {
foreach ($this->shipments as $shipment) {
if (count($shipment->getItems())) {
$array['shipments'][] = $shipment->toArray();
}
}
}
// total for all currencies
$total = array();
$total[$id] = $this->getTotal();
// taxes
$array['taxes'] = $taxAmount = array();
$taxAmount[$id] = 0;
$array['taxes'][$id] = array();
foreach ($this->taxes as $taxId => $amount) {
if ($amount > 0) {
$taxAmount[$id] += $amount;
$tax = Tax::getInstanceById($taxId)->toArray();
$tax['amount'] = $amount;
$tax['formattedAmount'] = $currency->getFormattedPrice($amount);
$array['taxes'][$id][] = $tax;
}
}
$array['taxAmount'] = $taxAmount[$id];
foreach ($this->taxDetails as &$taxRate) {
$taxRate['formattedAmount'] = $currency->getFormattedPrice($taxRate['amount']);
}
$array['taxDetails'] = $this->taxDetails;
$array['total'] = $total;
$array['formattedTotal'] = $array['formattedTotalBeforeTax'] = array();
if (is_array($array['total'])) {
foreach ($array['total'] as $id => $amount) {
if (!isset($taxAmount[$id])) {
$taxAmount[$id] = 0;
}
$array['formattedTotalBeforeTax'][$id] = $currency->getFormattedPrice($amount - $taxAmount[$id]);
$array['formattedTotal'][$id] = $currency->getFormattedPrice($amount);
}
}
// order type
$array['isShippingRequired'] = (int) $this->isShippingRequired();
// status
$array['isReturned'] = (int) $this->isReturned();
$array['isShipped'] = (int) $this->isShipped();
$array['isAwaitingShipment'] = (int) $this->isAwaitingShipment();
$array['isProcessing'] = (int) $this->isProcessing();
// payments
if (isset($options['payments'])) {
$array['amountPaid'] = $this->getPaidAmount();
$array['amountNotCaptured'] = $array['amountPaid'] - $array['capturedAmount'];
if ($array['amountNotCaptured'] < 0) {
$array['amountNotCaptured'] = 0;
}
$array['amountDue'] = $array['totalAmount'] - $array['amountPaid'];
if ($array['amountDue'] < 0) {
$array['amountDue'] = 0;
}
}
// items subtotal
$array['itemSubtotal'] = $array['itemDisplayPriceTotal'] = $array['itemSubtotalWithoutTax'] = 0;
foreach ($this->getOrderedItems() as $item) {
$array['itemSubtotal'] += $item->getSubtotal(true);
$array['itemSubtotalWithoutTax'] += $item->getSubtotal(false);
$array['itemDisplayPriceTotal'] += $item->getDisplayPrice($currency) * $item->count->get();
}
$array['itemDiscount'] = $array['itemDisplayPriceTotal'] - $array['itemSubtotal'];
$array['itemDiscountReverse'] = $array['itemDiscount'] * -1;
//.........这里部分代码省略.........
示例6: toArray
public function toArray()
{
$array = parent::toArray();
$array['isVoidable'] = $this->isVoidable();
$array['isCapturable'] = $this->isCapturable();
$array['isMultiCapture'] = $this->isMultiCapture();
$array['hasFullNumber'] = strlen(self::decrypt($this->ccLastDigits->get())) > self::LAST_DIGIT_COUNT;
return $array;
}
示例7: exportInstance
public function exportInstance(ActiveRecordModel $instance)
{
return $this->exportArray($instance->toArray());
}
示例8: toArray
public function toArray()
{
$array = parent::toArray();
$currency = $this->getCurrency();
$id = $currency->getID();
// ordered items
$items = array();
foreach ($this->items as $item) {
$items[] = $item->toArray();
}
$array['items'] = $items;
// subtotal
$currencies = self::getApplication()->getCurrencySet();
$array['subTotal'][$id] = $this->getSubTotal();
// total amount
$array['totalAmount'] = $this->getTotal();
$array['formatted_totalAmount'] = $this->order->get()->currency->get()->getFormattedPrice($array['totalAmount']);
$array['formatted_amount'] = $this->order->get()->currency->get()->getFormattedPrice($array['amount']);
// formatted subtotal
$array['formattedSubTotal'] = $array['formattedSubTotalBeforeTax'] = array();
$array['formattedSubTotal'][$id] = $currency->getFormattedPrice($array['subTotal'][$id]);
$array['formattedSubTotalBeforeTax'][$id] = $currency->getFormattedPrice($array['subTotal'][$id] - $this->getTaxAmount());
// selected shipping rate
if ($selected = $this->getSelectedRate()) {
$array['selectedRate'] = $selected->toArray($this->applyTaxesToShippingAmount($selected->getCostAmount()));
if (!$array['selectedRate']) {
unset($array['selectedRate']);
} else {
$array['ShippingService'] = $array['selectedRate']['ShippingService'];
}
}
// shipping rate for a saved shipment
if (!isset($array['selectedRate']) && isset($array['shippingAmount'])) {
$array['shippingAmountWithoutTax'] = $array['shippingAmount'];
$array['shippingAmount'] = $this->applyTaxesToShippingAmount($array['shippingAmount']);
$orderCurrency = $this->order->get()->currency->get();
$array['selectedRate']['formattedPrice'] = array();
foreach ($currencies as $id => $currency) {
$rate = $currency->convertAmount($orderCurrency, $array['shippingAmount']);
$array['selectedRate']['formattedPrice'][$id] = Currency::getInstanceById($id)->getFormattedPrice($rate);
$array['selectedRate']['formattedPriceWithoutTax'][$id] = Currency::getInstanceById($id)->getFormattedPrice($array['shippingAmountWithoutTax']);
}
}
// taxes
$taxes = array();
foreach ($this->getTaxes() as $tax) {
if ($tax->taxRate->get()) {
$taxes[$tax->taxRate->get()->tax->get()->getID()][] = $tax;
}
}
foreach ($taxes as $taxType) {
$amount = 0;
foreach ($taxType as $tax) {
$amount += $tax->amount->get();
}
if ($amount > 0) {
$array['taxes'][] = $tax->toArray($amount);
}
}
// consists of downloadable files only?
$array['isShippable'] = $this->isShippable();
// Statuses
$array['isReturned'] = (int) $this->isReturned();
$array['isShipped'] = (int) $this->isShipped();
$array['isAwaitingShipment'] = (int) $this->isAwaitingShipment();
$array['isProcessing'] = (int) $this->isProcessing();
$array['isDelivered'] = (int) $this->isDelivered();
$array['isLost'] = (int) $this->isLost();
$array['AmountCurrency'] =& $array['Order']['Currency'];
return $array;
}
示例9: toArray
/**
* Creates an array representation of this node
*
* @return array
*/
public function toArray()
{
$data = parent::toArray();
foreach ($this->data as $name => $field) {
if ($name == self::PARENT_NODE_FIELD_NAME && $field->get() != null) {
$data['parent'] = $field->get()->getID();
}
}
$data["childrenCount"] = ($data[self::RIGHT_NODE_FIELD_NAME] - $data[self::LEFT_NODE_FIELD_NAME] - 1) / 2;
$childArray = array();
if ($this->childList != null) {
foreach ($this->childList as $child) {
$childArray[] = $child->toArray();
}
$data['children'] = $childArray;
}
return $data;
}
示例10: toArray
public function toArray()
{
$array = parent::toArray();
$array['formatted_amount'] = $this->order->get()->currency->get()->getFormattedPrice($array['amount'] * -1);
return $array;
}
示例11: toArray
public function toArray()
{
$array = parent::toArray();
$info = self::getApplication()->getLocale()->info();
$array['name'] = $info->getLanguageName($array['ID']);
$array['originalName'] = $info->getOriginalLanguageName($array['ID']);
if (file_exists(ClassLoader::getRealPath('public.image.localeflag') . '/' . $array['ID'] . '.png')) {
$array['image'] = 'image/localeflag/' . $array['ID'] . '.png';
}
return $array;
}