BulkOperationsConfig.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\InventoryCatalogAdminUi\Model;
  8. use Magento\Framework\App\Config\ScopeConfigInterface;
  9. class BulkOperationsConfig
  10. {
  11. const XML_PATH_ASYNC_ENABLED = 'cataloginventory/bulk_operations/async';
  12. const XML_PATH_BATCH_SIZE = 'cataloginventory/bulk_operations/batch_size';
  13. /**
  14. * @var ScopeConfigInterface
  15. */
  16. private $scopeConfig;
  17. /**
  18. * @param ScopeConfigInterface $scopeConfig
  19. */
  20. public function __construct(ScopeConfigInterface $scopeConfig)
  21. {
  22. $this->scopeConfig = $scopeConfig;
  23. }
  24. /**
  25. * @return bool
  26. */
  27. public function isAsyncEnabled(): bool
  28. {
  29. return (bool) $this->scopeConfig->getValue(self::XML_PATH_ASYNC_ENABLED);
  30. }
  31. /**
  32. * @return int
  33. */
  34. public function getBatchSize(): int
  35. {
  36. return (int) max(1, (int) $this->scopeConfig->getValue(self::XML_PATH_BATCH_SIZE));
  37. }
  38. }