Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
namespace Magento\Signifyd\Model\CaseServices;

use Magento\Framework\Api\SimpleDataObjectConverter;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NotFoundException;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CommentsHistoryUpdater;
Expand Down Expand Up @@ -73,7 +73,6 @@ public function __construct(
* @param CaseInterface $case
* @param array $data
* @return void
* @throws NotFoundException
* @throws LocalizedException
*/
public function update(CaseInterface $case, array $data)
Expand Down Expand Up @@ -111,7 +110,7 @@ private function setCaseData(CaseInterface $case, array $data)
'orderId'
];
foreach ($data as $key => $value) {
$methodName = 'set' . ucfirst($key);
$methodName = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key);
if (!in_array($key, $notResolvedKeys) && method_exists($case, $methodName)) {
call_user_func([$case, $methodName], $value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private function isPropertyDeclaredInDataObject(
$index = array_search($serviceMethodParamName, array_column($methodParams, 'name'));
if ($index !== false) {
$paramObjectType = $methodParams[$index][MethodsMap::METHOD_META_TYPE];
$setter = 'set' . ucfirst(SimpleDataObjectConverter::snakeCaseToCamelCase($objectProperty));
$setter = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($objectProperty);
if (array_key_exists(
$setter,
$this->getMethodsMap()->getMethodsMap($paramObjectType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Magento\Framework\Convert\ConvertArray;
use Magento\Framework\Reflection\DataObjectProcessor;

/**
* Data object converter.
*/
class SimpleDataObjectConverter
{
/**
Expand Down Expand Up @@ -156,14 +159,13 @@ public static function snakeCaseToUpperCamelCase($input)
*/
public static function snakeCaseToCamelCase($input)
{
return lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $input))));
return lcfirst(self::snakeCaseToUpperCamelCase($input));
}

/**
* Convert a CamelCase string read from method into field key in snake_case
*
* e.g. DefaultShipping => default_shipping
* Postcode => postcode
* For example [DefaultShipping => default_shipping, Postcode => postcode]
*
* @param string $name
* @return string
Expand Down
10 changes: 7 additions & 3 deletions lib/internal/Magento/Framework/App/Request/DataPersistor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
*/
namespace Magento\Framework\App\Request;

use Magento\Framework\Api\SimpleDataObjectConverter;
use Magento\Framework\Session\SessionManagerInterface;

/**
* Persist data to session.
*/
class DataPersistor implements DataPersistorInterface
{
/**
Expand All @@ -32,7 +36,7 @@ public function __construct(
*/
public function set($key, $data)
{
$method = 'set' . ucfirst($key) . 'Data';
$method = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key) . 'Data';
call_user_func_array([$this->session, $method], [$data]);
}

Expand All @@ -44,7 +48,7 @@ public function set($key, $data)
*/
public function get($key)
{
$method = 'get' . ucfirst($key) . 'Data';
$method = 'get' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key) . 'Data';
return call_user_func_array([$this->session, $method], []);
}

Expand All @@ -56,7 +60,7 @@ public function get($key)
*/
public function clear($key)
{
$method = 'uns' . ucfirst($key) . 'Data';
$method = 'uns' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key) . 'Data';
call_user_func_array([$this->session, $method], []);
}
}