11<?php
2+ /**
3+ * Copyright © 2015 Magento. All rights reserved.
4+ * See COPYING.txt for license details.
5+ */
26namespace Magento \Setup \Model ;
37
48use Magento \Framework \App \Filesystem \DirectoryList ;
711use Magento \Framework \Module \ModuleList ;
812
913/**
10- * Collects all ConfigOptions throughout modules, framework and setup
14+ * Collects all ConfigOptions class in modules and setup
1115 */
1216class ConfigOptionsCollector
1317{
@@ -53,6 +57,7 @@ class ConfigOptionsCollector
5357 * @param Filesystem $filesystem
5458 * @param FullModuleList $fullModuleList
5559 * @param ModuleList $moduleList
60+ * @param ObjectManagerProvider $objectManagerProvider
5661 */
5762 public function __construct (
5863 DirectoryList $ directoryList ,
@@ -78,7 +83,7 @@ public function collectOptions()
7883 $ optionsList = [];
7984
8085 // go through modules
81- foreach ($ this ->moduleList ->getNames () as $ moduleName ) {
86+ foreach ($ this ->fullModuleList ->getNames () as $ moduleName ) {
8287 $ optionsClassName = str_replace ('_ ' , '\\' , $ moduleName ) . '\Setup\ConfigOptions ' ;
8388 if (class_exists ($ optionsClassName )) {
8489 $ optionsClass = $ this ->objectManagerProvider ->get ()->create ($ optionsClassName );
@@ -91,66 +96,18 @@ public function collectOptions()
9196 }
9297 }
9398
94- // go through framework
95- $ frameworkOptionsFiles = [];
96- $ this ->collectRecursively (
97- $ this ->filesystem ->getDirectoryRead (DirectoryList::LIB_INTERNAL ),
98- 'Magento/Framework ' ,
99- $ frameworkOptionsFiles
100- );
101- foreach ($ frameworkOptionsFiles as $ frameworkOptionsFile ) {
102- // remove .php
103- $ frameworkOptionsFile = substr ($ frameworkOptionsFile , 0 , -4 );
104- $ frameworkOptionsClassName = str_replace ('/ ' , '\\' , $ frameworkOptionsFile );
105- $ optionsClass = $ this ->objectManagerProvider ->get ()->create ($ frameworkOptionsClassName );
106- if ($ optionsClass instanceof \Magento \Framework \Setup \ConfigOptionsInterface) {
107- $ optionsList [$ frameworkOptionsClassName ] = [
108- 'options ' => $ optionsClass ->getOptions (),
109- 'enabled ' => true ,
110- ];
111- }
112- }
113-
114- // go through setup
115- $ setupOptionsFiles = [];
116- $ this ->collectRecursively (
117- $ this ->filesystem ->getDirectoryRead (DirectoryList::ROOT ),
118- 'setup/src ' ,
119- $ setupOptionsFiles
120- );
121- foreach ($ setupOptionsFiles as $ setupOptionsFile ) {
122- // remove setup/src/ and .php
123- $ setupOptionsFile = substr ($ setupOptionsFile , 10 , -4 );
124- $ setupOptionsClassName = str_replace ('/ ' , '\\' , $ setupOptionsFile );
125- $ optionsClass = $ this ->objectManagerProvider ->get ()->create ($ setupOptionsClassName );
126- if ($ optionsClass instanceof \Magento \Framework \Setup \ConfigOptionsInterface) {
99+ // check setup
100+ $ setupOptionsClassName = 'Magento\Setup\Model\ConfigOptions ' ;
101+ if (class_exists ($ setupOptionsClassName )) {
102+ $ setupOptionsClass = $ this ->objectManagerProvider ->get ()->create ($ setupOptionsClassName );
103+ if ($ setupOptionsClass instanceof \Magento \Framework \Setup \ConfigOptionsInterface) {
127104 $ optionsList [$ setupOptionsClassName ] = [
128- 'options ' => $ optionsClass ->getOptions (),
105+ 'options ' => $ setupOptionsClass ->getOptions (),
129106 'enabled ' => true ,
130107 ];
131108 }
132109 }
133110
134111 return $ optionsList ;
135112 }
136-
137- /**
138- * Collects Options files recursively
139- *
140- * @param Filesystem\Directory\ReadInterface $dir
141- * @param string $path
142- * @param array $result
143- */
144- private function collectRecursively (\Magento \Framework \Filesystem \Directory \ReadInterface $ dir , $ path , &$ result )
145- {
146- $ localResult = $ dir ->search ($ path . '/Setup/ConfigOptions.php ' );
147- foreach ($ localResult as $ optionFile ) {
148- $ result [] = $ optionFile ;
149- }
150-
151- // goes deeper if current search is successful or next depth level exists
152- if ($ localResult || $ dir ->search ($ path . '/* ' )) {
153- $ this ->collectRecursively ($ dir , $ path . '/* ' , $ result );
154- }
155- }
156113}
0 commit comments