-
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.
MAGETWO-69879: Fix PaymentTokenFactory interface to have the "Interfa…
…ce" at the end of the name. #9306
- Loading branch information
Showing
9 changed files
with
147 additions
and
14 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
app/code/Magento/Vault/Api/Data/PaymentTokenFactoryInterface.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,28 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Vault\Api\Data; | ||
|
||
/** | ||
* Interface PaymentTokenFactoryInterface | ||
* @api | ||
*/ | ||
interface PaymentTokenFactoryInterface | ||
{ | ||
/** | ||
* Payment Token types | ||
* @var string | ||
*/ | ||
const TOKEN_TYPE_ACCOUNT = 'account'; | ||
const TOKEN_TYPE_CREDIT_CARD = 'card'; | ||
|
||
/** | ||
* Create payment token entity | ||
* @param $type string|null | ||
* @return PaymentTokenInterface | ||
*/ | ||
public function create($type = null); | ||
} |
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,62 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Vault\Model; | ||
|
||
use Magento\Framework\ObjectManagerInterface; | ||
use Magento\Vault\Api\Data\PaymentTokenFactoryInterface; | ||
use Magento\Vault\Api\Data\PaymentTokenInterface; | ||
|
||
/** | ||
* PaymentTokenFactory class | ||
* @api | ||
*/ | ||
class PaymentTokenFactory implements PaymentTokenFactoryInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $tokenTypes = []; | ||
|
||
/** | ||
* PaymentTokenFactory constructor. | ||
* @param ObjectManagerInterface $objectManager | ||
* @param array $tokenTypes | ||
*/ | ||
public function __construct(ObjectManagerInterface $objectManager, array $tokenTypes = []) | ||
{ | ||
$this->objectManager = $objectManager; | ||
$this->tokenTypes = $tokenTypes; | ||
} | ||
|
||
/** | ||
* Create payment token entity | ||
* @param $type string | ||
* @return PaymentTokenInterface | ||
*/ | ||
public function create($type = null) | ||
{ | ||
/** | ||
* This code added for Backward Compatibility reasons only, as previous implementation of Code Generated factory | ||
* accepted an array as any other code generated factory | ||
*/ | ||
if (is_array($type)) { | ||
return $this->objectManager->create( | ||
PaymentTokenInterface::class, | ||
$type | ||
); | ||
} | ||
|
||
if ($type !== null && !in_array($type, $this->tokenTypes, true)) { | ||
throw new \LogicException('There is no such payment token type: ' . $type); | ||
} | ||
|
||
return $this->objectManager->create( | ||
PaymentTokenInterface::class, | ||
['data' => [PaymentTokenInterface::TYPE => $type]] | ||
); | ||
} | ||
} |
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