Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
GetSourceSelectionAlgorithmList.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 use Magento\InventorySourceSelectionApi\Api\Data\SourceSelectionAlgorithmInterfaceFactory;
13 
20 {
24  private $availableAlgorithms;
25 
29  private $sourceSelectionAlgorithmFactory;
30 
36  public function __construct(
37  SourceSelectionAlgorithmInterfaceFactory $sourceSelectionAlgorithmFactory,
38  array $availableAlgorithms = []
39  ) {
40  $this->availableAlgorithms = $availableAlgorithms;
41  $this->sourceSelectionAlgorithmFactory = $sourceSelectionAlgorithmFactory;
42  }
43 
47  public function execute(): array
48  {
49  $algorithmsList = [];
50  foreach ($this->availableAlgorithms as $data) {
51  $algorithmsList[] = $this->sourceSelectionAlgorithmFactory->create([
52  'code' => $data['code'],
53  'title' => $data['title'],
54  'description' => $data['description']
55  ]);
56  }
57 
58  return $algorithmsList;
59  }
60 }
__construct(SourceSelectionAlgorithmInterfaceFactory $sourceSelectionAlgorithmFactory, array $availableAlgorithms=[])