init
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleJoinDirectives\Api;
|
||||
|
||||
/**
|
||||
* Interface TestRepositoryInterface
|
||||
*/
|
||||
interface TestRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Get list of quotes
|
||||
*
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
* @return \Magento\Quote\Api\Data\CartSearchResultsInterface
|
||||
*/
|
||||
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleJoinDirectives\Model;
|
||||
|
||||
use Magento\TestModuleJoinDirectives\Api\TestRepositoryInterface;
|
||||
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
|
||||
|
||||
/**
|
||||
* Model TestRepository
|
||||
*/
|
||||
class TestRepository implements TestRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory
|
||||
*/
|
||||
private $quoteCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory
|
||||
*/
|
||||
private $searchResultsDataFactory;
|
||||
|
||||
/**
|
||||
* @var JoinProcessorInterface
|
||||
*/
|
||||
private $extensionAttributesJoinProcessor;
|
||||
|
||||
/**
|
||||
* @param \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $quoteCollectionFactory
|
||||
* @param \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory $searchResultsDataFactory
|
||||
* @param JoinProcessorInterface $extensionAttributesJoinProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $quoteCollectionFactory,
|
||||
\Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory $searchResultsDataFactory,
|
||||
JoinProcessorInterface $extensionAttributesJoinProcessor
|
||||
) {
|
||||
$this->quoteCollectionFactory = $quoteCollectionFactory;
|
||||
$this->searchResultsDataFactory = $searchResultsDataFactory;
|
||||
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
|
||||
{
|
||||
$quoteCollection = $this->quoteCollectionFactory->create();
|
||||
$this->extensionAttributesJoinProcessor->process($quoteCollection);
|
||||
$searchData = $this->searchResultsDataFactory->create();
|
||||
$searchData->setSearchCriteria($searchCriteria);
|
||||
$searchData->setItems($quoteCollection->getItems());
|
||||
return $searchData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "magento/module-test-join-directives",
|
||||
"description": "test integration for join directives",
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"php": "~7.4.0||~8.0.0",
|
||||
"magento/framework": "*",
|
||||
"magento/module-sales": "*"
|
||||
},
|
||||
"type": "magento2-module",
|
||||
"extra": {
|
||||
"map": [
|
||||
[
|
||||
"*",
|
||||
"Magento/TestModuleJoinDirectives"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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:Acl/etc/acl.xsd">
|
||||
<acl>
|
||||
<resources>
|
||||
<resource id="Magento_Backend::admin">
|
||||
<resource id="Magento_TestModuleJoinDirectives::all" title="TestJoinDirectives" sortOrder="1">
|
||||
<resource id="Magento_TestModuleJoinDirectives::getList" title="GetList" sortOrder="10"/>
|
||||
</resource>
|
||||
</resource>
|
||||
</resources>
|
||||
</acl>
|
||||
</config>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?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\TestModuleJoinDirectives\Api\TestRepositoryInterface" type="Magento\TestModuleJoinDirectives\Model\TestRepository" />
|
||||
</config>
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<?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\Quote\Api\Data\CartInterface">
|
||||
<attribute code="quoteApiTestAttribute" type="Magento\User\Api\Data\UserInterface">
|
||||
<join reference_table="admin_user"
|
||||
join_on_field="store_id"
|
||||
reference_field="user_id"
|
||||
>
|
||||
<field>firstname</field>
|
||||
<field>lastname</field>
|
||||
<field>email</field>
|
||||
</join>
|
||||
</attribute>
|
||||
</extension_attributes>
|
||||
<extension_attributes for="Magento\Sales\Api\Data\InvoiceInterface">
|
||||
<attribute code="invoiceApiTestAttribute" type="Magento\User\Api\Data\UserInterface">
|
||||
<join reference_table="admin_user"
|
||||
join_on_field="store_id"
|
||||
reference_field="user_id"
|
||||
>
|
||||
<field>firstname</field>
|
||||
<field>lastname</field>
|
||||
<field>email</field>
|
||||
</join>
|
||||
</attribute>
|
||||
</extension_attributes>
|
||||
<extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
|
||||
<attribute code="orderApiTestAttribute" type="Magento\User\Api\Data\UserInterface">
|
||||
<join reference_table="admin_user"
|
||||
join_on_field="store_id"
|
||||
reference_field="user_id"
|
||||
>
|
||||
<field>firstname</field>
|
||||
<field>lastname</field>
|
||||
<field>email</field>
|
||||
</join>
|
||||
</attribute>
|
||||
</extension_attributes>
|
||||
</config>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?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_TestModuleJoinDirectives" />
|
||||
</config>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?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/TestModuleJoinDirectives" method="GET">
|
||||
<service class="Magento\TestModuleJoinDirectives\Api\TestRepositoryInterface" method="getList"/>
|
||||
<resources>
|
||||
<resource ref="Magento_TestModuleJoinDirectives::getList" />
|
||||
</resources>
|
||||
</route>
|
||||
</routes>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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_TestModuleJoinDirectives') === null) {
|
||||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestModuleJoinDirectives', __DIR__);
|
||||
}
|
||||
Reference in New Issue
Block a user