Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigOptionsListCollector.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Setup\Model;
7 
12 use Zend\ServiceManager\ServiceLocatorInterface;
13 
18 {
24  private $directoryList;
25 
31  private $filesystem;
32 
38  private $fullModuleList;
39 
45  private $objectManagerProvider;
46 
52  private $serviceLocator;
53 
63  public function __construct(
64  DirectoryList $directoryList,
65  Filesystem $filesystem,
66  FullModuleList $fullModuleList,
67  ObjectManagerProvider $objectManagerProvider,
68  ServiceLocatorInterface $serviceLocator
69  ) {
70  $this->directoryList = $directoryList;
71  $this->filesystem = $filesystem;
72  $this->fullModuleList = $fullModuleList;
73  $this->objectManagerProvider = $objectManagerProvider;
74  $this->serviceLocator = $serviceLocator;
75  }
76 
83  public function collectOptionsLists()
84  {
85  $optionsList = [];
86 
87  // go through modules
88  foreach ($this->fullModuleList->getNames() as $moduleName) {
89  $optionsClassName = str_replace('_', '\\', $moduleName) . '\Setup\ConfigOptionsList';
90  if (class_exists($optionsClassName)) {
91  $optionsClass = $this->objectManagerProvider->get()->create($optionsClassName);
92  if ($optionsClass instanceof ConfigOptionsListInterface) {
93  $optionsList[$moduleName] = $optionsClass;
94  }
95  }
96  }
97 
98  // check Setup
99  $setupOptionsClassName = \Magento\Setup\Model\ConfigOptionsList::class;
100  if (class_exists($setupOptionsClassName)) {
101  $setupOptionsClass = $this->serviceLocator->get($setupOptionsClassName);
102  if ($setupOptionsClass instanceof ConfigOptionsListInterface) {
103  $optionsList['setup'] = $setupOptionsClass;
104  }
105  }
106 
107  return $optionsList;
108  }
109 }
__construct(DirectoryList $directoryList, Filesystem $filesystem, FullModuleList $fullModuleList, ObjectManagerProvider $objectManagerProvider, ServiceLocatorInterface $serviceLocator)
$filesystem