public function update()
{
/** @var \Bolt\Filesystem\Handler\JsonFile $jsonFile */
$jsonFile = $this->app['filesystem']->get('extensions://composer.json', new JsonFile());
if (!$jsonFile->exists()) {
try {
$this->init('extensions://composer.json');
} catch (IOException $e) {
$this->messages[] = Trans::__('page.extend.error-composer-json-not-readable');
$this->app['extend.writeable'] = false;
$this->app['extend.online'] = false;
return;
}
}
$json = $jsonOrig = $jsonFile->parse();
// Workaround Bolt 2.0 installs with "require": []
if (isset($json['require']) && empty($json['require'])) {
unset($json['require']);
}
$json = $this->setJsonDefaults($json);
// Write out the file, but only if it's actually changed, and if it's writable.
if ($json != $jsonOrig) {
try {
$jsonFile->dump($json);
} catch (IOException $e) {
$this->messages[] = Trans::__('page.extend.error-composer-json-not-writable');
}
}
return $json;
}