Media.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\ProductVideo\Helper;
  7. use Magento\Framework\App\Helper\Context;
  8. /**
  9. * Helper to get attributes for video
  10. *
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Media extends \Magento\Framework\App\Helper\AbstractHelper
  15. {
  16. /**
  17. * Catalog Module
  18. */
  19. const MODULE_NAME = 'Magento_ProductVideo';
  20. /**
  21. * Configuration path
  22. */
  23. const XML_PATH_YOUTUBE_API_KEY = 'catalog/product_video/youtube_api_key';
  24. /**
  25. * Configuration path for video play
  26. */
  27. const XML_PATH_PLAY_IF_BASE = 'catalog/product_video/play_if_base';
  28. /**
  29. * Configuration path for show related
  30. */
  31. const XML_PATH_SHOW_RELATED = 'catalog/product_video/show_related';
  32. /**
  33. * Configuration path for video auto restart
  34. */
  35. const XML_PATH_VIDEO_AUTO_RESTART = 'catalog/product_video/video_auto_restart';
  36. /**
  37. * Media config node
  38. */
  39. const MEDIA_TYPE_CONFIG_NODE = 'videos';
  40. /**
  41. * @param Context $context
  42. */
  43. public function __construct(
  44. Context $context
  45. ) {
  46. parent::__construct($context);
  47. }
  48. /**
  49. * Get play if base video attribute
  50. *
  51. * @return mixed
  52. */
  53. public function getPlayIfBaseAttribute()
  54. {
  55. return $this->scopeConfig->getValue(self::XML_PATH_PLAY_IF_BASE);
  56. }
  57. /**
  58. * Get show related youtube attribute
  59. *
  60. * @return mixed
  61. */
  62. public function getShowRelatedAttribute()
  63. {
  64. return $this->scopeConfig->getValue(self::XML_PATH_SHOW_RELATED);
  65. }
  66. /**
  67. * Get video auto restart attribute
  68. *
  69. * @return mixed
  70. */
  71. public function getVideoAutoRestartAttribute()
  72. {
  73. return $this->scopeConfig->getValue(self::XML_PATH_VIDEO_AUTO_RESTART);
  74. }
  75. /**
  76. * Retrieve YouTube API key
  77. *
  78. * @return string
  79. */
  80. public function getYouTubeApiKey()
  81. {
  82. return $this->scopeConfig->getValue(self::XML_PATH_YOUTUBE_API_KEY);
  83. }
  84. }