Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
WebsiteSource.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
18 {
22  private $websiteRepository;
23 
27  public function __construct(
28  WebsiteRepositoryInterface $websiteRepository
29  ) {
30  $this->websiteRepository = $websiteRepository;
31  }
32 
36  public function toOptionArray(): array
37  {
38  $websites = [];
39  foreach ($this->websiteRepository->getList() as $website) {
40  if ($website->getCode() === WebsiteInterface::ADMIN_CODE) {
41  continue;
42  }
43  $websites[] = [
44  'value' => $website->getCode(),
45  'label' => $website->getName(),
46  ];
47  }
48  return $websites;
49  }
50 }
__construct(WebsiteRepositoryInterface $websiteRepository)