TopDestinationCountries.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Directory\Model;
  7. use Magento\Store\Model\ScopeInterface;
  8. use Magento\Framework\App\Config\ScopeConfigInterface;
  9. /**
  10. * Class TopDestinationCountries
  11. */
  12. class TopDestinationCountries
  13. {
  14. const CONFIG_DESTINATIONS_PATH = 'general/country/destinations';
  15. /**
  16. * @var ScopeConfigInterface
  17. */
  18. private $scopeConfig;
  19. /**
  20. * @param ScopeConfigInterface $scopeConfig
  21. */
  22. public function __construct(ScopeConfigInterface $scopeConfig)
  23. {
  24. $this->scopeConfig = $scopeConfig;
  25. }
  26. /**
  27. * Retrieve list of top destinations countries
  28. *
  29. * @return array
  30. */
  31. public function getTopDestinations()
  32. {
  33. $destinations = (string)$this->scopeConfig->getValue(
  34. self::CONFIG_DESTINATIONS_PATH,
  35. ScopeInterface::SCOPE_STORE
  36. );
  37. return !empty($destinations) ? explode(',', $destinations) : [];
  38. }
  39. }