SearchCollectionFactory.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Search\Model;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. class SearchCollectionFactory
  12. {
  13. /**
  14. * Object Manager instance
  15. *
  16. * @var \Magento\Framework\ObjectManagerInterface
  17. */
  18. protected $_objectManager = null;
  19. /**
  20. * Instance name to create
  21. *
  22. * @var string
  23. */
  24. protected $_instanceName = null;
  25. /**
  26. * Factory constructor
  27. *
  28. * @param \Magento\Framework\ObjectManagerInterface $objectManager
  29. * @param string $instanceName
  30. */
  31. public function __construct(
  32. \Magento\Framework\ObjectManagerInterface $objectManager,
  33. $instanceName = \Magento\Search\Model\SearchCollectionInterface::class
  34. ) {
  35. $this->_objectManager = $objectManager;
  36. $this->_instanceName = $instanceName;
  37. }
  38. /**
  39. * Create class instance with specified parameters
  40. *
  41. * @param array $data
  42. * @return \Magento\Search\Model\SearchCollectionInterface
  43. */
  44. public function create(array $data = [])
  45. {
  46. return $this->_objectManager->create($this->_instanceName, $data);
  47. }
  48. }