-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3937 from magento-mpi/pr_2019_03_20
[mpi] bugfixes
- Loading branch information
Showing
30 changed files
with
830 additions
and
243 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
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
44 changes: 44 additions & 0 deletions
44
app/code/Magento/Elasticsearch/SearchAdapter/Query/ValueTransformer/DateTransformer.php
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,44 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Elasticsearch\SearchAdapter\Query\ValueTransformer; | ||
|
||
use Magento\Elasticsearch\Model\Adapter\FieldType\Date; | ||
use Magento\Elasticsearch\SearchAdapter\Query\ValueTransformerInterface; | ||
|
||
/** | ||
* Value transformer for date type fields. | ||
*/ | ||
class DateTransformer implements ValueTransformerInterface | ||
{ | ||
/** | ||
* @var Date | ||
*/ | ||
private $dateFieldType; | ||
|
||
/** | ||
* @param Date $dateFieldType | ||
*/ | ||
public function __construct(Date $dateFieldType) | ||
{ | ||
$this->dateFieldType = $dateFieldType; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function transform(string $value): ?string | ||
{ | ||
try { | ||
$formattedDate = $this->dateFieldType->formatDate(null, $value); | ||
} catch (\Exception $e) { | ||
$formattedDate = null; | ||
} | ||
|
||
return $formattedDate; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/code/Magento/Elasticsearch/SearchAdapter/Query/ValueTransformer/FloatTransformer.php
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,24 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Elasticsearch\SearchAdapter\Query\ValueTransformer; | ||
|
||
use Magento\Elasticsearch\SearchAdapter\Query\ValueTransformerInterface; | ||
|
||
/** | ||
* Value transformer for float type fields. | ||
*/ | ||
class FloatTransformer implements ValueTransformerInterface | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function transform(string $value): ?float | ||
{ | ||
return \is_numeric($value) ? (float) $value : null; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/code/Magento/Elasticsearch/SearchAdapter/Query/ValueTransformer/IntegerTransformer.php
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,24 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Elasticsearch\SearchAdapter\Query\ValueTransformer; | ||
|
||
use Magento\Elasticsearch\SearchAdapter\Query\ValueTransformerInterface; | ||
|
||
/** | ||
* Value transformer for integer type fields. | ||
*/ | ||
class IntegerTransformer implements ValueTransformerInterface | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function transform(string $value): ?int | ||
{ | ||
return \is_numeric($value) ? (int) $value : null; | ||
} | ||
} |
Oops, something went wrong.