Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new ImportConfig method to Search Service #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions app/code/Magento/SearchStorefrontApi/Api/Data/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php
// Generated by the Magento PHP proto generator. DO NOT EDIT!

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\SearchStorefrontApi\Api\Data;

/**
* Autogenerated description for Config class
*
* phpcs:disable Magento2.PHP.FinalImplementation
*
* @SuppressWarnings(PHPMD)
* @SuppressWarnings(PHPCPD)
*/
final class Config implements ConfigInterface
{

/**
* @var string
*/
private $name;

/**
* @var string
*/
private $value;

/**
* @var string
*/
private $store;

/**
* @inheritdoc
*
* @return string
*/
public function getName(): string
{
return (string) $this->name;
}

/**
* @inheritdoc
*
* @param string $value
* @return void
*/
public function setName(string $value): void
{
$this->name = $value;
}

/**
* @inheritdoc
*
* @return string
*/
public function getValue(): string
{
return (string) $this->value;
}

/**
* @inheritdoc
*
* @param string $value
* @return void
*/
public function setValue(string $value): void
{
$this->value = $value;
}

/**
* @inheritdoc
*
* @return string
*/
public function getStore(): string
{
return (string) $this->store;
}

/**
* @inheritdoc
*
* @param string $value
* @return void
*/
public function setStore(string $value): void
{
$this->store = $value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
// Generated by the Magento PHP proto generator. DO NOT EDIT!

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\SearchStorefrontApi\Api\Data;

use Magento\Framework\ObjectManagerInterface;

/**
* Autogenerated description for Config class
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.UnusedPrivateField)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
final class ConfigArrayMapper
{
/**
* @var mixed
*/
private $data;

/**
* @var ObjectManagerInterface
*/
private $objectManager;

public function __construct(ObjectManagerInterface $objectManager)
{
$this->objectManager = $objectManager;
}

/**
* Convert the DTO to the array with the data
*
* @param Config $dto
* @return array
*/
public function convertToArray(Config $dto)
{
$result = [];
$result["name"] = $dto->getName();
$result["value"] = $dto->getValue();
$result["store"] = $dto->getStore();
return $result;
}
}
64 changes: 64 additions & 0 deletions app/code/Magento/SearchStorefrontApi/Api/Data/ConfigInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
// Generated by the Magento PHP proto generator. DO NOT EDIT!

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\SearchStorefrontApi\Api\Data;

/**
* Autogenerated description for Config interface
*
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
*/
interface ConfigInterface
{
/**
* Autogenerated description for getName() interface method
*
* @return string
*/
public function getName(): string;

/**
* Autogenerated description for setName() interface method
*
* @param string $value
* @return void
*/
public function setName(string $value): void;

/**
* Autogenerated description for getValue() interface method
*
* @return string
*/
public function getValue(): string;

/**
* Autogenerated description for setValue() interface method
*
* @param string $value
* @return void
*/
public function setValue(string $value): void;

/**
* Autogenerated description for getStore() interface method
*
* @return string
*/
public function getStore(): string;

/**
* Autogenerated description for setStore() interface method
*
* @param string $value
* @return void
*/
public function setStore(string $value): void;
}
99 changes: 99 additions & 0 deletions app/code/Magento/SearchStorefrontApi/Api/Data/ConfigMapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php
// Generated by the Magento PHP proto generator. DO NOT EDIT!

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\SearchStorefrontApi\Api\Data;

use Magento\Framework\ObjectManagerInterface;

/**
* Autogenerated description for Config class
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.UnusedPrivateField)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
final class ConfigMapper
{
/**
* @var string
*/
private static $dtoClassName = ConfigInterface::class;

/**
* @var mixed
*/
private $data;

/**
* @var ObjectManagerInterface
*/
private $objectManager;

public function __construct(ObjectManagerInterface $objectManager)
{
$this->objectManager = $objectManager;
}

/**
* Set the data to populate the DTO
*
* @param mixed $data
* @return $this
*/
public function setData($data)
{
$this->data = $data;
return $this;
}

/**
* Build new DTO populated with the data
*
* @return Config
*/
public function build()
{
$dto = $this->objectManager->create(self::$dtoClassName);
foreach ($this->data as $key => $valueData) {
if ($valueData === null) {
continue;
}
$this->setByKey($dto, $key, $valueData);
}
return $dto;
}

/**
* Set the value of the key using setters.
*
* In case if the field is object, the corresponding Mapper would be create and DTO representing the field data
* would be built
*
* @param Config $dto
* @param string $key
* @param mixed $value
*/
private function setByKey(Config $dto, string $key, $value): void
{
switch ($key) {
case "name":
$dto->setName((string) $value);
break;
case "value":
$dto->setValue((string) $value);
break;
case "store":
$dto->setStore((string) $value);
break;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
// Generated by the Magento PHP proto generator. DO NOT EDIT!

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\SearchStorefrontApi\Api\Data;

/**
* Autogenerated description for ImportConfigRequest class
*
* phpcs:disable Magento2.PHP.FinalImplementation
*
* @SuppressWarnings(PHPMD)
* @SuppressWarnings(PHPCPD)
*/
final class ImportConfigRequest implements ImportConfigRequestInterface
{

/**
* @var array
*/
private $config;

/**
* @inheritdoc
*
* @return \Magento\SearchStorefrontApi\Api\Data\ConfigInterface[]
*/
public function getConfig(): array
{
return (array) $this->config;
}

/**
* @inheritdoc
*
* @param \Magento\SearchStorefrontApi\Api\Data\ConfigInterface[] $value
* @return void
*/
public function setConfig(array $value): void
{
$this->config = $value;
}
}
Loading