public function uploadAction($type)
{
$file = App::request()->files->get('file');
if ($file === null || !$file->isValid()) {
App::abort(400, __('No file uploaded.'));
}
$package = $this->loadPackage($file->getPathname());
if (!$package->getName() || !$package->get('title') || !$package->get('version')) {
App::abort(400, __('"composer.json" file not valid.'));
}
if ($package->get('type') !== 'pagekit-' . $type) {
App::abort(400, __('No Pagekit %type%', ['%type%' => $type]));
}
$filename = str_replace('/', '-', $package->getName()) . '-' . $package->get('version') . '.zip';
$file->move(App::get('path') . '/tmp/packages', $filename);
return compact('package');
}