forked from neos/neos-development-collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLiveWorkspaceCreationProcessor.php
54 lines (48 loc) · 1.82 KB
/
LiveWorkspaceCreationProcessor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/*
* This file is part of the Neos.Neos package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
declare(strict_types=1);
namespace Neos\Neos\Domain\Import;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Export\ProcessingContext;
use Neos\ContentRepository\Export\ProcessorInterface;
use Neos\ContentRepository\Export\Severity;
use Neos\Neos\Domain\Model\WorkspaceDescription;
use Neos\Neos\Domain\Model\WorkspaceRoleAssignments;
use Neos\Neos\Domain\Model\WorkspaceTitle;
use Neos\Neos\Domain\Service\WorkspaceService;
/**
* Import processor that creates the "live" workspace if it doesn't exist
*/
final readonly class LiveWorkspaceCreationProcessor implements ProcessorInterface
{
public function __construct(
private ContentRepository $contentRepository,
private WorkspaceService $workspaceService,
) {
}
public function run(ProcessingContext $context): void
{
$context->dispatch(Severity::NOTICE, 'Creating live workspace');
$liveWorkspace = $this->contentRepository->findWorkspaceByName(WorkspaceName::forLive());
if ($liveWorkspace !== null) {
$context->dispatch(Severity::NOTICE, 'Workspace already exists, skipping');
return;
}
$this->workspaceService->createRootWorkspace(
$this->contentRepository->id,
WorkspaceName::forLive(),
WorkspaceTitle::fromString('Public live workspace'),
WorkspaceDescription::createEmpty(),
WorkspaceRoleAssignments::createForLiveWorkspace()
);
}
}