init
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user