Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
WebsiteSource Class Reference
Inheritance diagram for WebsiteSource:
OptionSourceInterface

Public Member Functions

 __construct (WebsiteRepositoryInterface $websiteRepository)
 
 toOptionArray ()
 

Detailed Description

@api

Definition at line 17 of file WebsiteSource.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( WebsiteRepositoryInterface  $websiteRepository)
Parameters
WebsiteRepositoryInterface$websiteRepository

Definition at line 27 of file WebsiteSource.php.

29  {
30  $this->websiteRepository = $websiteRepository;
31  }

Member Function Documentation

◆ toOptionArray()

toOptionArray ( )

Return array of options as value-label pairs

Returns
array Format: array(array('value' => '

', 'label' => '<label>'), ...)

Implements OptionSourceInterface.

Definition at line 36 of file WebsiteSource.php.

36  : 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  }

The documentation for this class was generated from the following file: