I need the list of all the admin users.
And, both the below set of codes, provide the same result.
Code 1
public function __construct(
\Magento\User\Model\ResourceModel\User\Collection $userCollectionFactory
)
{
$this->userCollectionFactory = $userCollectionFactory;
}
public function getCustomData()
{
$userCollection = $this->userCollectionFactory;
var_dump($userCollection->getData());
}
Code 2
public function __construct(
\Magento\User\Model\ResourceModel\User\CollectionFactory $userCollectionFactory
)
{
$this->userCollectionFactory = $userCollectionFactory;
}
public function getCustomData()
{
$userCollection = $this->userCollectionFactory->create();
var_dump($userCollection->getData());
exit('test');
}
My question here is, what is the difference between both these set of codes and which one is better to use and in which case we can use the other one? And if there is any other better way to fetch the same result set?