Skip to content

Commit af7d945

Browse files
committed
Allow core and project keys to be set
1 parent 6587f23 commit af7d945

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/Writer/Drupal.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public function set(array $paths)
3030
/**
3131
* {@inheritdoc}
3232
*/
33-
public function rewrite($version, $timestamp)
33+
public function rewrite($version, $timestamp, $core = null, $project = null)
3434
{
3535
foreach ($this->paths as $info_file) {
3636
// Don't write to files that already contain version information.
3737
if (!$this->hasVersionInfo($info_file)) {
3838
$file = fopen($info_file, 'a+');
39-
fwrite($file, $this->formatInfo($version, $timestamp));
39+
fwrite($file, $this->formatInfo($version, $timestamp, $core, $project));
4040
fclose($file);
4141
}
4242
}
@@ -58,14 +58,20 @@ public function rollback()
5858
/**
5959
* Format version and timestamp into YAML.
6060
*/
61-
protected function formatInfo($version, $timestamp)
61+
protected function formatInfo($version, $timestamp, $core = null, $project = null)
6262
{
6363
$date = gmdate('c', $timestamp);
6464
$info = array();
6565
// Always start with EOL character.
6666
$info[] = '';
6767
$info[] = "# Information added by drupal-composer/info-rewrite on $date.";
6868
$info[] = "version: '$version'";
69+
if ($core) {
70+
$info[] = "core: '$core'";
71+
}
72+
if ($project) {
73+
$info[] = "project: '$project'";
74+
}
6975
$info[] = "datestamp: $timestamp";
7076
// Always end with EOL character.
7177
$info[] = '';

src/Writer/Drupal7.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,20 @@ class Drupal7 extends Drupal
1515
/**
1616
* Format version and timestamp into INI format.
1717
*/
18-
protected function formatInfo($version, $timestamp)
18+
protected function formatInfo($version, $timestamp, $core = null, $project = null)
1919
{
2020
$date = gmdate('c', $timestamp);
2121
$info = array();
2222
// Always start with EOL character.
2323
$info[] = '';
2424
$info[] = "; Information added by drupal-composer/info-rewrite on $date.";
2525
$info[] = "version = \"$version\"";
26+
if ($core) {
27+
$info[] = "core = \"$core\"";
28+
}
29+
if ($project) {
30+
$info[] = "project = \"$project\"";
31+
}
2632
$info[] = "datestamp = \"$timestamp\"";
2733
// Always end with EOL character.
2834
$info[] = '';

src/Writer/WriterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function set(array $paths);
2222
* @param string $timestamp
2323
* @return
2424
*/
25-
public function rewrite($version, $timestamp);
25+
public function rewrite($version, $timestamp, $core = null, $project = null);
2626

2727
/**
2828
* Rollback the info files to their download/unprocessed state.

0 commit comments

Comments
 (0)