public function importCommand($packageKey = null, $filename = null)
{
$exceedingArguments = $this->request->getExceedingArguments();
if (isset($exceedingArguments[0]) && $packageKey === null && $filename === null) {
if (file_exists($exceedingArguments[0])) {
$filename = $exceedingArguments[0];
} elseif ($this->packageManager->isPackageAvailable($exceedingArguments[0])) {
$packageKey = $exceedingArguments[0];
}
}
if ($packageKey === null && $filename === null) {
$this->outputLine('You have to specify either "--package-key" or "--filename"');
$this->quit(1);
}
$site = null;
if ($filename !== null) {
try {
$site = $this->siteImportService->importFromFile($filename);
} catch (\Exception $exception) {
$this->systemLogger->logException($exception);
$this->outputLine('<error>During the import of the file "%s" an exception occurred: %s, see log for further information.</error>', array($filename, $exception->getMessage()));
$this->quit(1);
}
} else {
try {
$site = $this->siteImportService->importFromPackage($packageKey);
} catch (\Exception $exception) {
$this->systemLogger->logException($exception);
$this->outputLine('<error>During the import of the "Sites.xml" from the package "%s" an exception occurred: %s, see log for further information.</error>', array($packageKey, $exception->getMessage()));
$this->quit(1);
}
}
$this->outputLine('Import of site "%s" finished.', array($site->getName()));
}