/** * Class constructor * * @return void */ protected function _construct() { parent::_construct(); $roleId = $this->getRequest()->getParam('rid', false); /** @var \Magento\User\Model\ResourceModel\User\Collection $users */ $users = $this->_userCollectionFactory->create()->load(); $this->setTemplate('role/users.phtml')->assign('users', $users->getItems())->assign('roleId', $roleId); }
/** * Retrieve option array * * @return string[] */ public function getOptionArray() { $result = []; foreach ($this->userCollectionFactory->create() as $user) { $result[$user->getId()] = $user->getName(); } return $result; }
/** * Options getter * * @return array */ public function toOptionArray() { if ($this->options === null) { $this->options = [['label' => __('Please select'), 'value' => 0]]; $collection = $this->authorCollectionFactory->create(); foreach ($collection as $item) { $this->options[] = ['label' => $item->getName(), 'value' => $item->getId()]; } } return $this->options; }