Data.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Downloadable\Helper;
  7. use Magento\Downloadable\Model\Link;
  8. use Magento\Downloadable\Model\Link\Purchased\Item;
  9. use Magento\Store\Model\ScopeInterface;
  10. /**
  11. * Downloadable helper
  12. *
  13. * @author Magento Core Team <core@magentocommerce.com>
  14. */
  15. class Data extends \Magento\Framework\App\Helper\AbstractHelper
  16. {
  17. /**
  18. * Check is link shareable or not
  19. *
  20. * @param Link|Item $link
  21. * @return bool
  22. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  23. */
  24. public function getIsShareable($link)
  25. {
  26. $shareable = false;
  27. switch ($link->getIsShareable()) {
  28. case Link::LINK_SHAREABLE_YES:
  29. case Link::LINK_SHAREABLE_NO:
  30. $shareable = (bool)$link->getIsShareable();
  31. break;
  32. case Link::LINK_SHAREABLE_CONFIG:
  33. $shareable = $this->scopeConfig->isSetFlag(
  34. Link::XML_PATH_CONFIG_IS_SHAREABLE,
  35. ScopeInterface::SCOPE_STORE
  36. );
  37. }
  38. return $shareable;
  39. }
  40. }