Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CommentFactory.php
Go to the documentation of this file.
1 <?php
11 
17 {
21  protected $_objectManager;
22 
26  public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
27  {
28  $this->_objectManager = $objectManager;
29  }
30 
38  public function create($type)
39  {
40  $commentModel = $this->_objectManager->create($type);
41  if (!$commentModel instanceof CommentInterface) {
42  throw new \InvalidArgumentException('Incorrect comment model provided');
43  }
44  return $commentModel;
45  }
46 }
__construct(\Magento\Framework\ObjectManagerInterface $objectManager)
$objectManager
Definition: bootstrap.php:17
$type
Definition: item.phtml:13