Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RestrictAdminBillingAgreementUsageObserver.php
Go to the documentation of this file.
1 <?php
8 
11 
13 {
17  protected $_authorization;
18 
22  public function __construct(
23  \Magento\Framework\AuthorizationInterface $authorization
24  ) {
25  $this->_authorization = $authorization;
26  }
27 
34  public function execute(EventObserver $observer)
35  {
36  $event = $observer->getEvent();
37  $methodInstance = $event->getMethodInstance();
38  if ($methodInstance instanceof \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement &&
39  false == $this->_authorization->isAllowed(
40  'Magento_Paypal::use'
41  )
42  ) {
44  $result = $observer->getEvent()->getResult();
45  $result->setData('is_available', false);
46  }
47  }
48 }