Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-webapi
Model
WebapiRoleLocator.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Webapi\Model
;
8
9
use Magento\Authorization\Model\ResourceModel\Role\CollectionFactory as RoleCollectionFactory;
10
use
Magento\Authorization\Model\Role
;
11
use
Magento\Authorization\Model\UserContextInterface
;
12
use
Magento\Framework\Authorization\RoleLocatorInterface
;
13
14
class
WebapiRoleLocator
implements
RoleLocatorInterface
15
{
19
protected
$userContext
;
20
24
protected
$roleCollectionFactory
;
25
32
public
function
__construct
(
33
UserContextInterface
$userContext
,
34
RoleCollectionFactory
$roleCollectionFactory
35
) {
36
$this->userContext =
$userContext
;
37
$this->roleCollectionFactory =
$roleCollectionFactory
;
38
}
39
43
public
function
getAclRoleId
()
44
{
45
$userId = $this->userContext->getUserId();
46
$userType = $this->userContext->getUserType();
47
48
$roleCollection = $this->roleCollectionFactory->create();
50
$role = $roleCollection->setUserFilter($userId, $userType)->getFirstItem();
51
52
if
(!$role->getId()) {
53
return
null
;
54
}
55
56
return
$role->getId();
57
}
58
}
Magento\Framework\Authorization\RoleLocatorInterface\getAclRoleId
getAclRoleId()
Magento\Authorization\Model\UserContextInterface
Definition:
UserContextInterface.php:15
Magento\Webapi\Model
Magento\Webapi\Model\WebapiRoleLocator\__construct
__construct(UserContextInterface $userContext, RoleCollectionFactory $roleCollectionFactory)
Definition:
WebapiRoleLocator.php:32
Magento\Webapi\Model\WebapiRoleLocator
Definition:
WebapiRoleLocator.php:14
Magento\Framework\Authorization\RoleLocatorInterface
Definition:
RoleLocatorInterface.php:16
Magento\Authorization\Model\Role
Definition:
Role.php:29
Magento\Webapi\Model\WebapiRoleLocator\$roleCollectionFactory
$roleCollectionFactory
Definition:
WebapiRoleLocator.php:24
Magento\Webapi\Model\WebapiRoleLocator\$userContext
$userContext
Definition:
WebapiRoleLocator.php:19