CommentFactory.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * System configuration comment model factory
  8. */
  9. namespace Magento\Config\Model\Config;
  10. /**
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class CommentFactory
  15. {
  16. /**
  17. * @var \Magento\Framework\ObjectManagerInterface
  18. */
  19. protected $_objectManager;
  20. /**
  21. * @param \Magento\Framework\ObjectManagerInterface $objectManager
  22. */
  23. public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
  24. {
  25. $this->_objectManager = $objectManager;
  26. }
  27. /**
  28. * Create new config object
  29. *
  30. * @param string $type
  31. * @return CommentInterface
  32. * @throws \InvalidArgumentException
  33. */
  34. public function create($type)
  35. {
  36. $commentModel = $this->_objectManager->create($type);
  37. if (!$commentModel instanceof CommentInterface) {
  38. throw new \InvalidArgumentException('Incorrect comment model provided');
  39. }
  40. return $commentModel;
  41. }
  42. }