CheckoutSummaryConfigProvider.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Checkout\Model\Cart;
  7. use Magento\Checkout\Model\ConfigProviderInterface;
  8. use Magento\Framework\UrlInterface;
  9. use Magento\Framework\App\Config\ScopeConfigInterface;
  10. use Magento\Store\Model\ScopeInterface;
  11. /**
  12. * Class CheckoutSummaryConfigProvider provides configuration for checkout summary block
  13. */
  14. class CheckoutSummaryConfigProvider implements ConfigProviderInterface
  15. {
  16. /**
  17. * @var UrlInterface
  18. */
  19. private $urlBuilder;
  20. /**
  21. * @var ScopeConfigInterface
  22. */
  23. private $scopeConfig;
  24. /**
  25. * @param UrlInterface $urlBuilder
  26. * @param ScopeConfigInterface $scopeConfig
  27. */
  28. public function __construct(
  29. UrlInterface $urlBuilder,
  30. ScopeConfigInterface $scopeConfig
  31. ) {
  32. $this->urlBuilder = $urlBuilder;
  33. $this->scopeConfig = $scopeConfig;
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function getConfig()
  39. {
  40. return [
  41. 'maxCartItemsToDisplay' => $this->getMaxCartItemsToDisplay(),
  42. 'cartUrl' => $this->urlBuilder->getUrl('checkout/cart')
  43. ];
  44. }
  45. /**
  46. * Returns maximum cart items to display
  47. * This setting regulates how many items will be displayed in checkout summary block
  48. *
  49. * @return int
  50. */
  51. private function getMaxCartItemsToDisplay()
  52. {
  53. return (int)$this->scopeConfig->getValue(
  54. 'checkout/options/max_items_display_count',
  55. ScopeInterface::SCOPE_STORE
  56. );
  57. }
  58. }