Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Factory.php
Go to the documentation of this file.
1 <?php
7 
11 class Factory
12 {
18  protected $_objectManager;
19 
25  public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
26  {
27  $this->_objectManager = $objectManager;
28  }
29 
38  public function create($className, $data = [])
39  {
40  $method = $this->_objectManager->create($className, $data);
41  if (!$method instanceof \Magento\Payment\Model\MethodInterface) {
42  throw new \Magento\Framework\Exception\LocalizedException(
43  __('%1 class doesn\'t implement \Magento\Payment\Model\MethodInterface', $className)
44  );
45  }
46  return $method;
47  }
48 }
$objectManager
Definition: bootstrap.php:17
__()
Definition: __.php:13
__construct(\Magento\Framework\ObjectManagerInterface $objectManager)
Definition: Factory.php:25
$method
Definition: info.phtml:13
create($className, $data=[])
Definition: Factory.php:38
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31