Data.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Google Optimizer Data Helper
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\GoogleOptimizer\Helper;
  9. use \Magento\Store\Model\ScopeInterface;
  10. /**
  11. * Class Data
  12. *
  13. * @api
  14. * @since 100.0.2
  15. */
  16. class Data extends \Magento\Framework\App\Helper\AbstractHelper
  17. {
  18. /**
  19. * Xml path google experiments enabled
  20. */
  21. const XML_PATH_ENABLED = 'google/analytics/experiments';
  22. /**
  23. * @var bool
  24. */
  25. protected $_activeForCmsFlag;
  26. /**
  27. * @var \Magento\GoogleAnalytics\Helper\Data
  28. */
  29. protected $_analyticsHelper;
  30. /**
  31. * Data constructor.
  32. *
  33. * @param \Magento\Framework\App\Helper\Context $context
  34. * @param \Magento\GoogleAnalytics\Helper\Data $analyticsHelper
  35. */
  36. public function __construct(
  37. \Magento\Framework\App\Helper\Context $context,
  38. \Magento\GoogleAnalytics\Helper\Data $analyticsHelper
  39. ) {
  40. $this->_analyticsHelper = $analyticsHelper;
  41. parent::__construct($context);
  42. }
  43. /**
  44. * Checks if Google Experiment is enabled
  45. *
  46. * @param string $store
  47. * @return bool
  48. */
  49. public function isGoogleExperimentEnabled($store = null)
  50. {
  51. return $this->scopeConfig->isSetFlag(self::XML_PATH_ENABLED, ScopeInterface::SCOPE_STORE, $store);
  52. }
  53. /**
  54. * Checks if Google Experiment is active
  55. *
  56. * @param string $store
  57. * @return bool
  58. */
  59. public function isGoogleExperimentActive($store = null)
  60. {
  61. return $this->isGoogleExperimentEnabled($store) && $this->_analyticsHelper->isGoogleAnalyticsAvailable($store);
  62. }
  63. }