Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MysqlFactory.php
Go to the documentation of this file.
1 <?php
7 
12 
17 {
21  private $objectManager;
22 
28  public function __construct(
29  ObjectManagerInterface $objectManager
30  ) {
31  $this->objectManager = $objectManager;
32  }
33 
44  public function create(
45  $className,
46  array $config,
47  LoggerInterface $logger = null,
48  SelectFactory $selectFactory = null
49  ) {
50  if (!in_array(Mysql::class, class_parents($className, true) + [$className => $className])) {
51  throw new \InvalidArgumentException('Invalid class, ' . $className . ' must extend ' . Mysql::class . '.');
52  }
53  $arguments = [
54  'config' => $config
55  ];
56  if ($logger) {
57  $arguments['logger'] = $logger;
58  }
59  if ($selectFactory) {
60  $arguments['selectFactory'] = $selectFactory;
61  }
62  return $this->objectManager->create(
63  $className,
65  );
66  }
67 }
create( $className, array $config, LoggerInterface $logger=null, SelectFactory $selectFactory=null)
$objectManager
Definition: bootstrap.php:17
$config
Definition: fraud_order.php:17
$logger
$arguments
__construct(ObjectManagerInterface $objectManager)
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31