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 
9 
15 class Group extends \Magento\Eav\Model\Entity\Attribute\Source\Table implements GroupSourceLoggedInOnlyInterface
16 {
20  protected $_groupManagement;
21 
25  protected $_converter;
26 
33  public function __construct(
34  \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory,
35  \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory,
36  GroupManagementInterface $groupManagement,
37  \Magento\Framework\Convert\DataObject $converter
38  ) {
39  $this->_groupManagement = $groupManagement;
40  $this->_converter = $converter;
41  parent::__construct($attrOptionCollectionFactory, $attrOptionFactory);
42  }
43 
47  public function getAllOptions($withEmpty = true, $defaultValues = false)
48  {
49  if (!$this->_options) {
50  $groups = $this->_groupManagement->getLoggedInGroups();
51  $this->_options = $this->_converter->toOptionArray($groups, 'id', 'code');
52  }
53 
54  return $this->_options;
55  }
56 }
__construct(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory, \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory, GroupManagementInterface $groupManagement, \Magento\Framework\Convert\DataObject $converter)
Definition: Group.php:33
getAllOptions($withEmpty=true, $defaultValues=false)
Definition: Group.php:47