Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AgreementsProvider.php
Go to the documentation of this file.
1 <?php
7 
9 use Magento\CheckoutAgreements\Model\ResourceModel\Agreement\CollectionFactory as AgreementCollectionFactory;
10 
15 {
19  const PATH_ENABLED = 'checkout/options/enable_agreements';
20 
25 
29  protected $scopeConfig;
30 
34  protected $storeManager;
35 
42  public function __construct(
43  AgreementCollectionFactory $agreementCollectionFactory,
46  ) {
47  $this->agreementCollectionFactory = $agreementCollectionFactory;
48  $this->storeManager = $storeManager;
49  $this->scopeConfig = $scopeConfig;
50  }
51 
57  public function getRequiredAgreementIds()
58  {
59  $agreementIds = [];
60  if ($this->scopeConfig->isSetFlag(self::PATH_ENABLED, ScopeInterface::SCOPE_STORE)) {
61  $agreementCollection = $this->agreementCollectionFactory->create();
62  $agreementCollection->addStoreFilter($this->storeManager->getStore()->getId());
63  $agreementCollection->addFieldToFilter('is_active', 1);
64  $agreementCollection->addFieldToFilter('mode', AgreementModeOptions::MODE_MANUAL);
65  $agreementIds = $agreementCollection->getAllIds();
66  }
67  return $agreementIds;
68  }
69 }
__construct(AgreementCollectionFactory $agreementCollectionFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)