Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Website.php
Go to the documentation of this file.
1 <?php
7 
13 class Website extends \Magento\Eav\Model\Entity\Attribute\Source\Table
14 {
18  protected $_store;
19 
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\System\Store $store
29  ) {
30  parent::__construct($attrOptionCollectionFactory, $attrOptionFactory);
31  $this->_store = $store;
32  }
33 
37  public function getAllOptions($withEmpty = true, $defaultValues = false)
38  {
39  if (!$this->_options) {
40  $this->_options = $this->_store->getWebsiteValuesForForm();
41  }
42 
43  return $this->_options;
44  }
45 
50  public function getOptionText($value)
51  {
52  if (!$this->_options) {
53  $this->_options = $this->getAllOptions();
54  }
55  foreach ($this->_options as $option) {
56  if ($option['value'] == $value) {
57  return $option['label'];
58  }
59  }
60  return false;
61  }
62 }
getAllOptions($withEmpty=true, $defaultValues=false)
Definition: Website.php:37
$value
Definition: gender.phtml:16
__construct(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory, \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory, \Magento\Store\Model\System\Store $store)
Definition: Website.php:25