@@ -33,18 +33,36 @@ public static function dump(Event $event)
3333 $ configurationData = file_exists ($ config )?$ yaml ->load ($ config ):[];
3434
3535 foreach ($ packages as $ package ) {
36- $ configFile = $ directory .'/vendor/ ' .$ package .'/config.yml ' ;
37- if (is_file ($ configFile )) {
38- $ libraryData = $ yaml ->load ($ configFile );
39- if (!static ::isValid ($ libraryData )) {
40- continue ;
41- }
42- $ configurationData = array_merge_recursive (
43- $ configurationData ,
44- $ libraryData
45- );
36+ $ packageDirectory = $ directory .'/vendor/ ' .$ package ;
37+ if (!is_dir ($ packageDirectory )) {
38+ continue ;
4639 }
40+
41+ $ composerFile = $ packageDirectory .'/composer.json ' ;
42+ if (!is_file ($ composerFile )) {
43+ continue ;
44+ }
45+
46+ if (!static ::isValidPackageType ($ composerFile )) {
47+ continue ;
48+ }
49+
50+ $ configFile = $ packageDirectory .'/config.yml ' ;
51+ if (!is_file ($ configFile )) {
52+ continue ;
53+ }
54+
55+ $ libraryData = $ yaml ->load ($ configFile );
56+ if (!static ::isValidAutoWireData ($ libraryData )) {
57+ continue ;
58+ }
59+
60+ $ configurationData = array_merge_recursive (
61+ $ configurationData ,
62+ $ libraryData
63+ );
4764 }
65+
4866 if ($ configurationData ) {
4967 file_put_contents (
5068 $ directory . '/extend.yml ' ,
@@ -53,7 +71,18 @@ public static function dump(Event $event)
5371 }
5472 }
5573
56- public static function isValid ($ libraryData )
74+ public static function isValidPackageType ($ composerFile )
75+ {
76+ $ composerContent = json_decode (file_get_contents ($ composerFile ), true );
77+ if (!array_key_exists ('type ' , $ composerContent )) {
78+ return false ;
79+ }
80+ $ packageType = $ composerContent ['type ' ];
81+
82+ return $ packageType === 'drupal-console-library ' ;
83+ }
84+
85+ public static function isValidAutoWireData ($ libraryData )
5786 {
5887 if (!array_key_exists ('application ' , $ libraryData )) {
5988 return false ;
0 commit comments