Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Block.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
10 use Magento\Cms\Model\ResourceModel\Block\CollectionFactory;
12 
16 class Block implements OptionSourceInterface
17 {
21  private $options;
22 
26  private $collectionFactory;
27 
31  public function __construct(
32  CollectionFactory $collectionFactory
33  ) {
34  $this->collectionFactory = $collectionFactory;
35  }
36 
40  public function toOptionArray()
41  {
42  if (!$this->options) {
43  $this->options = $this->collectionFactory->create()->toOptionIdArray();
44  }
45 
46  return $this->options;
47  }
48 }
__construct(CollectionFactory $collectionFactory)
Definition: Block.php:31