@@ -120,7 +120,12 @@ public function rollbackRewrite(Event $event)
120120 protected function doWriteInfoFiles (PackageInterface $ package )
121121 {
122122 if ($ writer = $ this ->getWriter ($ package )) {
123- $ writer ->rewrite ($ this ->findVersion ($ package ), $ this ->findTimestamp ($ package ));
123+ $ writer ->rewrite (
124+ $ this ->findVersion ($ package ),
125+ $ this ->findTimestamp ($ package ),
126+ $ this ->findCore ($ package ),
127+ $ this ->findPackage ($ package )
128+ );
124129 } elseif ($ this ->io ->isVerbose ()) {
125130 $ this ->io ->write (
126131 '<info>No info files found for ' .$ package ->getPrettyName () . '</info> '
@@ -195,6 +200,46 @@ protected function findTimestamp(PackageInterface $package)
195200 return time ();
196201 }
197202
203+ /**
204+ * Find the Drupal core version this package is for.
205+ *
206+ * @param PackageInterface $package
207+ *
208+ * @return string|null
209+ * Drupal core version, such as "8.x". NULL if unable to determine.
210+ */
211+ protected function findCore (PackageInterface $ package )
212+ {
213+ // Attempt to determine from getExtra().
214+ $ extra = $ package ->getExtra ();
215+ if (isset ($ extra ['drupal ' ]['core ' ])) {
216+ return $ extra ['drupal ' ]['core ' ];
217+ }
218+
219+ // Attempt to determine from version number.
220+ $ version = $ this ->findVersion ($ package );
221+ if (preg_match ('/^(\d+\.x)-/ ' , $ version , $ backref )) {
222+ return $ backref [1 ];
223+ }
224+ }
225+
226+ /**
227+ * Find the name of the packge.
228+ *
229+ * @param PackageInterface $package
230+ *
231+ * @return string|null
232+ * The package name. NULL if unable to determine.
233+ */
234+ protected function findPackage (PackageInterface $ package )
235+ {
236+ // Attempt to determine from getExtra().
237+ $ extra = $ package ->getExtra ();
238+ if (isset ($ extra ['drupal ' ]['package ' ])) {
239+ return $ extra ['drupal ' ]['package ' ];
240+ }
241+ }
242+
198243 /**
199244 * Determine if this package should be processed.
200245 *
0 commit comments