protected function _mapEricssonModelToModel(array $data) { \App_Util_Array::changePropertyName($data, 'customer', 'customerData'); $data = parent::_mapEricssonModelToModel($data); \App_Util_Array::changePropertyName($data, 'customerData.fiscalNumber', 'customerData.defaultBillingAccount.fiscalNumber'); if (isset($data['customerData'])) { $data['customer'] = OrgCustomerMapper::getInstance()->mapToModel($data['customerData']); unset($data['customerData']); } if (isset($data['serviceProviderData'])) { $data['serviceProvider'] = OrgServiceProviderMapper::getInstance()->mapToModel($data['serviceProviderData']); unset($data['serviceProviderData']); } if (isset($data['billingAccountData'])) { $data['billingAccountName'] = $data['billingAccountData']['name']; if (isset($data['billingAccountData']['region'])) { $data['billingAccountRegion'] = $data['billingAccountData']['region']; } unset($data['billingAccountData']); } \App_Util_Array::changePropertyName($data, 'prebillBillingcycle', 'billingCycle'); if (isset($data['billingCycle'])) { foreach ($data['billingCycle'] as &$bc) { $this->_mapReference($bc, 'billingAccount'); } } $this->_mapReference($data, 'billingAccount'); if (isset($data['datesData'])) { $data += $data['datesData']; unset($data['datesData']); } \App_Util_Array::changePropertiesNames($data, array('totalChargeData' => 'totalCharge', 'totalCharge.adjusts.adjustList' => 'totalCharge.adjusts', 'adjusts.adjustList' => 'adjusts', 'serviceGlobalCharges.basicServicesCustomerCharges' => 'serviceGlobalCharges.basicServices', 'serviceGlobalCharges.basicServices.commercialGroupData' => 'serviceGlobalCharges.basicServices.commercialGroup', 'serviceGlobalCharges.supplementaryServicesCustomerCharges' => 'serviceGlobalCharges.supplServices', 'subscriptionsChargesSummary.basicServices.commercialGroupData' => 'subscriptionsChargesSummary.basicServices.commercialGroup', 'subscriptionsChargesSummary.supplementaryServices' => 'subscriptionsChargesSummary.supplServices')); if (isset($data['serviceGlobalCharges']) && isset($data['serviceGlobalCharges']['basicServices']) && isset($data['serviceGlobalCharges']['basicServices']['commercialGroup'])) { foreach ($data['serviceGlobalCharges']['basicServices']['commercialGroup'] as &$item) { $this->_mapReference($item, 'aggregator'); } } if (isset($data['subscriptionsChargesSummary']) && isset($data['subscriptionsChargesSummary']['basicServices']) && isset($data['subscriptionsChargesSummary']['basicServices']['commercialGroup'])) { foreach ($data['subscriptionsChargesSummary']['basicServices']['commercialGroup'] as &$item) { \App_Util_Array::changePropertiesNames($item, array('oneTimeFee.lifecycleStateChangeEvent' => 'oneTimeFee.lifecycleStatusChangeEvent', 'monthlyFee.activeStateRecurrentFee' => 'monthlyFee.activeStatusRecurrentFee', 'monthlyFee.deactivatedStateRecurrentFee' => 'monthlyFee.deactivatedStatusRecurrentFee', 'monthlyFee.activationReadyRecurrentFee' => 'monthlyFee.activationReadyStatusRecurrentFee', 'monthlyFee.activationPendingRecurrentFee' => 'monthlyFee.activationPendingStatusRecurrentFee')); $this->_mapReference($item, 'aggregator'); } } if (!isset($data["published"])) { $data["published"] = isset($data["issuedDate"]) && $data["issuedDate"]; } $customerDiscounts = \App_Util_Array::getItem($data, 'totalCharge.discounts.customer'); if (empty($customerDiscounts)) { \App_Util_Array::unsetItem($data, 'totalCharge.discounts.customer'); } return $data; }
public function testChangeProperties() { \App_Util_Array::changePropertiesNames($this->_data, array('a.b.c' => 'a.b', 'a.d.e' => 'a.d', 'a.d' => 'f.c', 'z' => 'a.z')); $this->assertEquals($this->_data, array('a' => array('b' => '1'), 'f' => array('g' => '3', 'c' => '2'), 'h' => array(), 'i' => '', 'j' => array('k' => array()), 'l' => array('m' => array(), 'n' => ''))); }
protected function _mapModelToEricssonModel(array $data) { $fieldMap = static::$_protoMessageFields; $mappedData = array(); if (!isset($data['description']) || !$data['description']) { $mappedData['description'] = 'description'; } \App_Util_Array::changePropertiesNames($data, $fieldMap); $exclude = array_values($fieldMap); $mappedData += self::filterFieldNames(array(new \Zend_Filter_Word_CamelCaseToUnderscore(), new \Zend_Filter_StringToLower()), $data, $exclude); return $mappedData; }