Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PatchFactory.php
Go to the documentation of this file.
1 <?php
8 
10 
16 {
20  private $objectManager;
21 
25  public function __construct(ObjectManagerInterface $objectManager)
26  {
27  $this->objectManager = $objectManager;
28  }
29 
37  public function create($instanceName, $arguments = [])
38  {
39  $patchInstance = $this->objectManager->create('\\' . $instanceName, $arguments);
40  if (!$patchInstance instanceof PatchInterface) {
41  throw new \InvalidArgumentException(
42  sprintf(
43  "%s should implement %s interface",
44  $instanceName,
45  PatchInterface::class
46  )
47  );
48  }
49 
50  return $patchInstance;
51  }
52 }
$objectManager
Definition: bootstrap.php:17
__construct(ObjectManagerInterface $objectManager)
create($instanceName, $arguments=[])
$arguments