This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,77 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule5\Service\V1;
use Magento\TestModule5\Service\V1\Entity\AllSoapAndRestFactory;
class AllSoapAndRest implements \Magento\TestModule5\Service\V1\AllSoapAndRestInterface
{
/**
* @var AllSoapAndRestFactory
*/
protected $factory;
/**
* @param AllSoapAndRestFactory $factory
*/
public function __construct(AllSoapAndRestFactory $factory)
{
$this->factory = $factory;
}
/**
* {@inheritdoc}
*/
public function item($entityId)
{
return $this->factory->create()
->setEntityId($entityId)
->setName('testItemName')
->setIsEnabled(true)
->setHasOrders(true);
}
/**
* {@inheritdoc}
*/
public function items()
{
$allSoapAndRest1 = $this->factory->create()->setEntityId(1)->setName('testProduct1');
$allSoapAndRest2 = $this->factory->create()->setEntityId(2)->setName('testProduct2');
return [$allSoapAndRest1, $allSoapAndRest2];
}
/**
* {@inheritdoc}
*/
public function create(\Magento\TestModule5\Service\V1\Entity\AllSoapAndRest $item)
{
return $this->factory->create()
->setEntityId($item->getEntityId())
->setName($item->getName())
->setIsEnabled($item->isEnabled())
->setHasOrders($item->hasOrders());
}
/**
* {@inheritdoc}
*/
public function update(\Magento\TestModule5\Service\V1\Entity\AllSoapAndRest $entityItem)
{
return $entityItem;
}
/**
* {@inheritdoc}
*/
public function nestedUpdate(
$parentId,
$entityId,
\Magento\TestModule5\Service\V1\Entity\AllSoapAndRest $entityItem
) {
return $entityItem;
}
}
@@ -0,0 +1,59 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule5\Service\V1;
/**
* Both SOAP and REST Version ONE
* @package Magento\TestModule5\Service\V1
*/
interface AllSoapAndRestInterface
{
/**
* Retrieve an item.
*
* @param int $entityId
* @return \Magento\TestModule5\Service\V1\Entity\AllSoapAndRest
* @throws \Magento\Framework\Webapi\Exception
*/
public function item($entityId);
/**
* Retrieve all items.
*
* @return \Magento\TestModule5\Service\V1\Entity\AllSoapAndRest[]
*/
public function items();
/**
* Create a new item.
*
* @param \Magento\TestModule5\Service\V1\Entity\AllSoapAndRest $item
* @return \Magento\TestModule5\Service\V1\Entity\AllSoapAndRest
*/
public function create(\Magento\TestModule5\Service\V1\Entity\AllSoapAndRest $item);
/**
* Update existing item.
*
* @param \Magento\TestModule5\Service\V1\Entity\AllSoapAndRest $entityItem
* @return \Magento\TestModule5\Service\V1\Entity\AllSoapAndRest
*/
public function update(\Magento\TestModule5\Service\V1\Entity\AllSoapAndRest $entityItem);
/**
* Update existing item.
*
* @param string $parentId
* @param string $entityId
* @param \Magento\TestModule5\Service\V1\Entity\AllSoapAndRest $entityItem
* @return \Magento\TestModule5\Service\V1\Entity\AllSoapAndRest
*/
public function nestedUpdate(
$parentId,
$entityId,
\Magento\TestModule5\Service\V1\Entity\AllSoapAndRest $entityItem
);
}
@@ -0,0 +1,122 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule5\Service\V1\Entity;
/**
* Some Data Object short description.
*
* Data Object long
* multi line description.
*/
class AllSoapAndRest extends \Magento\Framework\Api\AbstractExtensibleObject
{
/**
* Entity ID
*/
const ID = 'entity_id';
const NAME = 'name';
/**
* Is Enabled
*/
const ENABLED = 'enabled';
const HAS_ORDERS = 'orders';
/**
* Retrieve item ID.
*
* @return int Item ID
*/
public function getEntityId()
{
return $this->_get(self::ID);
}
/**
* Set item ID.
*
* @param int $entityId
* @return $this
*/
public function setEntityId($entityId)
{
return $this->setData(self::ID, $entityId);
}
/**
* Retrieve item Name.
*
* @return string|null Item name
*/
public function getName()
{
return $this->_get(self::NAME);
}
/**
* Set item Name.
*
* @param string $name
* @return $this
*/
public function setName($name)
{
return $this->setData(self::NAME, $name);
}
/**
* Check if entity is enabled
*
* @return bool
*/
public function isEnabled()
{
return $this->_get(self::ENABLED);
}
/**
* Set if entity is enabled
*
* @param bool $isEnabled
* @return bool
*/
public function setIsEnabled($isEnabled)
{
return $this->setData(self::ENABLED, $isEnabled);
}
/**
* Check if current entity has a property defined
*
* @return bool
*/
public function hasOrders()
{
return $this->_get(self::HAS_ORDERS);
}
/**
* Set whether current entity has a property defined
*
* @param bool $setHasOrders
* @return $this
*/
public function setHasOrders($hasOrders)
{
return $this->setData(self::HAS_ORDERS, $hasOrders);
}
/**
* Method which will not be used when adding complex type field to WSDL.
*
* @param string $value
* @return string
*/
public function getFieldExcludedFromWsdl($value)
{
return $value;
}
}
@@ -0,0 +1,36 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule5\Service\V1;
use Magento\TestModule5\Service\V1\Entity\AllSoapAndRestFactory;
class OverrideService implements OverrideServiceInterface
{
/**
* @var AllSoapAndRestFactory
*/
protected $factory;
/**
* @param AllSoapAndRestFactory $factory
*/
public function __construct(AllSoapAndRestFactory $factory)
{
$this->factory = $factory;
}
/**
* {@inheritdoc}
*/
public function scalarUpdate($entityId, $name, $hasOrders)
{
return $this->factory->create()
->setEntityId($entityId)
->setName($name)
->setHasOrders($hasOrders);
}
}
@@ -0,0 +1,20 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule5\Service\V1;
interface OverrideServiceInterface
{
/**
* Update existing item.
*
* @param string $entityId
* @param string $name
* @param bool $orders
* @return \Magento\TestModule5\Service\V1\Entity\AllSoapAndRest
*/
public function scalarUpdate($entityId, $name, $orders);
}
@@ -0,0 +1,70 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule5\Service\V2;
use Magento\TestModule5\Service\V2\Entity\AllSoapAndRest as AllSoapAndRestEntity;
use Magento\TestModule5\Service\V2\Entity\AllSoapAndRestFactory;
class AllSoapAndRest implements AllSoapAndRestInterface
{
/**
* @var AllSoapAndRestFactory
*/
protected $factory;
/**
* @param AllSoapAndRestFactory $factory
*/
public function __construct(AllSoapAndRestFactory $factory)
{
$this->factory = $factory;
}
/**
* @inheritdoc
*/
public function item($id)
{
return $this->factory->create()->setPrice(1)->setId($id)->setName('testItemName');
}
/**
* @inheritdoc
*/
public function items()
{
$allSoapAndRest1 = $this->factory->create()->setPrice(1)->setId(1)->setName('testProduct1');
$allSoapAndRest2 = $this->factory->create()->setPrice(1)->setId(2)->setName('testProduct2');
return [$allSoapAndRest1, $allSoapAndRest2];
}
/**
* @inheritdoc
*/
public function create(\Magento\TestModule5\Service\V2\Entity\AllSoapAndRest $item)
{
return $this->factory->create()->setPrice($item->getPrice());
}
/**
* @inheritdoc
*/
public function update(\Magento\TestModule5\Service\V2\Entity\AllSoapAndRest $item)
{
$item->setName('Updated' . $item->getName());
return $item;
}
/**
* @param string $id
* @return AllSoapAndRestEntity
* @throws \Magento\Framework\Webapi\Exception
*/
public function delete($id)
{
return $this->factory->create()->setPrice(1)->setId($id)->setName('testItemName');
}
}
@@ -0,0 +1,53 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule5\Service\V2;
/**
* Both SOAP and REST Version TWO
* @package Magento\TestModule5\Service\V2
*/
interface AllSoapAndRestInterface
{
/**
* Retrieve existing item.
*
* @param int $id
* @return \Magento\TestModule5\Service\V2\Entity\AllSoapAndRest
* @throws \Magento\Framework\Webapi\Exception
*/
public function item($id);
/**
* Retrieve a list of all existing items.
*
* @return \Magento\TestModule5\Service\V2\Entity\AllSoapAndRest[]
*/
public function items();
/**
* Add new item.
*
* @param \Magento\TestModule5\Service\V2\Entity\AllSoapAndRest $item
* @return \Magento\TestModule5\Service\V2\Entity\AllSoapAndRest
*/
public function create(\Magento\TestModule5\Service\V2\Entity\AllSoapAndRest $item);
/**
* Update one item.
*
* @param \Magento\TestModule5\Service\V2\Entity\AllSoapAndRest $item
* @return \Magento\TestModule5\Service\V2\Entity\AllSoapAndRest
*/
public function update(\Magento\TestModule5\Service\V2\Entity\AllSoapAndRest $item);
/**
* Delete existing item.
*
* @param string $id
* @return \Magento\TestModule5\Service\V2\Entity\AllSoapAndRest
*/
public function delete($id);
}
@@ -0,0 +1,28 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestModule5\Service\V2\Entity;
/**
* Some Data Object short description.
*
* Data Object long
* multi line description.
*/
class AllSoapAndRest extends \Magento\TestModule5\Service\V2\AllSoapAndRest
{
/**
* Price field
*/
const PRICE = 'price';
/**
* @return int
*/
public function getPrice()
{
return $this->_get(self::PRICE);
}
}
@@ -0,0 +1,20 @@
<?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_TestModule5::all" title="TestModule5" sortOrder="1">
<resource id="Magento_TestModule5::resource1" title="Resource1" sortOrder="20"/>
<resource id="Magento_TestModule5::resource2" title="Resource2" sortOrder="10"/>
<resource id="Magento_TestModule5::resource3" title="Resource3" sortOrder="30"/>
</resource>
</resource>
</resources>
</acl>
</config>
@@ -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:ObjectManager/etc/config.xsd">
<preference for="Magento\TestModule5\Service\V1\AllSoapAndRestInterface" type="Magento\TestModule5\Service\V1\AllSoapAndRest" />
<preference for="Magento\TestModule5\Service\V2\AllSoapAndRestInterface" type="Magento\TestModule5\Service\V2\AllSoapAndRest" />
<preference for="Magento\TestModule5\Service\V1\OverrideServiceInterface" type="Magento\TestModule5\Service\V1\OverrideService" />
</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_TestModule5" />
</config>
@@ -0,0 +1,79 @@
<?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 method="GET" url="/V1/TestModule5/:entityId">
<service class="Magento\TestModule5\Service\V1\AllSoapAndRestInterface" method="item" />
<resources>
<resource ref="Magento_TestModule5::resource1" />
</resources>
</route>
<route method="GET" url="/V1/TestModule5">
<service class="Magento\TestModule5\Service\V1\AllSoapAndRestInterface" method="items" />
<resources>
<resource ref="Magento_TestModule5::resource2" />
</resources>
</route>
<route method="POST" url="/V1/TestModule5">
<service class="Magento\TestModule5\Service\V1\AllSoapAndRestInterface" method="create" />
<resources>
<resource ref="Magento_TestModule5::resource3" />
</resources>
</route>
<route method="PUT" url="/V1/TestModule5/:entityId">
<service class="Magento\TestModule5\Service\V1\AllSoapAndRestInterface" method="update" />
<resources>
<resource ref="Magento_TestModule5::resource1" />
<resource ref="Magento_TestModule5::resource2" />
</resources>
</route>
<route method="PUT" url="/V1/TestModule5/:parentId/nestedResource/:entityId">
<service class="Magento\TestModule5\Service\V1\AllSoapAndRestInterface" method="nestedUpdate" />
<resources>
<resource ref="Magento_TestModule5::resource1" />
<resource ref="Magento_TestModule5::resource2" />
</resources>
</route>
<route method="PUT" url="/V1/TestModule5/OverrideService/:parentId/nestedResource/:entityId">
<service class="Magento\TestModule5\Service\V1\OverrideServiceInterface" method="scalarUpdate" />
<resources>
<resource ref="Magento_TestModule5::resource1" />
<resource ref="Magento_TestModule5::resource2" />
</resources>
</route>
<route method="GET" url="/V2/TestModule5/:id">
<service class="Magento\TestModule5\Service\V2\AllSoapAndRestInterface" method="item" />
<resources>
<resource ref="Magento_TestModule5::resource1" />
</resources>
</route>
<route method="GET" url="/V2/TestModule5">
<service class="Magento\TestModule5\Service\V2\AllSoapAndRestInterface" method="items" />
<resources>
<resource ref="Magento_TestModule5::resource2" />
</resources>
</route>
<route method="POST" url="/V2/TestModule5">
<service class="Magento\TestModule5\Service\V2\AllSoapAndRestInterface" method="create" />
<resources>
<resource ref="Magento_TestModule5::resource3" />
</resources>
</route>
<route method="PUT" url="/V2/TestModule5/:id">
<service class="Magento\TestModule5\Service\V2\AllSoapAndRestInterface" method="update" />
<resources>
<resource ref="Magento_TestModule5::resource1" />
<resource ref="Magento_TestModule5::resource2" />
</resources>
</route>
<route method="DELETE" url="/V2/TestModule5/:id">
<service class="Magento\TestModule5\Service\V2\AllSoapAndRestInterface" method="delete" />
<resources>
<resource ref="Magento_TestModule5::resource1" />
</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_TestModule5') === null) {
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestModule5', __DIR__);
}