Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Group.php
Go to the documentation of this file.
1 <?php
7 
11 
13 {
17  protected $_options;
18 
23  protected $_groupManagement;
24 
29  protected $_converter;
30 
34  private $groupSourceLoggedInOnly;
35 
41  public function __construct(
42  GroupManagementInterface $groupManagement,
43  \Magento\Framework\Convert\DataObject $converter,
44  GroupSourceLoggedInOnlyInterface $groupSourceForLoggedInCustomers = null
45  ) {
46  $this->_groupManagement = $groupManagement;
47  $this->_converter = $converter;
48  $this->groupSourceLoggedInOnly = $groupSourceForLoggedInCustomers
49  ?: ObjectManager::getInstance()->get(GroupSourceLoggedInOnlyInterface::class);
50  }
51 
55  public function toOptionArray()
56  {
57  if (!$this->_options) {
58  $this->_options = $this->groupSourceLoggedInOnly->toOptionArray();
59  array_unshift($this->_options, ['value' => '', 'label' => __('-- Please Select --')]);
60  }
61 
62  return $this->_options;
63  }
64 }
__()
Definition: __.php:13
__construct(GroupManagementInterface $groupManagement, \Magento\Framework\Convert\DataObject $converter, GroupSourceLoggedInOnlyInterface $groupSourceForLoggedInCustomers=null)
Definition: Group.php:41