本文整理汇总了PHP中Magento\Framework\AuthorizationInterface::isAllowed方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthorizationInterface::isAllowed方法的具体用法?PHP AuthorizationInterface::isAllowed怎么用?PHP AuthorizationInterface::isAllowed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\AuthorizationInterface
的用法示例。
在下文中一共展示了AuthorizationInterface::isAllowed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isDisplayed
/**
* Check whether survey question can show
*
* @return bool
*/
public function isDisplayed()
{
if ($this->_authSession->getHideSurveyQuestion() || false == $this->_authorization->isAllowed(null) || $this->_survey->isSurveyViewed() || false == $this->_survey->isSurveyUrlValid()) {
return false;
}
return true;
}
示例2: aroundDispatch
/**
* Replace standard admin login form with HTTP Basic authentication
*
* @param AbstractAction $subject
* @param callable $proceed
* @param RequestInterface $request
* @return ResponseInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function aroundDispatch(AbstractAction $subject, \Closure $proceed, RequestInterface $request)
{
$resource = isset($this->aclResources[$request->getControllerName()]) ? isset($this->aclResources[$request->getControllerName()][$request->getActionName()]) ? $this->aclResources[$request->getControllerName()][$request->getActionName()] : $this->aclResources[$request->getControllerName()] : null;
$type = $request->getParam('type');
$resourceType = isset($this->aclResources[$type]) ? $this->aclResources[$type] : null;
if (!$resource || !$resourceType) {
return parent::aroundDispatch($subject, $proceed, $request);
}
$session = $this->_auth->getAuthStorage();
// Try to login using HTTP-authentication
if (!$session->isLoggedIn()) {
list($login, $password) = $this->httpAuthentication->getCredentials();
try {
$this->_auth->login($login, $password);
} catch (AuthenticationException $e) {
$this->logger->critical($e);
}
}
// Verify if logged in and authorized
if (!$session->isLoggedIn() || !$this->authorization->isAllowed($resource) || !$this->authorization->isAllowed($resourceType)) {
$this->httpAuthentication->setAuthenticationFailed('RSS Feeds');
return $this->_response;
}
return parent::aroundDispatch($subject, $proceed, $request);
}
示例3: getUrl
/**
* Generate row url
* @param \Magento\Framework\DataObject $item
* @return bool|string
*/
public function getUrl($item)
{
if ($this->_authorization->isAllowed('Magento_Sales::actions_view')) {
return parent::getUrl($item);
}
return false;
}
示例4: __call
/**
* Handler for all SOAP operations.
*
* @param string $operation
* @param array $arguments
* @return \stdClass|null
* @throws WebapiException
* @throws \LogicException
* @throws AuthorizationException
*/
public function __call($operation, $arguments)
{
$requestedServices = $this->_request->getRequestedServices();
$serviceMethodInfo = $this->_apiConfig->getServiceMethodInfo($operation, $requestedServices);
$serviceClass = $serviceMethodInfo[SoapConfig::KEY_CLASS];
$serviceMethod = $serviceMethodInfo[SoapConfig::KEY_METHOD];
// check if the operation is a secure operation & whether the request was made in HTTPS
if ($serviceMethodInfo[SoapConfig::KEY_IS_SECURE] && !$this->_request->isSecure()) {
throw new WebapiException(__("Operation allowed only in HTTPS"));
}
$isAllowed = false;
foreach ($serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES] as $resource) {
if ($this->_authorization->isAllowed($resource)) {
$isAllowed = true;
break;
}
}
if (!$isAllowed) {
throw new AuthorizationException(__(AuthorizationException::NOT_AUTHORIZED, ['resources' => implode(', ', $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES])]));
}
$service = $this->_objectManager->get($serviceClass);
$inputData = $this->_prepareRequestData($serviceClass, $serviceMethod, $arguments);
$outputData = call_user_func_array([$service, $serviceMethod], $inputData);
return $this->_prepareResponseData($outputData, $serviceClass, $serviceMethod);
}
示例5: getUrl
/**
* Create url for passed item using passed url model
* @param \Magento\Framework\Object $item
* @return string
*/
public function getUrl($item)
{
if ($this->_authorization->isAllowed('Magento_Customer::manage') && $item->getCustomerId()) {
return parent::getUrl($item);
}
return false;
}
示例6: update
/**
* Remove massaction items in case they disallowed for user
* @param mixed $argument
* @return mixed
*/
public function update($argument)
{
if (false === $this->authorization->isAllowed('Magento_Indexer::changeMode')) {
unset($argument['change_mode_onthefly']);
unset($argument['change_mode_changelog']);
}
return $argument;
}
示例7: execute
/**
* Block admin ability to use customer billing agreements
*
* @param EventObserver $observer
* @return void
*/
public function execute($observer)
{
$event = $observer->getEvent();
$methodInstance = $event->getMethodInstance();
if ($methodInstance instanceof \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement && false == $this->_authorization->isAllowed('Magento_Paypal::use')) {
$event->getResult()->isAvailable = false;
}
}
示例8: canAddAttributes
/**
* @return boolean
*/
protected function canAddAttributes()
{
$isWrapped = $this->registry->registry('use_wrapper');
if (!isset($isWrapped)) {
$isWrapped = true;
}
return $isWrapped && $this->authorization->isAllowed('Magento_Catalog::attributes_attributes');
}
示例9: getButtonData
/**
* @return array
*/
public function getButtonData()
{
$customerId = $this->getCustomerId();
$data = [];
if ($customerId && $this->authorization->isAllowed('Magento_Sales::create')) {
$data = ['label' => __('Create Order'), 'on_click' => sprintf("location.href = '%s';", $this->getCreateOrderUrl()), 'class' => 'add', 'sort_order' => 40];
}
return $data;
}
示例10: isAllowed
/**
* Check if all ACL resources are allowed to be accessed by current API user.
*
* @param string[] $aclResources
* @return bool
*/
public function isAllowed($aclResources)
{
foreach ($aclResources as $resource) {
if (!$this->authorization->isAllowed($resource)) {
return false;
}
}
return true;
}
示例11: getButtonData
/**
* @return array
*/
public function getButtonData()
{
$customerId = $this->getCustomerId();
$data = [];
$canModify = $customerId && $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button');
if ($canModify) {
$data = ['label' => __('Login As Customer'), 'class' => 'login login-button', 'on_click' => 'window.open( \'' . $this->getInvalidateTokenUrl() . '\')', 'sort_order' => 70];
}
return $data;
}
示例12: prepareDataSource
/**
* Prepare Data Source
*
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$hidden = !$this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button');
foreach ($dataSource['data']['items'] as &$item) {
$item[$this->getData('name')]['edit'] = ['href' => $this->urlBuilder->getUrl('loginascustomer/login/login', ['customer_id' => $item['entity_id']]), 'label' => __('Login As Customer'), 'hidden' => $hidden, 'target' => '_blank'];
}
}
return $dataSource;
}
示例13: execute
/**
* Block admin ability to use customer billing agreements
*
* @param EventObserver $observer
* @return void
*/
public function execute(EventObserver $observer)
{
$event = $observer->getEvent();
$methodInstance = $event->getMethodInstance();
if ($methodInstance instanceof \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement && false == $this->_authorization->isAllowed('Magento_Paypal::use')) {
/** @var \Magento\Framework\DataObject $result */
$result = $observer->getEvent()->getResult();
$result->setData('is_available', false);
}
}
示例14: filterAclNodes
/**
* Delete nodes that have "acl" attribute but value is "not allowed"
* In any case, the "acl" attribute will be unset
*
* @param \Magento\Framework\Simplexml\Element $xml
* @return void
*/
public function filterAclNodes(\Magento\Framework\Simplexml\Element $xml)
{
$limitations = $xml->xpath('//*[@acl]') ?: array();
foreach ($limitations as $node) {
if (!$this->_authorization->isAllowed($node['acl'])) {
$node->unsetSelf();
} else {
unset($node['acl']);
}
}
}
示例15: filterAclElements
/**
* Delete elements that have "acl" attribute but value is "not allowed"
* In any case, the "acl" attribute will be unset
*
* @param ScheduledStructure $scheduledStructure
* @param Structure $structure
*/
public function filterAclElements(ScheduledStructure $scheduledStructure, Structure $structure)
{
foreach ($scheduledStructure->getElements() as $name => $data) {
list(, $data) = $data;
if (isset($data['attributes']['acl']) && $data['attributes']['acl']) {
if (!$this->authorization->isAllowed($data['attributes']['acl'])) {
$this->removeElement($scheduledStructure, $structure, $name);
}
}
}
}