|
16 | 16 |
|
17 | 17 | use Neos\ContentRepository\Core\Feature\NodeRenaming\Command\ChangeNodeAggregateName;
|
18 | 18 | use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
|
19 |
| -use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace; |
20 | 19 | use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
|
21 | 20 | use Neos\ContentRepository\Core\SharedModel\Exception\NodeNameIsAlreadyCovered;
|
22 | 21 | use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;
|
23 | 22 | use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
|
| 23 | +use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace; |
24 | 24 | use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
|
25 | 25 | use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
|
26 | 26 | use Neos\ContentRepositoryRegistry\Exception\ContentRepositoryNotFoundException;
|
27 | 27 | use Neos\Error\Messages\Message;
|
28 | 28 | use Neos\Flow\Annotations as Flow;
|
29 | 29 | use Neos\Flow\Package;
|
30 | 30 | use Neos\Flow\Package\PackageManager;
|
| 31 | +use Neos\Flow\Security\Context as SecurityContext; |
31 | 32 | use Neos\Flow\Session\SessionInterface;
|
32 | 33 | use Neos\Media\Domain\Repository\AssetCollectionRepository;
|
33 | 34 | use Neos\Neos\Controller\Module\AbstractModuleController;
|
|
39 | 40 | use Neos\Neos\Domain\Repository\DomainRepository;
|
40 | 41 | use Neos\Neos\Domain\Repository\SiteRepository;
|
41 | 42 | use Neos\Neos\Domain\Service\NodeTypeNameFactory;
|
| 43 | +use Neos\Neos\Domain\Service\SiteImportService; |
42 | 44 | use Neos\Neos\Domain\Service\SiteService;
|
43 | 45 | use Neos\Neos\Domain\Service\UserService;
|
44 |
| -use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult; |
45 |
| -use Neos\SiteKickstarter\Generator\SitePackageGeneratorInterface; |
46 |
| -use Neos\SiteKickstarter\Service\SiteGeneratorCollectingService; |
47 |
| -use Neos\SiteKickstarter\Service\SitePackageGeneratorNameService; |
| 46 | +use Neos\Utility\Files; |
48 | 47 |
|
49 | 48 | /**
|
50 | 49 | * The Neos Sites Management module controller
|
@@ -97,6 +96,18 @@ class SitesController extends AbstractModuleController
|
97 | 96 | */
|
98 | 97 | protected $defaultContentRepositoryForNewSites;
|
99 | 98 |
|
| 99 | + /** |
| 100 | + * @Flow\Inject |
| 101 | + * @var SecurityContext |
| 102 | + */ |
| 103 | + protected $securityContext; |
| 104 | + |
| 105 | + /** |
| 106 | + * @Flow\Inject |
| 107 | + * @var SiteImportService |
| 108 | + */ |
| 109 | + protected $siteImportService; |
| 110 | + |
100 | 111 | #[Flow\Inject]
|
101 | 112 | protected UserService $domainUserService;
|
102 | 113 |
|
@@ -272,33 +283,35 @@ public function newSiteAction(): void
|
272 | 283 | * @Flow\Validate(argumentName="$packageKey", type="\Neos\Neos\Validation\Validator\PackageKeyValidator")
|
273 | 284 | * @return void
|
274 | 285 | */
|
275 |
| - /*public function importSiteAction($packageKey) |
| 286 | + public function importSiteAction($packageKey) |
276 | 287 | {
|
277 | 288 | try {
|
278 |
| - $this->siteImportService->importFromPackage($packageKey); |
279 |
| - $this->addFlashMessage( |
280 |
| - $this->getModuleLabel('sites.theSiteHasBeenImported.body'), |
281 |
| - '', |
282 |
| - Message::SEVERITY_OK, |
283 |
| - [], |
284 |
| - 1412372266 |
285 |
| - ); |
286 |
| - } catch (\Exception $exception) { |
287 |
| - $logMessage = $this->throwableStorage->logThrowable($exception); |
288 |
| - $this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__)); |
289 |
| - $this->addFlashMessage( |
290 |
| - $this->getModuleLabel( |
291 |
| - 'sites.importError.body', |
292 |
| - [htmlspecialchars($packageKey), htmlspecialchars($exception->getMessage())] |
293 |
| - ), |
294 |
| - $this->getModuleLabel('sites.importError.title'), |
295 |
| - Message::SEVERITY_ERROR, |
296 |
| - [], |
297 |
| - 1412372375 |
298 |
| - ); |
| 289 | + $contentRepositoryId = ContentRepositoryId::fromString($this->defaultContentRepositoryForNewSites ?? ''); |
| 290 | + } catch (\InvalidArgumentException $e) { |
| 291 | + throw new \RuntimeException('The default content repository for new sites configured in "Neos.Neos.sitePresets.default.contentRepository" is not valid.', 1736946907, $e); |
299 | 292 | }
|
300 |
| - $this->unsetLastVisitedNodeAndRedirect('index'); |
301 |
| - }*/ |
| 293 | + |
| 294 | + $package = $this->packageManager->getPackage($packageKey); |
| 295 | + $path = Files::concatenatePaths([$package->getPackagePath(), 'Resources/Private/Content']); |
| 296 | + |
| 297 | + // CreateRootWorkspace was denied: Creation of root workspaces is currently only allowed with disabled authorization checks |
| 298 | + $this->securityContext->withoutAuthorizationChecks(fn () => $this->siteImportService->importFromPath( |
| 299 | + $contentRepositoryId, |
| 300 | + $path, |
| 301 | + fn () => null, |
| 302 | + fn () => null |
| 303 | + )); |
| 304 | + |
| 305 | + $this->addFlashMessage( |
| 306 | + $this->getModuleLabel('sites.theSiteHasBeenImported.body'), |
| 307 | + '', |
| 308 | + Message::SEVERITY_OK, |
| 309 | + [], |
| 310 | + 1412372266 |
| 311 | + ); |
| 312 | + |
| 313 | + $this->redirect('index'); |
| 314 | + } |
302 | 315 |
|
303 | 316 | /**
|
304 | 317 | * Create a new empty site.
|
|
0 commit comments