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
8 
9 class Factory
10 {
14  const DEFAULT_VALIDATOR = \Magento\Paypal\Helper\Shortcut\Validator::class;
15 
19  const CHECKOUT_VALIDATOR = \Magento\Paypal\Helper\Shortcut\CheckoutValidator::class;
20 
24  protected $_objectManager;
25 
30  {
31  $this->_objectManager = $objectManager;
32  }
33 
38  public function create($parameter = null)
39  {
40  $instanceName = self::DEFAULT_VALIDATOR;
41  if (is_object($parameter) && $parameter instanceof \Magento\Checkout\Model\Session) {
42  $instanceName = self::CHECKOUT_VALIDATOR;
43  }
44  return $this->_objectManager->create($instanceName);
45  }
46 }
$objectManager
Definition: bootstrap.php:17
__construct(\Magento\Framework\ObjectManagerInterface $objectManager)
Definition: Factory.php:29