StockConfiguration.php 903 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\CatalogInventory\Model\Source;
  7. use Magento\Framework\Data\ValueSourceInterface;
  8. use Magento\CatalogInventory\Api\StockConfigurationInterface;
  9. /**
  10. * Class StockConfiguration
  11. */
  12. class StockConfiguration implements ValueSourceInterface
  13. {
  14. /**
  15. * @var StockConfigurationInterface
  16. */
  17. protected $stockConfiguration;
  18. /**
  19. * @param StockConfigurationInterface $stockConfiguration
  20. */
  21. public function __construct(StockConfigurationInterface $stockConfiguration)
  22. {
  23. $this->stockConfiguration = $stockConfiguration;
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function getValue($name)
  29. {
  30. $value= $this->stockConfiguration->getDefaultConfigValue($name);
  31. return is_numeric($value) ? (float)$value : $value;
  32. }
  33. }