Exemplo n.º 1
0
 /**
  * Builds the SearchCriteria Data Object
  *
  * @return SearchCriteria
  */
 public function create()
 {
     //Initialize with empty array if not set
     if (empty($this->_data[SearchCriteria::FILTER_GROUPS])) {
         $this->_set(SearchCriteria::FILTER_GROUPS, []);
     }
     return parent::create();
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function _setDataValues(array $data)
 {
     if (isset($data[FilterGroup::FILTERS])) {
         $filters = [];
         foreach ($data[FilterGroup::FILTERS] as $filter) {
             $filters[] = $this->_filterBuilder->populateWithArray($filter)->create();
         }
         $data[FilterGroup::FILTERS] = $filters;
     }
     return parent::_setDataValues($data);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 protected function _setDataValues(array $data)
 {
     if (array_key_exists(SearchResults::KEY_SEARCH_CRITERIA, $data)) {
         $data[SearchResults::KEY_SEARCH_CRITERIA] = $this->searchCriteriaBuilder->populateWithArray($data[SearchResults::KEY_SEARCH_CRITERIA])->create();
     }
     if (array_key_exists(SearchResults::KEY_ITEMS, $data)) {
         $items = [];
         foreach ($data[SearchResults::KEY_ITEMS] as $itemArray) {
             $items[] = $this->itemObjectBuilder->populateWithArray($itemArray)->create();
         }
         $data[SearchResults::KEY_ITEMS] = $items;
     }
     return parent::_setDataValues($data);
 }
Exemplo n.º 4
0
 /**
  * Get custom attributes codes
  *
  * @return string[]
  */
 public function getCustomAttributesCodes()
 {
     return array_merge(parent::getCustomAttributesCodes(), $this->customAttributes);
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 protected function _setDataValues(array $data)
 {
     if (array_key_exists(AppliedTax::KEY_RATES, $data)) {
         $rates = [];
         foreach ($data[AppliedTax::KEY_RATES] as $rateArray) {
             $rates[] = $this->appliedTaxRateBuilder->populateWithArray($rateArray)->create();
         }
         $data[AppliedTax::KEY_RATES] = $rates;
     }
     return parent::_setDataValues($data);
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 protected function _setDataValues(array $data)
 {
     if (array_key_exists(Item::KEY_TAX_CLASS_KEY, $data)) {
         $data[Item::KEY_TAX_CLASS_KEY] = $this->taxClassKeyBuilder->populateWithArray($data[Item::KEY_TAX_CLASS_KEY])->create();
     }
     return parent::_setDataValues($data);
 }
Exemplo n.º 7
0
 /**
  * Initialize dependencies.
  *
  * @param ObjectFactory $objectFactory
  * @param AttributeValueBuilder $valueBuilder
  * @param MetadataServiceInterface $metadataService
  * @param TaxRateBuilder $taxRateBuilder
  */
 public function __construct(ObjectFactory $objectFactory, AttributeValueBuilder $valueBuilder, MetadataServiceInterface $metadataService, TaxRateBuilder $taxRateBuilder)
 {
     parent::__construct($objectFactory, $valueBuilder, $metadataService);
     $this->taxRateBuilder = $taxRateBuilder;
 }
Exemplo n.º 8
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _setDataValues(array $data)
 {
     if (array_key_exists(AttributeMetadata::OPTIONS, $data)) {
         $options = array();
         if (is_array($data[AttributeMetadata::OPTIONS])) {
             foreach ($data[AttributeMetadata::OPTIONS] as $key => $option) {
                 $options[$key] = $this->optionBuilder->populateWithArray($option)->create();
             }
         }
         $validationRules = array();
         if (is_array($data[AttributeMetadata::VALIDATION_RULES])) {
             foreach ($data[AttributeMetadata::VALIDATION_RULES] as $key => $value) {
                 $validationRules[$key] = $this->validationRuleBuilder->populateWithArray($value)->create();
             }
         }
         $data[AttributeMetadata::OPTIONS] = $options;
         $data[AttributeMetadata::VALIDATION_RULES] = $validationRules;
     }
     // fill frontend labels
     if (isset($data[AttributeMetadata::FRONTEND_LABEL]) && is_array($data[AttributeMetadata::FRONTEND_LABEL])) {
         $frontendLabel = [];
         foreach ($data[AttributeMetadata::FRONTEND_LABEL] as $key => $value) {
             $frontendLabel[$key] = $this->frontendLabelBuilder->populateWithArray($value)->create();
         }
         $data[AttributeMetadata::FRONTEND_LABEL] = $frontendLabel;
     }
     if (array_key_exists(AttributeMetadata::APPLY_TO, $data)) {
         $data[AttributeMetadata::APPLY_TO] = $this->processApplyToValue($data[AttributeMetadata::APPLY_TO]);
     }
     return parent::_setDataValues($data);
 }
Exemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 protected function _setDataValues(array $data)
 {
     if (isset($data[Item::KEY_APPLIED_TAXES])) {
         $appliedTaxDataObjects = [];
         $appliedTaxes = $data[Item::KEY_APPLIED_TAXES];
         foreach ($appliedTaxes as $appliedTax) {
             $appliedTaxDataObjects[] = $this->appliedTaxBuilder->populateWithArray($appliedTax)->create();
         }
         $data[Item::KEY_APPLIED_TAXES] = $appliedTaxDataObjects;
     }
     return parent::_setDataValues($data);
 }
Exemplo n.º 10
0
 /**
  * Test constructor and getters
  *
  * @dataProvider constructorAndGettersDataProvider
  */
 public function testConstructorAndGetters($method, $key, $expectedValue)
 {
     $this->builderMock->expects($this->once())->method('getData')->will($this->returnValue([$key => $expectedValue]));
     $attributeMetadata = new AttributeMetadata($this->builderMock);
     $this->assertEquals($expectedValue, $attributeMetadata->{$method}());
 }
Exemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 protected function _setDataValues(array $data)
 {
     if (array_key_exists(QuoteDetails::KEY_BILLING_ADDRESS, $data)) {
         $data[QuoteDetails::KEY_BILLING_ADDRESS] = $this->addressBuilder->populateWithArray($data[QuoteDetails::KEY_BILLING_ADDRESS])->create();
     }
     if (array_key_exists(QuoteDetails::KEY_SHIPPING_ADDRESS, $data)) {
         $data[QuoteDetails::KEY_SHIPPING_ADDRESS] = $this->addressBuilder->populateWithArray($data[QuoteDetails::KEY_SHIPPING_ADDRESS])->create();
     }
     if (array_key_exists(QuoteDetails::KEY_ITEMS, $data)) {
         $items = [];
         foreach ($data[QuoteDetails::KEY_ITEMS] as $itemArray) {
             $items[] = $this->itemBuilder->populateWithArray($itemArray)->create();
         }
         $data[QuoteDetails::KEY_ITEMS] = $items;
     }
     if (array_key_exists(QuoteDetails::KEY_CUSTOMER_TAX_CLASS_KEY, $data)) {
         $data[QuoteDetails::KEY_CUSTOMER_TAX_CLASS_KEY] = $this->taxClassKeyBuilder->populateWithArray($data[QuoteDetails::KEY_CUSTOMER_TAX_CLASS_KEY])->create();
     }
     return parent::_setDataValues($data);
 }
Exemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function _setDataValues(array $data)
 {
     if (isset($data[OrderTaxDetails::KEY_APPLIED_TAXES])) {
         $appliedTaxDataObjects = [];
         $appliedTaxes = $data[OrderTaxDetails::KEY_APPLIED_TAXES];
         foreach ($appliedTaxes as $appliedTax) {
             $appliedTaxDataObjects[] = $this->appliedTaxBuilder->populateWithArray($appliedTax)->create();
         }
         $data[OrderTaxDetails::KEY_APPLIED_TAXES] = $appliedTaxDataObjects;
     }
     if (isset($data[OrderTaxDetails::KEY_ITEMS])) {
         $taxDetailItemDataObjects = [];
         $taxDetailItems = $data[OrderTaxDetails::KEY_ITEMS];
         foreach ($taxDetailItems as $taxDetailItem) {
             $taxDetailItemDataObjects[] = $this->itemBuilder->populateWithArray($taxDetailItem)->create();
         }
         $data[OrderTaxDetails::KEY_ITEMS] = $taxDetailItemDataObjects;
     }
     return parent::_setDataValues($data);
 }
Exemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 protected function _setDataValues(array $data)
 {
     if (array_key_exists(TaxRate::KEY_ZIP_RANGE, $data)) {
         $data[TaxRate::KEY_ZIP_RANGE] = $this->zipRangeBuilder->populateWithArray($data[TaxRate::KEY_ZIP_RANGE])->create();
     }
     if (array_key_exists(TaxRate::KEY_TITLES, $data)) {
         $titles = array();
         foreach ($data[TaxRate::KEY_TITLES] as $titleData) {
             $titles[] = $this->taxRateTitleBuilder->populateWithArray($titleData)->create();
         }
         $data[TaxRate::KEY_TITLES] = $titles;
     }
     return parent::_setDataValues($data);
 }
Exemplo n.º 14
0
 /**
  * @param \Magento\Framework\Service\Data\ObjectFactory $objectFactory
  * @param AttributeValueBuilder $valueBuilder
  * @param \Magento\Catalog\Service\V1\Product\MetadataServiceInterface $metadataService
  */
 public function __construct(\Magento\Framework\Service\Data\ObjectFactory $objectFactory, AttributeValueBuilder $valueBuilder, \Magento\Catalog\Service\V1\Product\MetadataServiceInterface $metadataService)
 {
     parent::__construct($objectFactory, $valueBuilder, $metadataService);
 }
Exemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 protected function _setDataValues(array $data)
 {
     if (array_key_exists(AttributeMetadata::OPTIONS, $data)) {
         $options = array();
         if (is_array($data[AttributeMetadata::OPTIONS])) {
             foreach ($data[AttributeMetadata::OPTIONS] as $key => $option) {
                 $options[$key] = $this->_optionBuilder->populateWithArray($option)->create();
             }
         }
         $validationRules = array();
         if (is_array($data[AttributeMetadata::VALIDATION_RULES])) {
             foreach ($data[AttributeMetadata::VALIDATION_RULES] as $key => $value) {
                 $validationRules[$key] = $this->_validationRuleBuilder->populateWithArray($value)->create();
             }
         }
         $data[AttributeMetadata::OPTIONS] = $options;
         $data[AttributeMetadata::VALIDATION_RULES] = $validationRules;
     }
     return parent::_setDataValues($data);
 }
Exemplo n.º 16
0
 /**
  * {@inheritdoc}
  */
 protected function _setDataValues(array $data)
 {
     if (array_key_exists(Address::KEY_REGION, $data)) {
         if (!is_array($data[Address::KEY_REGION])) {
             // Region data has been submitted as individual keys of Address object. Let's extract it.
             $regionData = array();
             foreach (array(Region::KEY_REGION, Region::KEY_REGION_CODE, Region::KEY_REGION_ID) as $attrCode) {
                 if (isset($data[$attrCode])) {
                     $regionData[$attrCode] = $data[$attrCode];
                 }
             }
         } else {
             $regionData = $data[Address::KEY_REGION];
         }
         $data[Address::KEY_REGION] = $this->_regionBuilder->populateWithArray($regionData)->create();
     }
     return parent::_setDataValues($data);
 }
Exemplo n.º 17
0
 /**
  * Builds the entity.
  *
  * @return \Magento\Customer\Service\V1\Data\CustomerDetails
  */
 public function create()
 {
     if (!isset($this->_data[CustomerDetails::KEY_CUSTOMER])) {
         $this->_data[CustomerDetails::KEY_CUSTOMER] = $this->_customerBuilder->create();
     }
     if (!isset($this->_data[CustomerDetails::KEY_ADDRESSES])) {
         $this->_data[CustomerDetails::KEY_ADDRESSES] = null;
     }
     return parent::create();
 }