Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Options.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
18  private $bulkCollectionFactory;
19 
23  private $userContext;
24 
30  public function __construct(
31  \Magento\AsynchronousOperations\Model\ResourceModel\Bulk\CollectionFactory $bulkCollection,
32  \Magento\Authorization\Model\UserContextInterface $userContext
33  ) {
34  $this->bulkCollectionFactory = $bulkCollection;
35  $this->userContext = $userContext;
36  }
37 
41  public function toOptionArray()
42  {
44  $collection = $this->bulkCollectionFactory->create();
45 
47  $select = $collection->getSelect();
48  $select->reset();
49  $select->distinct(true);
50  $select->from($collection->getMainTable(), ['description']);
51  $select->where('user_id = ?', $this->userContext->getUserId());
52 
53  $options = [];
54 
56  foreach ($collection->getItems() as $item) {
57  $options[] = [
58  'value' => $item->getDescription(),
59  'label' => $item->getDescription()
60  ];
61  }
62  return $options;
63  }
64 }
__construct(\Magento\AsynchronousOperations\Model\ResourceModel\Bulk\CollectionFactory $bulkCollection, \Magento\Authorization\Model\UserContextInterface $userContext)
Definition: Options.php:30