// Make sure there is an entry in sites.php for the new site.
$fs =
new Filesystem();
if (!
$fs->
exists($root . '/sites/sites.php'
)) { $fs->
copy($root . '/sites/example.sites.php',
$root . '/sites/sites.php'
);
} $parsed =
parse_url($base_url);
$port =
$parsed['port'
] ?? 80;
$host =
$parsed['host'
] ?? 'localhost';
// Remove 'sites/' from the beginning of the path.
$site_path =
substr($this->siteDirectory, 6
);
$fs->
appendToFile($root . '/sites/sites.php', "\$sites['
$port.
$host'] = '
$site_path';"
);
$user_agent =
drupal_generate_test_ua($this->databasePrefix
);
if ($input->
getOption('json'
)) { $output->
writeln(json_encode([ 'db_prefix' =>
$this->databasePrefix,
'user_agent' =>
$user_agent,
'site_path' =>
$this->siteDirectory,
]));
} else { $output->
writeln('<info>Successfully installed a test site</info>'
);