30 lines
917 B
PHP
30 lines
917 B
PHP
<?php
|
|
namespace Stemcell\ChineseDirectory\Model;
|
|
|
|
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
|
use Magento\Framework\ObjectManagerInterface;
|
|
|
|
class CollectionFactory
|
|
{
|
|
protected ObjectManagerInterface $_objectManager;
|
|
|
|
public function __construct(
|
|
ObjectManagerInterface $_objectManager
|
|
) {
|
|
$this->_objectManager = $_objectManager;
|
|
}
|
|
|
|
/**
|
|
* @param String $collectionType
|
|
* @param array $data
|
|
* @return AbstractCollection
|
|
*/
|
|
public function create(String $collectionType, array $data = []) {
|
|
$collection = 'Stemcell\ChineseDirectory\Model\ResourceModel\\'.ucfirst($collectionType).'\Collection';
|
|
if (strtolower($collectionType)==='region') {
|
|
$collection = 'Magento\Directory\Model\ResourceModel\Region\Collection';
|
|
}
|
|
return $this->_objectManager->create($collection, $data);
|
|
}
|
|
}
|