init
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleDefaultHydrator\Api;
|
||||
|
||||
/**
|
||||
* Customer CRUD interface
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
interface CustomerPersistenceInterface
|
||||
{
|
||||
/**
|
||||
* Create customer
|
||||
*
|
||||
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
|
||||
* @param string $passwordHash
|
||||
* @return \Magento\Customer\Api\Data\CustomerInterface
|
||||
* @throws \Magento\Framework\Exception\InputException If bad input is provided
|
||||
* @throws \Magento\Framework\Exception\State\InputMismatchException If the provided email is already used
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function save(\Magento\Customer\Api\Data\CustomerInterface $customer);
|
||||
|
||||
/**
|
||||
* Retrieve customer by email
|
||||
*
|
||||
* @param string $email
|
||||
* @param int|null $websiteId
|
||||
* @return \Magento\Customer\Api\Data\CustomerInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException If customer with the specified email does not exist
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function get($email, $websiteId = null);
|
||||
|
||||
/**
|
||||
* Retrieve customer by id
|
||||
*
|
||||
* @param int $id
|
||||
* @param int|null $websiteId
|
||||
* @return \Magento\Customer\Api\Data\CustomerInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function getById($id, $websiteId = null);
|
||||
|
||||
/**
|
||||
* Delete customer by id
|
||||
*
|
||||
* @param int $id
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function delete($id);
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleDefaultHydrator\Api\Data;
|
||||
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
interface ExtensionAttributeInterface
|
||||
{
|
||||
/**#@+
|
||||
* Constants for keys of data array. Identical to the name of the getter in snake case
|
||||
*/
|
||||
public const ID = 'id';
|
||||
public const CUSTOMER_ID = 'customer_id';
|
||||
public const VALUE = 'value';
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Get ID
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Set ID
|
||||
*
|
||||
* @param int $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* Get customer ID
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCustomerId();
|
||||
|
||||
/**
|
||||
* Set customer ID
|
||||
*
|
||||
* @param int $customerId
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomerId($customerId);
|
||||
|
||||
/**
|
||||
* Get value
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getValue();
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setValue($value);
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleDefaultHydrator\Model\Address;
|
||||
|
||||
use Magento\Framework\EntityManager\MapperInterface;
|
||||
|
||||
/**
|
||||
* Class Mapper
|
||||
*/
|
||||
class Mapper implements MapperInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityToDatabase($entityType, $data)
|
||||
{
|
||||
$data['street'] = implode("\n", $data['street']);
|
||||
$data['region_id'] = $data['region']['region_id'];
|
||||
$data['region_code'] = $data['region']['region_code'];
|
||||
$data['region'] = $data['region']['region'];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function databaseToEntity($entityType, $data)
|
||||
{
|
||||
$data['street'] = explode("\n", $data['street']);
|
||||
$region = [
|
||||
'region' => $data['region'],
|
||||
'region_code' => $data['region_code'],
|
||||
'region_id' => $data['region_id']
|
||||
];
|
||||
$data['region'] = $region;
|
||||
unset($data['region_id'], $data['region_code']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleDefaultHydrator\Model;
|
||||
|
||||
use Magento\TestModuleDefaultHydrator\Api\CustomerPersistenceInterface;
|
||||
use Magento\Framework\EntityManager\EntityManager;
|
||||
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
|
||||
|
||||
class CustomerPersistence implements CustomerPersistenceInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* @var CustomerInterfaceFactory
|
||||
*/
|
||||
private $customerDataFactory;
|
||||
|
||||
public function __construct(
|
||||
EntityManager $entityManager,
|
||||
CustomerInterfaceFactory $customerDataFactory
|
||||
) {
|
||||
$this->entityManager = $entityManager;
|
||||
$this->customerDataFactory = $customerDataFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save(\Magento\Customer\Api\Data\CustomerInterface $customer)
|
||||
{
|
||||
return $this->entityManager->save($customer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($email, $websiteId = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getById($id, $websiteId = null)
|
||||
{
|
||||
/** @var \Magento\Customer\Api\Data\CustomerInterface $customer */
|
||||
$customer = $this->customerDataFactory->create();
|
||||
$entity = $this->entityManager->load($customer, $id);
|
||||
return $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
/** @var \Magento\Customer\Api\Data\CustomerInterface $customer */
|
||||
$customer = $this->customerDataFactory->create();
|
||||
$customer = $this->entityManager->load($customer, $id);
|
||||
try {
|
||||
$this->entityManager->delete($customer);
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleDefaultHydrator\Model\Data;
|
||||
|
||||
class ExtensionAttribute extends \Magento\Framework\Api\AbstractSimpleObject implements
|
||||
\Magento\TestModuleDefaultHydrator\Api\Data\ExtensionAttributeInterface
|
||||
{
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->_get(self::ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customer id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomerId()
|
||||
{
|
||||
return $this->_get(self::CUSTOMER_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->_get(self::VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id
|
||||
*
|
||||
* @param int $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
return $this->setData(self::ID, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set customer id
|
||||
*
|
||||
* @param int $customerId
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomerId($customerId)
|
||||
{
|
||||
return $this->setData(self::CUSTOMER_ID, $customerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param int $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
return $this->setData(self::VALUE, $value);
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleDefaultHydrator\Model\ResourceModel\Address;
|
||||
|
||||
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
|
||||
use Magento\Customer\Api\AddressRepositoryInterface;
|
||||
use Magento\Framework\Api\SearchCriteriaBuilder;
|
||||
use Magento\Customer\Api\Data\CustomerInterface;
|
||||
use Magento\Framework\EntityManager\EntityManager;
|
||||
|
||||
class ReadHandler implements ExtensionInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $addressRepository;
|
||||
|
||||
/**
|
||||
* @var SearchCriteriaBuilder
|
||||
*/
|
||||
private $searchCriteriaBuilder;
|
||||
|
||||
/**
|
||||
* @param AddressRepositoryInterface $addressRepositoryInterface
|
||||
* @param SearchCriteriaBuilder $SearchCriteriaBuilder
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
|
||||
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
|
||||
) {
|
||||
$this->addressRepository = $addressRepository;
|
||||
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CustomerInterface $entity
|
||||
* @return CustomerInterface
|
||||
* @throws \Exception
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function execute($entity, $arguments = [])
|
||||
{
|
||||
$searchCriteria = $this->searchCriteriaBuilder->addFilter('parent_id', $entity->getId())
|
||||
->create();
|
||||
$addressesResult = $this->addressRepository->getList($searchCriteria);
|
||||
$entity->setAddresses($addressesResult->getItems());
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleDefaultHydrator\Model\ResourceModel\Address;
|
||||
|
||||
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
|
||||
use Magento\Framework\EntityManager\MetadataPool;
|
||||
use Magento\Framework\EntityManager\EntityManager;
|
||||
use Magento\Customer\Api\Data\CustomerInterface;
|
||||
|
||||
class SaveHandler implements ExtensionInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* @param EntityManager $entityManager
|
||||
*/
|
||||
public function __construct(
|
||||
EntityManager $entityManager
|
||||
) {
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CustomerInterface $entity
|
||||
* @param array $arguments
|
||||
* @return CustomerInterface
|
||||
* @throws \Exception
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function execute($entity, $arguments = [])
|
||||
{
|
||||
$newAddresses = [];
|
||||
foreach ($entity->getAddresses() as $address) {
|
||||
$address->setCustomerId($entity->getId());
|
||||
$newAddresses[] = $this->entityManager->save($address);
|
||||
}
|
||||
$entity->setAddresses($newAddresses);
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleDefaultHydrator\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
|
||||
use Magento\Framework\EntityManager\MetadataPool;
|
||||
use Magento\Framework\EntityManager\EntityManager;
|
||||
use Magento\Framework\App\ResourceConnection;
|
||||
use Magento\Customer\Api\Data\CustomerInterface;
|
||||
use Magento\Customer\Api\Data\CustomerExtensionFactory;
|
||||
use Magento\TestModuleDefaultHydrator\Api\Data\ExtensionAttributeInterface;
|
||||
use Magento\TestModuleDefaultHydrator\Api\Data\ExtensionAttributeInterfaceFactory as ExtensionAttributeFactory;
|
||||
|
||||
class ReadHandler implements ExtensionInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* @var ExtensionAttributeFactory
|
||||
*/
|
||||
private $extensionAttributeFactory;
|
||||
|
||||
/**
|
||||
* @var CustomerExtensionFactory
|
||||
*/
|
||||
private $customerExtensionFactory;
|
||||
|
||||
/**
|
||||
* @var MetadataPool
|
||||
*/
|
||||
private $metadataPool;
|
||||
|
||||
/**
|
||||
* @var ResourceConnection
|
||||
*/
|
||||
private $resourceConnection;
|
||||
|
||||
/**
|
||||
* @param EntityManager $entityManager
|
||||
* @param ExtensionAttributeFactory $extensionAttributeFactory
|
||||
* @param CustomerExtensionFactory $customerExtensionFactory
|
||||
* @param MetadataPool $metadataPool
|
||||
* @param ResourceConnection $resourceConnection
|
||||
*/
|
||||
public function __construct(
|
||||
EntityManager $entityManager,
|
||||
ExtensionAttributeFactory $extensionAttributeFactory,
|
||||
CustomerExtensionFactory $customerExtensionFactory,
|
||||
MetadataPool $metadataPool,
|
||||
ResourceConnection $resourceConnection
|
||||
) {
|
||||
$this->entityManager = $entityManager;
|
||||
$this->extensionAttributeFactory = $extensionAttributeFactory;
|
||||
$this->customerExtensionFactory = $customerExtensionFactory;
|
||||
$this->metadataPool = $metadataPool;
|
||||
$this->resourceConnection = $resourceConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CustomerInterface $entity
|
||||
* @param array $arguments
|
||||
* @return CustomerInterface
|
||||
* @throws \Exception
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function execute($entity, $arguments = [])
|
||||
{
|
||||
$metadata = $this->metadataPool->getMetadata(ExtensionAttributeInterface::class);
|
||||
$connection = $this->resourceConnection->getConnectionByName(
|
||||
$metadata->getEntityConnectionName()
|
||||
);
|
||||
$id = $connection->fetchOne(
|
||||
$connection->select()
|
||||
->from($metadata->getEntityTable(), [$metadata->getIdentifierField()])
|
||||
->where('customer_id = ?', $entity->getId())
|
||||
->limit(1)
|
||||
);
|
||||
$extensionAttribute = $this->extensionAttributeFactory->create();
|
||||
$extensionAttribute = $this->entityManager->load($extensionAttribute, $id);
|
||||
$customerExtension = $this->customerExtensionFactory->create(
|
||||
[
|
||||
'data' => ['extension_attribute' => $extensionAttribute]
|
||||
]
|
||||
);
|
||||
$entity->setExtensionAttributes($customerExtension);
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleDefaultHydrator\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
|
||||
use Magento\TestModuleDefaultHydrator\Api\Data\ExtensionAttributeInterface;
|
||||
use Magento\Customer\Api\Data\CustomerInterface;
|
||||
use Magento\Framework\EntityManager\EntityManager;
|
||||
|
||||
class SaveHandler implements ExtensionInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* @param EntityManager $entityManager
|
||||
*/
|
||||
public function __construct(
|
||||
EntityManager $entityManager
|
||||
) {
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CustomerInterface $entity
|
||||
* @param array $arguments
|
||||
* @return CustomerInterface
|
||||
* @throws \Exception
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function execute($entity, $arguments = [])
|
||||
{
|
||||
$extensionAttribute = $entity->getExtensionAttributes()->getExtensionAttribute();
|
||||
$extensionAttribute->setCustomerId($entity->getId());
|
||||
$extensionAttribute = $this->entityManager->save($extensionAttribute);
|
||||
$entity->getExtensionAttributes()->setExtensionAttribute($extensionAttribute);
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
|
||||
<table name="testmodule_default_hydrator_extension_attribute_entity" resource="default" engine="innodb">
|
||||
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true"/>
|
||||
<column xsi:type="int" name="customer_id" padding="10" unsigned="true" nullable="false" identity="false"/>
|
||||
<column xsi:type="varchar" name="value" nullable="true" length="255"/>
|
||||
<constraint xsi:type="primary" referenceId="PRIMARY">
|
||||
<column name="entity_id"/>
|
||||
</constraint>
|
||||
<constraint xsi:type="foreign" referenceId="CSTR_EXTENSION_ATTR_ENTT_CSTR_ID_CSTR_ENTT_ENTT_ID"
|
||||
table="testmodule_default_hydrator_extension_attribute_entity" column="customer_id"
|
||||
referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
|
||||
</table>
|
||||
</schema>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"testmodule_default_hydrator_extension_attribute_entity": {
|
||||
"column": {
|
||||
"entity_id": true,
|
||||
"customer_id": true,
|
||||
"value": true
|
||||
},
|
||||
"constraint": {
|
||||
"PRIMARY": true,
|
||||
"CSTR_EXTENSION_ATTR_ENTT_CSTR_ID_CSTR_ENTT_ENTT_ID": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
|
||||
<preference for="Magento\TestModuleDefaultHydrator\Api\CustomerPersistenceInterface" type="Magento\TestModuleDefaultHydrator\Model\CustomerPersistence" />
|
||||
<preference for="Magento\TestModuleDefaultHydrator\Api\Data\ExtensionAttributeInterface" type="Magento\TestModuleDefaultHydrator\Model\Data\ExtensionAttribute" />
|
||||
<type name="Magento\Framework\EntityManager\Operation\ExtensionPool">
|
||||
<arguments>
|
||||
<argument name="extensionActions" xsi:type="array">
|
||||
<item name="Magento\Customer\Api\Data\CustomerInterface" xsi:type="array">
|
||||
<item name="read" xsi:type="array">
|
||||
<item name="extensionAttribute" xsi:type="string">Magento\TestModuleDefaultHydrator\Model\ResourceModel\ReadHandler</item>
|
||||
<item name="address" xsi:type="string">Magento\TestModuleDefaultHydrator\Model\ResourceModel\Address\ReadHandler</item>
|
||||
</item>
|
||||
<item name="create" xsi:type="array">
|
||||
<item name="extensionAttribute" xsi:type="string">Magento\TestModuleDefaultHydrator\Model\ResourceModel\SaveHandler</item>
|
||||
<item name="address" xsi:type="string">Magento\TestModuleDefaultHydrator\Model\ResourceModel\Address\SaveHandler</item>
|
||||
</item>
|
||||
<item name="update" xsi:type="array">
|
||||
<item name="extensionAttribute" xsi:type="string">Magento\TestModuleDefaultHydrator\Model\ResourceModel\SaveHandler</item>
|
||||
<item name="address" xsi:type="string">Magento\TestModuleDefaultHydrator\Model\ResourceModel\Address\SaveHandler</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
<type name="Magento\Framework\EntityManager\MetadataPool">
|
||||
<arguments>
|
||||
<argument name="metadata" xsi:type="array">
|
||||
<item name="Magento\Customer\Api\Data\CustomerInterface" xsi:type="array">
|
||||
<item name="entityTableName" xsi:type="string">customer_entity</item>
|
||||
<item name="eavEntityType" xsi:type="string">customer</item>
|
||||
<item name="identifierField" xsi:type="string">entity_id</item>
|
||||
</item>
|
||||
<item name="Magento\Customer\Api\Data\AddressInterface" xsi:type="array">
|
||||
<item name="entityTableName" xsi:type="string">customer_address_entity</item>
|
||||
<item name="eavEntityType" xsi:type="string">customer_address</item>
|
||||
<item name="identifierField" xsi:type="string">entity_id</item>
|
||||
</item>
|
||||
<item name="Magento\TestModuleDefaultHydrator\Api\Data\ExtensionAttributeInterface" xsi:type="array">
|
||||
<item name="entityTableName" xsi:type="string">testmodule_default_hydrator_extension_attribute_entity</item>
|
||||
<item name="identifierField" xsi:type="string">entity_id</item>
|
||||
</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
<type name="Magento\Framework\EntityManager\Mapper">
|
||||
<arguments>
|
||||
<argument name="config" xsi:type="array">
|
||||
<item name="Magento\Customer\Api\Data\CustomerInterface" xsi:type="array">
|
||||
<item name="entity_id" xsi:type="string">id</item>
|
||||
</item>
|
||||
<item name="Magento\Customer\Api\Data\AddressInterface" xsi:type="array">
|
||||
<item name="parent_id" xsi:type="string">customer_id</item>
|
||||
</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
<virtualType name="customerAddressMapper" type="Magento\Framework\EntityManager\CompositeMapper">
|
||||
<arguments>
|
||||
<argument name="mappers" xsi:type="array">
|
||||
<item name="addressMapper" xsi:type="object">Magento\TestModuleDefaultHydrator\Model\Address\Mapper</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</virtualType>
|
||||
<type name="Magento\Framework\EntityManager\MapperPool">
|
||||
<arguments>
|
||||
<argument name="mappers" xsi:type="array">
|
||||
<item name="Magento\Customer\Api\Data\AddressInterface" xsi:type="string">customerAddressMapper</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
</config>
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
|
||||
<extension_attributes for="Magento\Customer\Api\Data\CustomerInterface">
|
||||
<attribute code="extension_attribute" type="Magento\TestModuleDefaultHydrator\Api\Data\ExtensionAttributeInterface" />
|
||||
</extension_attributes>
|
||||
</config>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Magento_TestModuleDefaultHydrator">
|
||||
</module>
|
||||
</config>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
|
||||
<route url="/V1/TestModuleDefaultHydrator" method="POST">
|
||||
<service class="Magento\TestModuleDefaultHydrator\Api\CustomerPersistenceInterface" method="save"/>
|
||||
<resources>
|
||||
<resource ref="anonymous"/>
|
||||
</resources>
|
||||
</route>
|
||||
<route url="/V1/TestModuleDefaultHydrator/:id" method="GET">
|
||||
<service class="Magento\TestModuleDefaultHydrator\Api\CustomerPersistenceInterface" method="getById"/>
|
||||
<resources>
|
||||
<resource ref="anonymous"/>
|
||||
</resources>
|
||||
</route>
|
||||
<route url="/V1/TestModuleDefaultHydrator/:id" method="DELETE">
|
||||
<service class="Magento\TestModuleDefaultHydrator\Api\CustomerPersistenceInterface" method="delete"/>
|
||||
<resources>
|
||||
<resource ref="anonymous"/>
|
||||
</resources>
|
||||
</route>
|
||||
<route url="/V1/TestModuleDefaultHydrator/:id" method="PUT">
|
||||
<service class="Magento\TestModuleDefaultHydrator\Api\CustomerPersistenceInterface" method="save"/>
|
||||
<resources>
|
||||
<resource ref="anonymous"/>
|
||||
</resources>
|
||||
</route>
|
||||
</routes>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
$registrar = new ComponentRegistrar();
|
||||
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestModuleDefaultHydrator') === null) {
|
||||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestModuleDefaultHydrator', __DIR__);
|
||||
}
|
||||
Reference in New Issue
Block a user