/** * @return Import * * @throws InvalidConfigurationException */ public function buildFromRequest(ImportRequest $importRequest) { $importerId = $importRequest->getImporterId(); $storageSelection = null; $sourceStorage = null; if ($importRequest->hasSource()) { $storageSelection = $this->storageLocator->selectStorage($importRequest->getSourceProviderId(), $importRequest->getSourceId()); $sourceStorage = $this->storageLocator->getStorage($storageSelection); if (!$importRequest->hasImporterId()) { $importerId = $this->findImporterForStorage($sourceStorage); if (!$importerId) { throw new InvalidConfigurationException('No importerId was given and there is no importer that matches the storage.'); } $importRequest->setImporterId($importerId); $this->eventDispatcher->dispatch(ImportRequestEvent::DISCOVERED, new ImportRequestEvent($importRequest)); } } $importConfiguration = new ImportConfiguration($storageSelection, $importerId); return $this->build($importConfiguration, $sourceStorage, $importRequest->getCreatedBy(), $importRequest->getContext()); }