• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Api\DataObjectHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Framework\Api\DataObjectHelper的典型用法代码示例。如果您正苦于以下问题:PHP DataObjectHelper类的具体用法?PHP DataObjectHelper怎么用?PHP DataObjectHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DataObjectHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     if (!function_exists('libxml_set_external_entity_loader')) {
         $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
     }
     $this->customer = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\CustomerInterface', [], '', false, true, true);
     $this->customer->expects($this->once())->method('getWebsiteId')->willReturn(2);
     $this->customerDataFactory = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterfaceFactory', ['create'], [], '', false);
     $this->customerDataFactory->expects($this->once())->method('create')->willReturn($this->customer);
     $this->form = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', [], [], '', false);
     $this->request = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface', [], '', false, true, true, ['getPost']);
     $this->response = $this->getMockForAbstractClass('Magento\\Framework\\App\\ResponseInterface', [], '', false);
     $this->formFactory = $this->getMock('Magento\\Customer\\Model\\Metadata\\FormFactory', ['create'], [], '', false);
     $this->formFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->form);
     $this->extensibleDataObjectConverter = $this->getMock('Magento\\Framework\\Api\\ExtensibleDataObjectConverter', [], [], '', false);
     $this->dataObjectHelper = $this->getMock('Magento\\Framework\\Api\\DataObjectHelper', [], [], '', false);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray');
     $this->customerAccountManagement = $this->getMockForAbstractClass('Magento\\Customer\\Api\\AccountManagementInterface', [], '', false, true, true);
     $this->resultJson = $this->getMock('Magento\\Framework\\Controller\\Result\\Json', [], [], '', false);
     $this->resultJson->expects($this->once())->method('setData');
     $this->resultJsonFactory = $this->getMock('Magento\\Framework\\Controller\\Result\\JsonFactory', ['create'], [], '', false);
     $this->resultJsonFactory->expects($this->once())->method('create')->willReturn($this->resultJson);
     $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->controller = $objectHelper->getObject('Magento\\Customer\\Controller\\Adminhtml\\Index\\Validate', ['request' => $this->request, 'response' => $this->response, 'customerDataFactory' => $this->customerDataFactory, 'formFactory' => $this->formFactory, 'extensibleDataObjectConverter' => $this->extensibleDataObjectConverter, 'customerAccountManagement' => $this->customerAccountManagement, 'resultJsonFactory' => $this->resultJsonFactory, 'dataObjectHelper' => $this->dataObjectHelper]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:ValidateTest.php


示例2: copyQuoteAddressToCustomerAddress

 /**
  * Copies a quote address to a customer address
  *
  * Ths function serves to create a customer address from a quote address because when a user is logged in and they
  * go to checkout, if they select an existing customer address the checkout module will retrieve that customer
  * address to set as the quote address. Rather that update the quote address every time at checkout, this module
  * will update the customer address (if the user selects the valid address) so that customer address only needs
  * to be validated once. To do this, the quote address must be converted to a customer address so the validated
  * address can be saved to the quote address.
  *
  * @param QuoteAddressInterface $quoteAddress
  * @param CustomerAddressInterface $customerAddress
  * @return null|CustomerAddressInterface
  */
 public function copyQuoteAddressToCustomerAddress(QuoteAddressInterface $quoteAddress, CustomerAddressInterface $customerAddress)
 {
     $customerAddress->setRegionId($quoteAddress->getRegionId());
     $customerAddress->setCountryId($quoteAddress->getCountryId());
     $customerAddress->setStreet($quoteAddress->getStreet());
     $customerAddress->setPostcode($quoteAddress->getPostcode());
     $customerAddress->setCity($quoteAddress->getCity());
     $customerAddressData = $this->getCustomerAddressData($customerAddress);
     $customerAddressDataWithRegion = [];
     $customerAddressDataWithRegion['region']['region'] = $quoteAddress->getRegion();
     $customerAddressDataWithRegion['region']['region_code'] = $quoteAddress->getRegionCode();
     if ($customerAddressData['region_id']) {
         $customerAddressDataWithRegion['region']['region_id'] = $quoteAddress->getRegionId();
     }
     $customerAddressData = array_merge($customerAddressData, $customerAddressDataWithRegion);
     // Per Github issue #4, the \Magento\Framework\Api\DataObjectHelper::_setDataValues method chokes on the
     // custom_attributes array, so remove it and set it after the data has been mapped
     $customAttributes = false;
     if (isset($customerAddressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES]) && is_array($customerAddressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES])) {
         $customAttributes = $customerAddressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES];
         unset($customerAddressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES]);
     }
     $addressDataObject = $this->customerAddressFactory->create();
     $this->dataObjectHelper->populateWithArray($addressDataObject, $customerAddressData, '\\Magento\\Customer\\Api\\Data\\AddressInterface');
     if ($customAttributes) {
         $addressDataObject->setCustomAttributes($customAttributes);
     }
     return $addressDataObject;
 }
开发者ID:classyllama,项目名称:ClassyLlama_AvaTax,代码行数:43,代码来源:Address.php


示例3: execute

 /**
  * @return \Magento\Customer\Api\Data\AddressInterface|string
  */
 public function execute()
 {
     $customerAddressData = $this->getRequest()->getParam('address');
     $customerAddressDataWithRegion = [];
     $customerAddressDataWithRegion['region']['region'] = $customerAddressData['region'];
     if (isset($customerAddressData['region_code'])) {
         $customerAddressDataWithRegion['region']['region_code'] = $customerAddressData['region_code'];
     }
     if ($customerAddressData['region_id']) {
         $customerAddressDataWithRegion['region']['region_id'] = $customerAddressData['region_id'];
     }
     $customerAddressData = array_merge($customerAddressData, $customerAddressDataWithRegion);
     /**
      * @var \Magento\Customer\Api\Data\AddressInterface $addressDataObject
      */
     $addressDataObject = $this->customerAddressFactory->create();
     $this->dataObjectHelper->populateWithArray($addressDataObject, $customerAddressData, '\\Magento\\Customer\\Api\\Data\\AddressInterface');
     $addressValidationResponse = $this->validAddressManagement->saveValidAddress($addressDataObject, \Magento\Store\Model\Store::DEFAULT_STORE_ID);
     $resultJson = $this->resultJsonFactory->create();
     if (!is_string($addressValidationResponse)) {
         $resultJson->setData([AddressInterface::FIRSTNAME => $addressValidationResponse->getFirstname(), AddressInterface::LASTNAME => $addressValidationResponse->getLastname(), AddressInterface::STREET => $addressValidationResponse->getStreet(), AddressInterface::COUNTRY_ID => $addressValidationResponse->getCountryId(), AddressInterface::CITY => $addressValidationResponse->getCity(), AddressInterface::REGION_ID => $addressValidationResponse->getRegionId(), AddressInterface::REGION => $addressValidationResponse->getRegion(), AddressInterface::POSTCODE => $addressValidationResponse->getPostcode()]);
     } else {
         $resultJson->setData($addressValidationResponse);
     }
     return $resultJson;
 }
开发者ID:classyllama,项目名称:ClassyLlama_AvaTax,代码行数:29,代码来源:Validation.php


示例4: save

 /**
  * {@inheritdoc}
  */
 public function save(CustomAttributesDataInterface $dataObjectWithCustomAttributes, $entityType, CustomAttributesDataInterface $previousCustomerData = null)
 {
     //Get all Image related custom attributes
     $imageDataObjects = $this->dataObjectHelper->getCustomAttributeValueByType($dataObjectWithCustomAttributes->getCustomAttributes(), '\\Magento\\Framework\\Api\\Data\\ImageContentInterface');
     // Return if no images to process
     if (empty($imageDataObjects)) {
         return $dataObjectWithCustomAttributes;
     }
     // For every image, save it and replace it with corresponding Eav data object
     /** @var $imageDataObject \Magento\Framework\Api\AttributeValue */
     foreach ($imageDataObjects as $imageDataObject) {
         /** @var $imageContent \Magento\Framework\Api\Data\ImageContentInterface */
         $imageContent = $imageDataObject->getValue();
         $filename = $this->processImageContent($entityType, $imageContent);
         //Set filename from static media location into data object
         $dataObjectWithCustomAttributes->setCustomAttribute($imageDataObject->getAttributeCode(), $filename);
         //Delete previously saved image if it exists
         if ($previousCustomerData) {
             $previousImageAttribute = $previousCustomerData->getCustomAttribute($imageDataObject->getAttributeCode());
             if ($previousImageAttribute) {
                 $previousImagePath = $previousImageAttribute->getValue();
                 if (!empty($previousImagePath)) {
                     @unlink($this->mediaDirectory->getAbsolutePath() . $entityType . $previousImagePath);
                 }
             }
         }
     }
     return $dataObjectWithCustomAttributes;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:32,代码来源:ImageProcessor.php


示例5: createMetadataAttribute

 /**
  * Create AttributeMetadata Data object from the Attribute Model
  *
  * @param \Magento\Customer\Model\Attribute $attribute
  * @return \Magento\Customer\Api\Data\AttributeMetadataInterface
  */
 public function createMetadataAttribute($attribute)
 {
     $options = [];
     if ($attribute->usesSource()) {
         foreach ($attribute->getSource()->getAllOptions() as $option) {
             $optionDataObject = $this->optionFactory->create();
             if (!is_array($option['value'])) {
                 $optionDataObject->setValue($option['value']);
             } else {
                 $optionArray = [];
                 foreach ($option['value'] as $optionArrayValues) {
                     $optionObject = $this->optionFactory->create();
                     $this->dataObjectHelper->populateWithArray($optionObject, $optionArrayValues, '\\Magento\\Customer\\Api\\Data\\OptionInterface');
                     $optionArray[] = $optionObject;
                 }
                 $optionDataObject->setOptions($optionArray);
             }
             $optionDataObject->setLabel($option['label']);
             $options[] = $optionDataObject;
         }
     }
     $validationRules = [];
     foreach ($attribute->getValidateRules() as $name => $value) {
         $validationRule = $this->validationRuleFactory->create()->setName($name)->setValue($value);
         $validationRules[] = $validationRule;
     }
     return $this->attributeMetadataFactory->create()->setAttributeCode($attribute->getAttributeCode())->setFrontendInput($attribute->getFrontendInput())->setInputFilter((string) $attribute->getInputFilter())->setStoreLabel($attribute->getStoreLabel())->setValidationRules($validationRules)->setIsVisible((bool) $attribute->getIsVisible())->setIsRequired((bool) $attribute->getIsRequired())->setMultilineCount((int) $attribute->getMultilineCount())->setDataModel((string) $attribute->getDataModel())->setOptions($options)->setFrontendClass($attribute->getFrontend()->getClass())->setFrontendLabel($attribute->getFrontendLabel())->setNote((string) $attribute->getNote())->setIsSystem((bool) $attribute->getIsSystem())->setIsUserDefined((bool) $attribute->getIsUserDefined())->setBackendType($attribute->getBackendType())->setSortOrder((int) $attribute->getSortOrder())->setIsUsedInGrid($attribute->getIsUsedInGrid())->setIsVisibleInGrid($attribute->getIsVisibleInGrid())->setIsFilterableInGrid($attribute->getIsFilterableInGrid())->setIsSearchableInGrid($attribute->getIsSearchableInGrid());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:34,代码来源:AttributeMetadataConverter.php


示例6: prepareQuoteForNewCustomer

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @return \Magento\Quote\Model\Quote
  */
 public function prepareQuoteForNewCustomer(\Magento\Quote\Model\Quote $quote)
 {
     $billing = $quote->getBillingAddress();
     $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
     $billing->setDefaultBilling(true);
     if ($shipping && !$shipping->getSameAsBilling()) {
         $shipping->setDefaultShipping(true);
         $address = $shipping->exportCustomerAddress();
         $shipping->setCustomerAddressData($address);
     } elseif ($shipping) {
         $billing->setDefaultShipping(true);
     }
     $address = $shipping->exportCustomerAddress();
     $billing->setCustomerAddressData($address);
     foreach (['customer_dob', 'customer_taxvat', 'customer_gender'] as $attribute) {
         if ($quote->getData($attribute) && !$billing->getData($attribute)) {
             $billing->setData($attribute, $quote->getData($attribute));
         }
     }
     $customer = $this->customerFactory->create();
     $this->dataObjectHelper->populateWithArray($customer, $this->copyObject->getDataFromFieldset('checkout_onepage_billing', 'to_customer', $billing), '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     $customer->setEmail($quote->getCustomerEmail());
     $customer->setPrefix($quote->getCustomerPrefix());
     $customer->setFirstname($quote->getCustomerFirstname());
     $customer->setMiddlename($quote->getCustomerMiddlename());
     $customer->setLastname($quote->getCustomerLastname());
     $customer->setSuffix($quote->getCustomerSuffix());
     $quote->setCustomer($customer);
     $quote->addCustomerAddress($billing->exportCustomerAddress());
     if ($shipping->hasCustomerAddress()) {
         $quote->addCustomerAddress($shipping->exportCustomerAddress());
     }
     return $quote;
 }
开发者ID:nja78,项目名称:magento2,代码行数:38,代码来源:Quote.php


示例7: testGetChildren

 public function testGetChildren()
 {
     $productId = 'test';
     $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productTypeInstance = $this->getMockBuilder('Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable')->disableOriginalConstructor()->getMock();
     $product->expects($this->any())->method('getTypeId')->willReturn(Configurable::TYPE_CODE);
     $product->expects($this->any())->method('getStoreId')->willReturn(1);
     $product->expects($this->any())->method('getTypeInstance')->willReturn($productTypeInstance);
     $productTypeInstance->expects($this->once())->method('setStoreFilter')->with(1, $product);
     $childProduct = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productTypeInstance->expects($this->any())->method('getUsedProducts')->with($product)->willReturn([$childProduct]);
     $this->productRepository->expects($this->any())->method('get')->with($productId)->willReturn($product);
     $attribute = $this->getMock('\\Magento\\Eav\\Api\\Data\\AttributeInterface');
     $attribute->expects($this->once())->method('getAttributeCode')->willReturn('code');
     $childProduct->expects($this->once())->method('getDataUsingMethod')->with('code')->willReturn(false);
     $childProduct->expects($this->once())->method('getData')->with('code')->willReturn(10);
     $childProduct->expects($this->once())->method('getStoreId')->willReturn(1);
     $childProduct->expects($this->once())->method('getAttributes')->willReturn([$attribute]);
     $productMock = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductInterface');
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray')->with($productMock, ['store_id' => 1, 'code' => 10], '\\Magento\\Catalog\\Api\\Data\\ProductInterface')->willReturnSelf();
     $this->productFactory->expects($this->once())->method('create')->willReturn($productMock);
     $products = $this->object->getChildren($productId);
     $this->assertCount(1, $products);
     $this->assertEquals($productMock, $products[0]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:LinkManagementTest.php


示例8: convert

    /**
     * @param Address $object
     * @param array $data
     * @return OrderInterface
     */
    public function convert(Address $object, $data = [])
    {
        $orderData = $this->objectCopyService->getDataFromFieldset(
            'quote_convert_address',
            'to_order',
            $object
        );
        /**
         * @var $order \Magento\Sales\Model\Order
         */
        $order = $this->orderFactory->create();
        $this->dataObjectHelper->populateWithArray(
            $order,
            array_merge($orderData, $data),
            '\Magento\Sales\Api\Data\OrderInterface'
        );
        $order->setStoreId($object->getQuote()->getStoreId())
            ->setQuoteId($object->getQuote()->getId())
            ->setIncrementId($object->getQuote()->getReservedOrderId());
        $this->objectCopyService->copyFieldsetToTarget('sales_convert_quote', 'to_order', $object->getQuote(), $order);
        $this->eventManager->dispatch(
            'sales_convert_quote_to_order',
            ['order' => $order, 'quote' => $object->getQuote()]
        );
        return $order;

    }
开发者ID:razbakov,项目名称:magento2,代码行数:32,代码来源:ToOrder.php


示例9: get

 /**
  * {@inheritDoc}
  *
  * @param int $cartId The cart ID.
  * @return Totals Quote totals data.
  */
 public function get($cartId)
 {
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $this->quoteRepository->getActive($cartId);
     if ($quote->isVirtual()) {
         $addressTotalsData = $quote->getBillingAddress()->getData();
         $addressTotals = $quote->getBillingAddress()->getTotals();
     } else {
         $addressTotalsData = $quote->getShippingAddress()->getData();
         $addressTotals = $quote->getShippingAddress()->getTotals();
     }
     /** @var \Magento\Quote\Api\Data\TotalsInterface $quoteTotals */
     $quoteTotals = $this->totalsFactory->create();
     $this->dataObjectHelper->populateWithArray($quoteTotals, $addressTotalsData, '\\Magento\\Quote\\Api\\Data\\TotalsInterface');
     $items = [];
     foreach ($quote->getAllVisibleItems() as $index => $item) {
         $items[$index] = $this->itemConverter->modelToDataObject($item);
     }
     $calculatedTotals = $this->totalsConverter->process($addressTotals);
     $quoteTotals->setTotalSegments($calculatedTotals);
     $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
     $amount = $amount > 0 ? $amount : 0;
     $quoteTotals->setCouponCode($this->couponService->get($cartId));
     $quoteTotals->setGrandTotal($amount);
     $quoteTotals->setItems($items);
     $quoteTotals->setItemsQty($quote->getItemsQty());
     $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
     $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
     return $quoteTotals;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:36,代码来源:CartTotalRepository.php


示例10: convert

 /**
  * @param Address $object
  * @param array $data
  * @return OrderAddressInterface
  */
 public function convert(Address $object, $data = [])
 {
     $orderAddress = $this->orderAddressRepository->create();
     $orderAddressData = $this->objectCopyService->getDataFromFieldset('quote_convert_address', 'to_order_address', $object);
     $this->dataObjectHelper->populateWithArray($orderAddress, array_merge($orderAddressData, $data), '\\Magento\\Sales\\Api\\Data\\OrderAddressInterface');
     return $orderAddress;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:12,代码来源:ToOrderAddress.php


示例11: getChildren

 /**
  * {@inheritdoc}
  */
 public function getChildren($sku)
 {
     /** @var \Magento\Catalog\Model\Product $product */
     $product = $this->productRepository->get($sku);
     if ($product->getTypeId() != \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) {
         return [];
     }
     /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable $productTypeInstance */
     $productTypeInstance = $product->getTypeInstance();
     $productTypeInstance->setStoreFilter($product->getStoreId(), $product);
     $childrenList = [];
     /** @var \Magento\Catalog\Model\Product $child */
     foreach ($productTypeInstance->getUsedProducts($product) as $child) {
         $attributes = [];
         foreach ($child->getAttributes() as $attribute) {
             $attrCode = $attribute->getAttributeCode();
             $value = $child->getDataUsingMethod($attrCode) ?: $child->getData($attrCode);
             if (null !== $value && $attrCode != 'entity_id') {
                 $attributes[$attrCode] = $value;
             }
         }
         $attributes['store_id'] = $child->getStoreId();
         /** @var \Magento\Catalog\Api\Data\ProductInterface $productDataObject */
         $productDataObject = $this->productFactory->create();
         $this->dataObjectHelper->populateWithArray($productDataObject, $attributes, '\\Magento\\Catalog\\Api\\Data\\ProductInterface');
         $childrenList[] = $productDataObject;
     }
     return $childrenList;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:32,代码来源:LinkManagement.php


示例12: hydrate

 /**
  * {@inheritdoc}
  */
 public function hydrate($entity, array $data)
 {
     $entityType = $this->typeResolver->resolve($entity);
     $mapper = $this->mapperPool->getMapper($entityType);
     $data = $mapper->databaseToEntity($entityType, array_merge($this->extract($entity), $data));
     $this->dataObjectHelper->populateWithArray($entity, $data, $entityType);
     return $entity;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:Hydrator.php


示例13: modelToDataObject

 /**
  * Converts a specified rate model to a shipping method data object.
  *
  * @param \Magento\Quote\Model\Quote\Item $item
  * @return array
  * @throws \Exception
  */
 public function modelToDataObject($item)
 {
     $this->eventManager->dispatch('items_additional_data', ['item' => $item]);
     $items = $item->toArray();
     $items['options'] = $this->getFormattedOptionValue($item);
     $itemsData = $this->totalsItemFactory->create();
     $this->dataObjectHelper->populateWithArray($itemsData, $items, '\\Magento\\Quote\\Api\\Data\\TotalsItemInterface');
     return $itemsData;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:ItemConverter.php


示例14: testFindOneByDataIfFound

 public function testFindOneByDataIfFound()
 {
     $data = [['field1' => 'value1']];
     $row = ['row1'];
     $urlRewrite = ['urlRewrite1'];
     $this->storage->expects($this->once())->method('doFindOneByData')->with($data)->will($this->returnValue($row));
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($urlRewrite, $row, '\\Magento\\UrlRewrite\\Service\\V1\\Data\\UrlRewrite')->will($this->returnSelf());
     $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($urlRewrite));
     $this->assertEquals($urlRewrite, $this->storage->findOneByData($data));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:AbstractStorageTest.php


示例15: testGetItems

 public function testGetItems()
 {
     $inputTypeMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Attribute\\Source\\Inputtype', [], [], '', false);
     $this->inputTypeFactoryMock->expects($this->once())->method('create')->willReturn($inputTypeMock);
     $inputTypeMock->expects($this->once())->method('toOptionArray')->willReturn(['option' => ['value']]);
     $attributeTypeMock = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductAttributeTypeInterface');
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray')->with($attributeTypeMock, ['value'], '\\Magento\\Catalog\\Api\\Data\\ProductAttributeTypeInterface')->willReturnSelf();
     $this->attributeTypeFactoryMock->expects($this->once())->method('create')->willReturn($attributeTypeMock);
     $this->assertEquals([$attributeTypeMock], $this->model->getItems());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:TypesListTest.php


示例16: convertToProductOption

 /**
  * {@inheritdoc}
  */
 public function convertToProductOption(DataObject $request)
 {
     /** @var DownloadableOption $downloadableOption */
     $downloadableOption = $this->downloadableOptionFactory->create();
     $links = $request->getLinks();
     if (!empty($links) && is_array($links)) {
         $this->dataObjectHelper->populateWithArray($downloadableOption, ['downloadable_links' => $links], 'Magento\\Downloadable\\Api\\Data\\DownloadableOptionInterface');
         return ['downloadable_option' => $downloadableOption];
     }
     return [];
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:ProductOptionProcessor.php


示例17: convert

 /**
  * @param Payment $object
  * @param array $data
  * @return OrderPaymentInterface
  */
 public function convert(Payment $object, $data = [])
 {
     $paymentData = $this->objectCopyService->getDataFromFieldset('quote_convert_payment', 'to_order_payment', $object);
     $orderPayment = $this->orderPaymentFactory->create();
     $this->dataObjectHelper->populateWithArray($orderPayment, array_merge($paymentData, $data), '\\Magento\\Sales\\Api\\Data\\OrderPaymentInterface');
     $orderPayment->setAdditionalInformation(serialize(array_merge($object->getAdditionalInformation(), [Substitution::INFO_KEY_TITLE => $object->getMethodInstance()->getTitle()])));
     // set directly on the model
     $orderPayment->setCcNumber($object->getCcNumber());
     $orderPayment->setCcCid($object->getCcCid());
     return $orderPayment;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:16,代码来源:ToOrderPayment.php


示例18: getItems

 /**
  * {@inheritdoc}
  */
 public function getItems()
 {
     $types = [];
     $inputType = $this->inputTypeFactory->create();
     foreach ($inputType->toOptionArray() as $option) {
         $type = $this->attributeTypeFactory->create();
         $this->dataObjectHelper->populateWithArray($type, $option, '\\Magento\\Catalog\\Api\\Data\\ProductAttributeTypeInterface');
         $types[] = $type;
     }
     return $types;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:TypesList.php


示例19: testFindOneByData

 public function testFindOneByData()
 {
     $data = ['col1' => 'val1', 'col2' => 'val2'];
     $this->select->expects($this->at(1))->method('where')->with('col1 IN (?)', 'val1');
     $this->select->expects($this->at(2))->method('where')->with('col2 IN (?)', 'val2');
     $this->adapter->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0));
     $this->adapter->expects($this->once())->method('fetchRow')->with($this->select)->will($this->returnValue(['row1']));
     $this->dataObjectHelper->expects($this->at(0))->method('populateWithArray')->with(['urlRewrite1'], ['row1'], '\\Magento\\UrlRewrite\\Service\\V1\\Data\\UrlRewrite')->will($this->returnSelf());
     $this->urlRewriteFactory->expects($this->at(0))->method('create')->will($this->returnValue(['urlRewrite1']));
     $this->assertEquals(['urlRewrite1'], $this->storage->findOneByData($data));
 }
开发者ID:opexsw,项目名称:magento2,代码行数:11,代码来源:DbStorageTest.php


示例20: testConvert

 public function testConvert()
 {
     $orderData = ['test' => 'test1'];
     $data = ['test' => 'beer'];
     /**
      * @var \Magento\Quote\Model\Quote\Address $object
      */
     $object = $this->getMock('Magento\\Quote\\Model\\Quote\\Address', [], [], '', false);
     $this->objectCopyMock->expects($this->once())->method('getDataFromFieldset')->with('sales_convert_quote_address', 'to_order_address', $object)->willReturn($orderData);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($this->orderInterfaceMock, ['test' => 'beer'], '\\Magento\\Sales\\Api\\Data\\OrderAddressInterface')->willReturnSelf();
     $this->orderAddressRepositoryMock->expects($this->once())->method('create')->willReturn($this->orderInterfaceMock);
     $this->assertSame($this->orderInterfaceMock, $this->converter->convert($object, $data));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:ToOrderAddressTest.php



注:本文中的Magento\Framework\Api\DataObjectHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Api\ExtensibleDataObjectConverter类代码示例发布时间:2022-05-23
下一篇:
PHP Framework\UrlInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap