-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
691 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* @author Bloomreach | ||
* @copyright Copyright (c) Bloomreach (https://www.bloomreach.com/) | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Bloomreach\EngagementConnector\Model\DataMapping; | ||
|
||
use Bloomreach\EngagementConnector\Service\ValueTypeGetter; | ||
use Magento\Framework\Exception\NotFoundException; | ||
|
||
/** | ||
* This class is responsible for getting field type | ||
*/ | ||
class FieldTypeResolver | ||
{ | ||
/** | ||
* @var ConfigResolver | ||
*/ | ||
private $configResolver; | ||
|
||
/** | ||
* @var ValueTypeGetter | ||
*/ | ||
private $valueTypeGetter; | ||
|
||
/** | ||
* @param ConfigResolver $configResolver | ||
* @param ValueTypeGetter $valueTypeGetter | ||
*/ | ||
public function __construct( | ||
ConfigResolver $configResolver, | ||
ValueTypeGetter $valueTypeGetter | ||
) { | ||
$this->configResolver = $configResolver; | ||
$this->valueTypeGetter = $valueTypeGetter; | ||
} | ||
|
||
/** | ||
* Get field type | ||
* | ||
* @param string $entityType | ||
* @param string $fieldCode | ||
* @param mixed $value | ||
* | ||
* @return string | ||
* @throws NotFoundException | ||
*/ | ||
public function get(string $entityType, string $fieldCode, $value): string | ||
{ | ||
$fieldConfig = $this->configResolver->getByEntityType($entityType)[$fieldCode] ?? null; | ||
|
||
return $fieldConfig && $fieldConfig->getType() | ||
? $fieldConfig->getType() | ||
: $this->valueTypeGetter->execute($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.