Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/9.0' into task/useNeosNeosSiteNo…
Browse files Browse the repository at this point in the history
…deType
  • Loading branch information
mhsdesign committed Oct 10, 2023
2 parents 24bf63f + 01ada83 commit 8faad15
Show file tree
Hide file tree
Showing 59 changed files with 220 additions and 191 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
./flow flow:cache:flush
./flow flow:cache:warmup
./flow doctrine:migrate
./flow user:create --username=admin --password=password --first-name=John --last-name=Doe --roles=Administrator
./flow user:create --username=admin --password=admin --first-name=John --last-name=Doe --roles=Administrator
- run:
name: Start flow server
command: /home/circleci/app/flow server:run --port 8081
Expand Down
14 changes: 7 additions & 7 deletions Classes/ContentRepository/Service/NodeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/**
* @Flow\Scope("singleton")
*/
class NodeService
{
/**
* @Flow\Inject
* @var ContentRepositoryRegistry
*/
protected $contentRepositoryRegistry;
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* Helper method to retrieve the closest document for a node
*/
public function getClosestDocument(Node $node): ?Node
{
if ($node->nodeType->isOfType('Neos.Neos:Document')) {
if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) {
return $node;
}

$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);

while ($node instanceof Node) {
if ($node->nodeType->isOfType('Neos.Neos:Document')) {
if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) {
return $node;
}
$node = $subgraph->findParentNode($node->nodeAggregateId);
Expand Down
14 changes: 7 additions & 7 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@
use Neos\Neos\PendingChangesProjection\ChangeFinder;
use Neos\Neos\Service\UserService;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RemoveNode;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/**
* @Flow\Scope("singleton")
*/
class WorkspaceService
{
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* @Flow\Inject
* @var UserService
Expand All @@ -44,12 +50,6 @@ class WorkspaceService
*/
protected $domainUserService;

/**
* @Flow\Inject
* @var ContentRepositoryRegistry
*/
protected $contentRepositoryRegistry;

/**
* Get all publishable node context paths for a workspace
*
Expand Down Expand Up @@ -207,7 +207,7 @@ private function getClosestDocumentNode(Node $node): ?Node
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);

while ($node instanceof Node) {
if ($node->nodeType->isOfType('Neos.Neos:Document')) {
if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) {
return $node;
}
$node = $subgraph->findParentNode($node->nodeAggregateId);
Expand Down
13 changes: 6 additions & 7 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@
*/

use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Neos\Domain\Model\WorkspaceName as NeosWorkspaceName;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ActionController;
use Neos\Flow\Mvc\View\ViewInterface;
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Flow\ResourceManagement\ResourceManager;
use Neos\Flow\Security\Context;
use Neos\Flow\Session\SessionInterface;
use Neos\Fusion\View\FusionView;
use Neos\Neos\Controller\Backend\MenuHelper;
use Neos\Neos\Domain\Repository\DomainRepository;
use Neos\Neos\Domain\Repository\SiteRepository;
use Neos\Neos\Domain\Service\WorkspaceNameBuilder;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
use Neos\Neos\Service\BackendRedirectionService;
use Neos\Neos\Service\UserService;
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Fusion\View\FusionView;
use Neos\Flow\Mvc\View\ViewInterface;
use Neos\Neos\Ui\Domain\Service\StyleAndJavascriptInclusionService;
use Neos\Neos\Ui\Service\NodeClipboard;

Expand Down Expand Up @@ -148,8 +148,7 @@ public function indexAction(string $node = null)

$currentAccount = $this->securityContext->getAccount();
$workspace = $contentRepository->getWorkspaceFinder()->findOneByName(
NeosWorkspaceName::fromAccountIdentifier($currentAccount->getAccountIdentifier())
->toContentRepositoryWorkspaceName()
WorkspaceNameBuilder::fromAccountIdentifier($currentAccount->getAccountIdentifier())
);
if (is_null($workspace)) {
$this->redirectToUri($this->uriBuilder->uriFor('index', [], 'Login', 'Neos.Neos'));
Expand Down
26 changes: 11 additions & 15 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
* source code.
*/

use Neos\ContentRepository\Core\Feature\WorkspaceModification\Command\ChangeBaseWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspaceModification\Exception\WorkspaceIsNotEmptyException;
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\DiscardIndividualNodesFromWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\PublishIndividualNodesFromWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Dto\NodeIdsToPublishOrDiscard;
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Dto\NodeIdToPublishOrDiscard;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregateCurrentlyDoesNotExist;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Eel\FlowQuery\FlowQuery;
use Neos\Flow\Annotations as Flow;
Expand All @@ -29,7 +32,7 @@
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Flow\Property\PropertyMapper;
use Neos\Flow\Security\Context;
use Neos\Neos\Domain\Model\WorkspaceName as NeosWorkspaceName;
use Neos\Neos\Domain\Service\WorkspaceNameBuilder;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
Expand All @@ -40,6 +43,8 @@
use Neos\Neos\Ui\Domain\Model\Feedback\Messages\Error;
use Neos\Neos\Ui\Domain\Model\Feedback\Messages\Info;
use Neos\Neos\Ui\Domain\Model\Feedback\Messages\Success;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\Redirect;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadDocument;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateWorkspaceInfo;
use Neos\Neos\Ui\Domain\Model\FeedbackCollection;
use Neos\Neos\Ui\Domain\Service\NodeTreeBuilder;
Expand All @@ -50,12 +55,6 @@
use Neos\Neos\Ui\Service\PublishingService;
use Neos\Neos\Ui\TypeConverter\ChangeCollectionConverter;
use Neos\Neos\Utility\NodeUriPathSegmentGenerator;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Core\Feature\WorkspaceModification\Command\ChangeBaseWorkspace;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadDocument;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\Redirect;
use Neos\ContentRepository\Core\Feature\WorkspaceModification\Exception\WorkspaceIsNotEmptyException;

class BackendServiceController extends ActionController
{
Expand Down Expand Up @@ -195,8 +194,7 @@ public function publishAllAction(): void
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);

$currentAccount = $this->securityContext->getAccount();
$workspaceName = NeosWorkspaceName::fromAccountIdentifier($currentAccount->getAccountIdentifier())
->toContentRepositoryWorkspaceName();
$workspaceName = WorkspaceNameBuilder::fromAccountIdentifier($currentAccount->getAccountIdentifier());
$this->publishingService->publishWorkspace($contentRepository, $workspaceName);

$success = new Success();
Expand All @@ -222,8 +220,7 @@ public function publishAction(array $nodeContextPaths, string $targetWorkspaceNa

try {
$currentAccount = $this->securityContext->getAccount();
$workspaceName = NeosWorkspaceName::fromAccountIdentifier($currentAccount->getAccountIdentifier())
->toContentRepositoryWorkspaceName();
$workspaceName = WorkspaceNameBuilder::fromAccountIdentifier($currentAccount->getAccountIdentifier());

$nodeIdentifiersToPublish = [];
foreach ($nodeContextPaths as $contextPath) {
Expand Down Expand Up @@ -282,8 +279,7 @@ public function discardAction(array $nodeContextPaths): void

try {
$currentAccount = $this->securityContext->getAccount();
$workspaceName = NeosWorkspaceName::fromAccountIdentifier($currentAccount->getAccountIdentifier())
->toContentRepositoryWorkspaceName();
$workspaceName = WorkspaceNameBuilder::fromAccountIdentifier($currentAccount->getAccountIdentifier());

$nodeIdentifiersToDiscard = [];
foreach ($nodeContextPaths as $contextPath) {
Expand Down Expand Up @@ -343,9 +339,9 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d
$nodeAddress = $nodeAddressFactory->createFromUriString($documentNode);

$currentAccount = $this->securityContext->getAccount();
$userWorkspaceName = NeosWorkspaceName::fromAccountIdentifier(
$userWorkspaceName = WorkspaceNameBuilder::fromAccountIdentifier(
$currentAccount->getAccountIdentifier()
)->toContentRepositoryWorkspaceName();
);

$command = ChangeBaseWorkspace::create($userWorkspaceName, WorkspaceName::fromString($targetWorkspaceName));
try {
Expand Down
14 changes: 7 additions & 7 deletions Classes/Domain/Model/AbstractChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\NodeCreated;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadDocument;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateWorkspaceInfo;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

abstract class AbstractChange implements ChangeInterface
{
use NodeTypeWithFallbackProvider;

protected ?Node $subject;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* @Flow\Inject
* @var FeedbackCollection
Expand All @@ -42,12 +48,6 @@ abstract class AbstractChange implements ChangeInterface
*/
protected $persistenceManager;

/**
* @Flow\Inject
* @var ContentRepositoryRegistry
*/
protected $contentRepositoryRegistry;

public function setSubject(Node $subject): void
{
$this->subject = $subject;
Expand Down Expand Up @@ -81,7 +81,7 @@ protected function updateWorkspaceInfo(): void
final protected function findClosestDocumentNode(Node $node): ?Node
{
while ($node instanceof Node) {
if ($node->nodeType->isOfType('Neos.Neos:Document')) {
if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) {
return $node;
}
$node = $this->findParentNode($node);
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Model/Changes/AbstractCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ protected function createNode(
if (is_null($nodeTypeName)) {
throw new \RuntimeException('Cannot run createNode without a set node type.', 1645577794);
}
// TODO: the $name=... line should be as expressed below
// $name = $this->getName() ?: $this->nodeService->generateUniqueNodeName($parent->findParentNode());
$nodeName = NodeName::fromString($this->getName() ?: uniqid('node-', false));
$nodeName = $this->getName()
? NodeName::fromString($this->getName())
: null;

$nodeAggregateId = NodeAggregateId::create(); // generate a new NodeAggregateId

Expand Down
24 changes: 12 additions & 12 deletions Classes/Domain/Model/Changes/AbstractStructuralChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\NodeType\NodeType;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
Expand All @@ -25,13 +26,18 @@
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RenderContentOutOfBand;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateNodeInfo;
use Neos\Neos\Ui\Domain\Model\RenderedNodeDomAddress;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/**
* A change that performs structural actions like moving or creating nodes
*/
abstract class AbstractStructuralChange extends AbstractChange
{
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* The node dom address for the parent node of the created node
*/
Expand All @@ -48,12 +54,6 @@ abstract class AbstractStructuralChange extends AbstractChange
*/
protected $nodeService;

/**
* @Flow\Inject
* @var ContentRepositoryRegistry
*/
protected $contentRepositoryRegistry;

protected ?Node $cachedSiblingNode = null;

/**
Expand Down Expand Up @@ -146,14 +146,14 @@ protected function finish(Node $node)

$this->updateWorkspaceInfo();

if ($node->nodeType->isOfType('Neos.Neos:Content')
if ($this->getNodeType($node)->isOfType('Neos.Neos:Content')
&& ($this->getParentDomAddress() || $this->getSiblingDomAddress())) {
// we can ONLY render out of band if:
// 1) the parent of our new (or copied or moved) node is a ContentCollection;
// so we can directly update an element of this content collection

$contentRepository = $this->contentRepositoryRegistry->get($parentNode->subgraphIdentity->contentRepositoryId);
if ($parentNode && $parentNode->nodeType->isOfType('Neos.Neos:ContentCollection') &&
if ($parentNode && $this->getNodeType($parentNode)->isOfType('Neos.Neos:ContentCollection') &&
// 2) the parent DOM address (i.e. the closest RENDERED node in DOM is actually the ContentCollection;
// and no other node in between
$this->getParentDomAddress() &&
Expand Down Expand Up @@ -187,14 +187,14 @@ protected function findChildNodes(Node $node): Nodes
protected function isNodeTypeAllowedAsChildNode(Node $node, NodeType $nodeType): bool
{
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);
if (NodeInfoHelper::isAutoCreated($node, $subgraph)) {
if ($node->classification === NodeAggregateClassification::CLASSIFICATION_TETHERED) {
$parentNode = $subgraph->findParentNode($node->nodeAggregateId);
return !$parentNode || $parentNode->nodeType->allowsGrandchildNodeType(
return !$parentNode || $this->getNodeType($parentNode)->allowsGrandchildNodeType(
$node->nodeName->value,
$nodeType
);
} else {
return $node->nodeType->allowsChildNodeType($nodeType);
return $this->getNodeType($node)->allowsChildNodeType($nodeType);
}
}
}
Loading

0 comments on commit 8faad15

Please sign in to comment.