Store.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Eav\Model\Entity\Attribute\Source;
  7. /**
  8. * Customer store_id attribute source
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Store extends \Magento\Eav\Model\Entity\Attribute\Source\Table
  14. {
  15. /**
  16. * @var \Magento\Store\Model\ResourceModel\Store\CollectionFactory
  17. */
  18. protected $_storeCollectionFactory;
  19. /**
  20. * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory
  21. * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory
  22. * @param \Magento\Store\Model\ResourceModel\Store\CollectionFactory $storeCollectionFactory
  23. * @codeCoverageIgnore
  24. */
  25. public function __construct(
  26. \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory,
  27. \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory,
  28. \Magento\Store\Model\ResourceModel\Store\CollectionFactory $storeCollectionFactory
  29. ) {
  30. parent::__construct($attrOptionCollectionFactory, $attrOptionFactory);
  31. $this->_storeCollectionFactory = $storeCollectionFactory;
  32. }
  33. /**
  34. * Retrieve Full Option values array
  35. * @inheritdoc
  36. */
  37. public function getAllOptions($withEmpty = true, $defaultValues = false)
  38. {
  39. if ($this->_options === null) {
  40. $this->_options = $this->_storeCollectionFactory->create()->load()->toOptionArray();
  41. }
  42. return $this->_options;
  43. }
  44. }