当前位置: 首页>>代码示例>>PHP>>正文


PHP Framework\AuthorizationInterface类代码示例

本文整理汇总了PHP中Magento\Framework\AuthorizationInterface的典型用法代码示例。如果您正苦于以下问题:PHP AuthorizationInterface类的具体用法?PHP AuthorizationInterface怎么用?PHP AuthorizationInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AuthorizationInterface类的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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Survey.php

示例2: __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);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:35,代码来源:Handler.php

示例3: 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);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:BackendAuthentication.php

示例4: 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;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:UrlGenerator.php

示例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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:UrlGenerator.php

示例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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:ItemsUpdater.php

示例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;
     }
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:14,代码来源:RestrictAdminBillingAgreementUsage.php

示例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');
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:11,代码来源:Attributes.php

示例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;
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:12,代码来源:OrderButton.php

示例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;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:Authorization.php

示例11: 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);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:RestrictAdminBillingAgreementUsageObserver.php

示例12: 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;
 }
开发者ID:magefan,项目名称:module-login-as-customer,代码行数:13,代码来源:Login.php

示例13: testExecute

 /**
  * @param object $methodInstance
  * @param bool $isAllowed
  * @param bool $isAvailable
  * @dataProvider restrictAdminBillingAgreementUsageDataProvider
  */
 public function testExecute($methodInstance, $isAllowed, $isAvailable)
 {
     $this->_event->setMethodInstance($methodInstance);
     $this->_authorization->expects($this->any())->method('isAllowed')->with('Magento_Paypal::use')->will($this->returnValue($isAllowed));
     $result = new \stdClass();
     $result->isAvailable = true;
     $this->_event->setResult($result);
     $this->_model->execute($this->_observer);
     $this->assertEquals($isAvailable, $result->isAvailable);
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:16,代码来源:RestrictAdminBillingAgreementUsageTest.php

示例14: 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;
 }
开发者ID:magefan,项目名称:module-login-as-customer,代码行数:16,代码来源:Actions.php

示例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);
             }
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Acl.php


注:本文中的Magento\Framework\AuthorizationInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。