Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Config.php
Go to the documentation of this file.
1 <?php
7 
11 class Config
12 {
16  const ORDER_ITEMS = 'lineItemCount';
17  const ORDER_VALUE = 'orderValue';
18  const ORDER_PLACED = 'Order';
19  const ADMIN_USER_ID = 'adminId';
20  const ADMIN_USER = 'adminUser';
21  const ADMIN_NAME = 'adminName';
22  const CUSTOMER_ID = 'customerId';
23  const CUSTOMER_NAME = 'CustomerName';
24  const CUSTOMER_COUNT = 'CustomerCount';
25  const FLUSH_CACHE = 'systemCacheFlush';
26  const STORE = 'store';
27  const STORE_VIEW_COUNT = 'StoreViewCount';
28  const WEBSITE = 'website';
29  const WEBSITE_COUNT = 'WebsiteCount';
30  const PRODUCT_CHANGE = 'adminProductChange';
31  const PRODUCT_COUNT = 'productCatalogSize';
32  const CONFIGURABLE_COUNT = 'productCatalogConfigurableSize';
33  const ACTIVE_COUNT = 'productCatalogActiveSize';
34  const CATEGORY_SIZE = 'productCatalogCategorySize';
35  const CATEGORY_COUNT = 'CatalogCategoryCount';
36  const ENABLED_MODULE_COUNT = 'enabledModuleCount';
37  const MODULES_ENABLED = 'ModulesEnabled';
38  const MODULES_DISABLED = 'ModulesDisabled';
39  const MODULES_INSTALLED = 'ModulesInstalled';
40  const MODULE_INSTALLED = 'moduleInstalled';
41  const MODULE_UNINSTALLED = 'moduleUninstalled';
42  const MODULE_ENABLED = 'moduleEnabled';
43  const MODULE_DISABLED = 'moduleDisabled';
49  const INSTALLED = 'installed';
50  const UNINSTALLED = 'uninstalled';
51  const ENABLED = 'enabled';
52  const DISABLED = 'disabled';
53  const TRUE = 'true';
54  const FALSE = 'false';
58  protected $scopeConfig;
59 
63  protected $encryptor;
64 
68  protected $resourceConfig;
69 
77  public function __construct(
78  \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
79  \Magento\Framework\Encryption\EncryptorInterface $encryptor,
81  ) {
82  $this->scopeConfig = $scopeConfig;
83  $this->encryptor = $encryptor;
84  $this->resourceConfig = $resourceConfig;
85  }
86 
92  public function isNewRelicEnabled()
93  {
94  return (bool)$this->scopeConfig->getValue('newrelicreporting/general/enable');
95  }
96 
102  public function getNewRelicApiUrl()
103  {
104  return (string)$this->scopeConfig->getValue('newrelicreporting/general/api_url');
105  }
106 
112  public function getInsightsApiUrl()
113  {
114  return (string)$this->scopeConfig->getValue('newrelicreporting/general/insights_api_url');
115  }
116 
122  public function getNewRelicAccountId()
123  {
124  return (string)$this->scopeConfig->getValue('newrelicreporting/general/account_id');
125  }
126 
132  public function getNewRelicAppId()
133  {
134  return (int)$this->scopeConfig->getValue('newrelicreporting/general/app_id');
135  }
136 
142  public function getNewRelicApiKey()
143  {
144  return $this->encryptor->decrypt($this->scopeConfig->getValue('newrelicreporting/general/api'));
145  }
146 
152  public function getInsightsInsertKey()
153  {
154  return $this->encryptor->decrypt($this->scopeConfig->getValue('newrelicreporting/general/insights_insert_key'));
155  }
156 
162  public function getNewRelicAppName()
163  {
164  return (string)$this->scopeConfig->getValue('newrelicreporting/general/app_name');
165  }
166 
172  public function isSeparateApps()
173  {
174  return (bool)$this->scopeConfig->getValue('newrelicreporting/general/separate_apps');
175  }
176 
182  public function isCronEnabled()
183  {
184  return (bool)$this->scopeConfig->getValue('newrelicreporting/cron/enable_cron');
185  }
186 
196  protected function setConfigValue($pathId, $value, $scope = 'default', $scopeId = 0)
197  {
198  $this->resourceConfig->saveConfig($pathId, $value, $scope, $scopeId);
199  }
200 
206  public function disableModule()
207  {
208  $this->setConfigValue('newrelicreporting/general/enable', 0);
209  }
210 }
__construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Config\Model\ResourceModel\Config $resourceConfig)
Definition: Config.php:77
$value
Definition: gender.phtml:16
setConfigValue($pathId, $value, $scope='default', $scopeId=0)
Definition: Config.php:196