| Current Path : /var/www/html/app/code/FlipsDigital/TextbookList/Model/Options/ |
| Current File : /var/www/html/app/code/FlipsDigital/TextbookList/Model/Options/TextbookList.php |
<?php
namespace FlipsDigital\TextbookList\Model\Options;
class TextbookList implements \Magento\Framework\Option\ArrayInterface
{
protected $_options;
protected $_storeManager;
protected $_objectManager;
public function __construct(
\Magento\Framework\ObjectManagerInterface $objectManagerInterface,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->_objectManager = $objectManagerInterface;
$this->_storeManager = $storeManager;
}
public function toOptionArray()
{
$this->_options = [];
array_unshift($this->_options, ['value' => '', 'label' => __('-- Please Select --')]);
$entityFactory = $this->_objectManager->create(\FlipsDigital\TextbookList\Model\ResourceModel\TextbookList\Collection::class);
$arrEnities = $entityFactory->addAttributeToSelect('*')
->setOrder('id','ASC')
->setStore($this->_storeManager->getStore());
if (count($arrEnities)){
foreach ($arrEnities as $objEntity){
$this->_options[] = [
'label' => $objEntity->getData('class_name') . ' - ' . $objEntity->getData('group_name'),
'value' => $objEntity->getId(),
];
}
}
return $this->_options;
}
}