Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Add migration for removed Workspace methods #134

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion config/set/contentrepository-90.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
\Neos\ContentRepository\Domain\Model\NodeType::class => \Neos\ContentRepository\Core\NodeType\NodeType::class,
\Neos\ContentRepository\Domain\Service\NodeTypeManager::class => \Neos\ContentRepository\Core\NodeType\NodeTypeManager::class,

\Neos\ContentRepository\Domain\Model\Workspace::class => \Neos\ContentRepository\Core\Projection\Workspace\Workspace::class,
\Neos\ContentRepository\Domain\Model\Workspace::class => \Neos\ContentRepository\Core\SharedModel\Workspace\Workspace::class,
\Neos\ContentRepository\Domain\NodeAggregate\NodeAggregateIdentifier::class => \Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId::class,
\Neos\ContentRepository\Domain\NodeAggregate\NodeName::class => \Neos\ContentRepository\Core\SharedModel\Node\NodeName::class,
\Neos\ContentRepository\Domain\NodeType\NodeTypeName::class => \Neos\ContentRepository\Core\NodeType\NodeTypeName::class,
Expand Down Expand Up @@ -695,6 +695,42 @@
*/
$rectorConfig->rule(FusionFlowQueryContextRector::class);

/**
* \Neos\ContentRepository\Domain\Model\Workspace
*/
// getBaseWorkspace(): Workspace|null
//->baseworkspaceName
// getBaseWorkspaces(): Workspace[]
// ->
// getDescription(): null|string
// workspaceService->getWorkspaceMetadata->description->value
// getName(): string
// ->name
// getNodeCount(): int
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\Workspace::class, 'getNodeCount', '!! Workspace::getNodeCount() has been removed in Neos 9.0 without a replacement.');
// getOwner(): UserInterface|null
// getRootNodeData(): NodeData
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\Workspace::class, 'getRootNodeData', '!! Workspace::getRootNodeData() has been removed in Neos 9.0 without a replacement.');
// getTitle(): string
// meta->setWorkspaceTitle
// isInternalWorkspace(): bool
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\Workspace::class, 'isInternalWorkspace', '!! Workspace::isInternalWorkspace() has been removed in Neos 9.0. Please use the new Workspace permission api instead. See ContentRepositoryAuthorizationService::getWorkspacePermissions()');
// isPersonalWorkspace(): bool
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\Workspace::class, 'isPersonalWorkspace', '!! Workspace::isPersonalWorkspace() has been removed in Neos 9.0. Please use the new Workspace permission api instead. See ContentRepositoryAuthorizationService::getWorkspacePermissions()');
// isPrivateWorkspace(): bool
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\Workspace::class, 'isPrivateWorkspace', '!! Workspace::isPrivateWorkspace() has been removed in Neos 9.0. Please use the new Workspace permission api instead. See ContentRepositoryAuthorizationService::getWorkspacePermissions()');
// isPublicWorkspace(): bool
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\Workspace::class, 'isPublicWorkspace', '!! Workspace::isPublicWorkspace() has been removed in Neos 9.0. Please use the new Workspace permission api instead. See ContentRepositoryAuthorizationService::getWorkspacePermissions()');
// publish(targetWorkspace: Workspace): void
// publishNode(nodeToPublish: NodeInterface, targetWorkspace: Workspace): void
// publishNodes(nodes: NodeInterface[], targetWorkspace: Workspace): void
// setBaseWorkspace(baseWorkspace: Workspace): void
// setDescription(description: string): void
// workspaceService->setWorkspaceDescription
// setOwner(user: UserInterface|null|string): void
// setTitle(title: string): void
// workspaceService->setWorkspaceTitle

/**
* SPECIAL rules
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class Package extends BasePackage
// TODO 9.0 migration: The signal "baseWorkspaceChanged" on "Workspace" has been removed. Please check https://docs.neos.io/api/upgrade-instructions/9/signals-and-slots for further information, how to replace a signal.


$dispatcher->connect(\Neos\ContentRepository\Core\Projection\Workspace\Workspace::class, 'baseWorkspaceChanged', function () { return 'foo'; });
$dispatcher->connect(\Neos\ContentRepository\Core\SharedModel\Workspace\Workspace::class, 'baseWorkspaceChanged', function () { return 'foo'; });
// TODO 9.0 migration: The signal "beforeNodePublishing" on "Workspace" has been removed. Please check https://docs.neos.io/api/upgrade-instructions/9/signals-and-slots for further information, how to replace a signal.

$dispatcher->connect('Neos\ContentRepository\Domain\Model\Workspace', 'beforeNodePublishing', RouterCachingService::class, 'flushCaches');
// TODO 9.0 migration: The signal "afterNodePublishing" on "Workspace" has been removed. Please check https://docs.neos.io/api/upgrade-instructions/9/signals-and-slots for further information, how to replace a signal.

$dispatcher->connect(\Neos\ContentRepository\Core\Projection\Workspace\Workspace::class, 'afterNodePublishing', function () { return 'foo'; });
$dispatcher->connect(\Neos\ContentRepository\Core\SharedModel\Workspace\Workspace::class, 'afterNodePublishing', function () { return 'foo'; });
}
}
127 changes: 127 additions & 0 deletions tests/Sets/ContentRepository90/Fixture/workspace.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php

namespace Neos\Rector\Test;

use Neos\Flow\Annotations as Flow;
use Neos\ContentRepository\Domain\Model\Workspace;

class SomeClass extends AnotherClass
{

public function test(Workspace $workspace)
{
$baseWorkspace = $workspace->getBaseWorkspace();

$baseWorkspaces = $workspace->getBaseWorkspaces();

$title = $workspace->getTitle();

$description = $workspace->getDescription();

$name = $workspace->getName();

$workspace->getNodeCount();

$workspace->getOwner();

$workspace->getRootNodeData();

$workspace->isInternalWorkspace();

$workspace->isPersonalWorkspace();

$workspace->isPrivateWorkspace();

$workspace->isPublicWorkspace();

$workspace->publish($targetWorkspace);

$workspace->publishNode($node, $targetWorkspace);

$workspace->publishNodes([$node], $targetWorkspace);

$workspace->setBaseWorkspace($baseWorkspace);

$workspace->setOwner($user);

$workspace->setDescription("description");

$workspace->setTitle("title");
}
}
-----


namespace Neos\Rector\Test;

use Neos\Flow\Annotations as Flow;

class SomeClass extends AnotherClass
{
#[Flow\Inject]
protected \Neos\Neos\Domain\Service\WorkspaceService $workspaceService;
#[Flow\Inject]
protected \Neos\ContentRepositoryRegistry\ContentRepositoryRegistry $contentRepositoryRegistry;
#[Flow\Inject]
protected \Neos\Neos\Domain\Service\WorkspacePublishingService $workspacePublishingService;

public function test(\Neos\ContentRepository\Core\SharedModel\Workspace\Workspace $workspace)
{

$contentRepository = $this->contentRepositoryRegistry->get(\Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId::fromString('default'));
$baseWorkspace = $contentRepository->findWorkspaceByName($workspace->baseWorkspaceName);

$contentRepository = $this->contentRepositoryRegistry->get(\Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId::fromString('default'));
$baseWorkspaces = $contentRepository->findWorkspaces()->getBaseWorkspaces($workspace->baseWorkspaceName);

$title = $this->workspaceService->getWorkspaceMetadata(\Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId::fromString('default'), $workspace->workspaceName)->title;

$description = $this->workspaceService->getWorkspaceMetadata(\Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId::fromString('default'), $workspace->workspaceName)->description;
// TODO 9.0 migration: Check if you could change your code to work with the WorkspaceName value object instead.


$name = $workspace->workspaceName->value;
// TODO 9.0 migration: !! Workspace::getNodeCount() has been removed in Neos 9.0 without a replacement.


$workspace->getNodeCount();

$workspace->getOwner();
// TODO 9.0 migration: !! Workspace::getRootNodeData() has been removed in Neos 9.0 without a replacement.


$workspace->getRootNodeData();
// TODO 9.0 migration: !! Workspace::isInternalWorkspace() has been removed in Neos 9.0. Please use the new Workspace permission api instead. See ContentRepositoryAuthorizationService::getWorkspacePermissions()


$workspace->isInternalWorkspace();
// TODO 9.0 migration: !! Workspace::isPersonalWorkspace() has been removed in Neos 9.0. Please use the new Workspace permission api instead. See ContentRepositoryAuthorizationService::getWorkspacePermissions()


$workspace->isPersonalWorkspace();
// TODO 9.0 migration: !! Workspace::isPrivateWorkspace() has been removed in Neos 9.0. Please use the new Workspace permission api instead. See ContentRepositoryAuthorizationService::getWorkspacePermissions()


$workspace->isPrivateWorkspace();
// TODO 9.0 migration: !! Workspace::isPublicWorkspace() has been removed in Neos 9.0. Please use the new Workspace permission api instead. See ContentRepositoryAuthorizationService::getWorkspacePermissions()


$workspace->isPublicWorkspace();

$this->workspacePublishingService->publishWorkspace(\Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId::fromString('default'), $workspace->workspaceName);

// TODO: Check if this matches your requirements as this is not a 100% replacement
$this->workspacePublishingService->publishChangesInDocument(\Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId::fromString('default'), $workspace->workspaceName, $node);

// TODO: Use the \Neos\Neos\Domain\Service\WorkspacePublishingService to publish a workspace or changesin a document.
$workspace->publishNodes([$node], $targetWorkspace);


$workspace->setBaseWorkspace($baseWorkspace);
$workspace->setOwner($user);

$this->workspaceService->setWorkspaceDescription(\Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId::fromString('default'), $workspace->workspaceName, 'description');

$this->workspaceService->setWorkspaceTitle(\Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId::fromString('default'), $workspace->workspaceName, 'title');
}
}
Loading