Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PaymentTokenFactory.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Vault\Model;
8 
12 
19 {
23  private $tokenTypes = [];
24 
28  private $objectManager;
29 
35  public function __construct(ObjectManagerInterface $objectManager, array $tokenTypes = [])
36  {
37  $this->objectManager = $objectManager;
38  $this->tokenTypes = $tokenTypes;
39  }
40 
47  public function create($type = null)
48  {
53  if (is_array($type)) {
54  return $this->objectManager->create(
55  PaymentTokenInterface::class,
56  $type
57  );
58  }
59 
60  if ($type !== null && !in_array($type, $this->tokenTypes, true)) {
61  throw new \LogicException('There is no such payment token type: ' . $type);
62  }
63 
64  return $this->objectManager->create(
65  PaymentTokenInterface::class,
66  ['data' => [PaymentTokenInterface::TYPE => $type]]
67  );
68  }
69 }
__construct(ObjectManagerInterface $objectManager, array $tokenTypes=[])
$objectManager
Definition: bootstrap.php:17
$type
Definition: item.phtml:13