public function install(Request $request)
{
$package = $request->get('package');
$version = $request->get('version');
try {
$response = $this->manager()->requirePackage(['name' => $package, 'version' => $version]);
} catch (\Exception $e) {
return $this->getJsonException($e);
}
if ($response === 0) {
$this->app['extensions.stats']->recordInstall($package, $version);
$this->app['logger.system']->info("Installed {$package} {$version}", ['event' => 'extensions']);
return new Response($this->manager()->getOutput());
}
return $this->getJsonException(new PackageManagerException($this->manager()->getOutput(), $response));
}