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

DRAFT: Neos9 compatibility #18

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
191 changes: 0 additions & 191 deletions Classes/Command/NodeRepairCommand.php

This file was deleted.

Expand Up @@ -13,7 +13,7 @@
* source code.
*/

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cache\CacheManager;
use Neos\Flow\I18n\Translator;
Expand Down Expand Up @@ -143,8 +143,8 @@ public function invokeCommand(string $argument, CommandContext $commandContext):

protected function getUriForNode(
ControllerContext $controllerContext,
NodeInterface $node,
NodeInterface $baseNode
Node $node,
Node $baseNode
): string {
try {
return $this->linkingService->createNodeUri(
Expand Down
19 changes: 11 additions & 8 deletions Classes/Controller/TerminalCommandController.php
Expand Up @@ -13,7 +13,7 @@
* source code.
*/

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\I18n\Exception\IndexOutOfBoundsException;
use Neos\Flow\I18n\Exception\InvalidFormatPlaceholderException;
Expand Down Expand Up @@ -79,17 +79,20 @@ class TerminalCommandController extends ActionController

public function getCommandsAction(): void
{
if (!$this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess')) {
/* TODO re-establish privilege checks when supported by NEOS 9*/
/*if (!$this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess')) {
$this->view->assign('value', ['success' => false, 'result' => []]);
return;
}
}*/

$commandNames = $this->terminalCommandService->getCommandNames();

$availableCommandNames = array_filter($commandNames, function ($commandName) {
/* TODO re-establish privilege checks when supported by NEOS 9*/
$availableCommandNames = $commandNames;
/*$availableCommandNames = array_filter($commandNames, function ($commandName) {
return $this->privilegeManager->isGranted(TerminalCommandPrivilege::class,
new TerminalCommandPrivilegeSubject($commandName));
});
});*/

$commandDefinitions = array_reduce($availableCommandNames, function (array $carry, string $commandName) {
$command = $this->terminalCommandService->getCommand($commandName);
Expand All @@ -107,9 +110,9 @@ public function getCommandsAction(): void
public function invokeCommandAction(
string $commandName,
string $argument = null,
NodeInterface $siteNode = null,
NodeInterface $documentNode = null,
NodeInterface $focusedNode = null
Node $siteNode = null,
Node $documentNode = null,
Node $focusedNode = null
): void {
$this->response->setContentType('application/json');

Expand Down
20 changes: 10 additions & 10 deletions Classes/Domain/CommandContext.php
Expand Up @@ -3,7 +3,7 @@

namespace Shel\Neos\Terminal\Domain;

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Mvc\Controller\ControllerContext;

/**
Expand All @@ -25,17 +25,17 @@ class CommandContext
protected $controllerContext;

/**
* @var NodeInterface
* @var Node
*/
protected $siteNode;

/**
* @var NodeInterface
* @var Node
*/
protected $documentNode;

/**
* @var NodeInterface
* @var Node
*/
protected $focusedNode;

Expand All @@ -49,36 +49,36 @@ public function getControllerContext(): ControllerContext
return $this->controllerContext;
}

public function getSiteNode(): ?NodeInterface
public function getSiteNode(): ?Node
{
return $this->siteNode;
}

public function withSiteNode(NodeInterface $siteNode = null): CommandContext
public function withSiteNode(Node $siteNode = null): CommandContext
{
$instance = clone $this;
$instance->siteNode = $siteNode;
return $instance;
}

public function getDocumentNode(): ?NodeInterface
public function getDocumentNode(): ?Node
{
return $this->documentNode;
}

public function withDocumentNode(NodeInterface $documentNode = null): CommandContext
public function withDocumentNode(Node $documentNode = null): CommandContext
{
$instance = clone $this;
$instance->documentNode = $documentNode;
return $instance;
}

public function getFocusedNode(): ?NodeInterface
public function getFocusedNode(): ?Node
{
return $this->focusedNode;
}

public function withFocusedNode(NodeInterface $focusedNode = null): CommandContext
public function withFocusedNode(Node $focusedNode = null): CommandContext
{
$instance = clone $this;
$instance->focusedNode = $focusedNode;
Expand Down
20 changes: 10 additions & 10 deletions Classes/Service/SerializationService.php
Expand Up @@ -13,7 +13,7 @@
* source code.
*/

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;

class SerializationService
{
Expand All @@ -27,13 +27,13 @@ public static function serialize($result): string
{
if (is_array($result)) {
$result = array_map(static function ($item) {
if ($item instanceof NodeInterface) {
if ($item instanceof Node) {
return self::serializeNode($item);
}
return $item;
}, $result);
}
if ($result instanceof NodeInterface) {
if ($result instanceof Node) {
$result = self::serializeNode($result);
}
return json_encode($result);
Expand All @@ -43,18 +43,18 @@ public static function serialize($result): string
* Serialises a node into an array with its properties and attributes
* to improve readability in the terminal output
*/
public static function serializeNode(NodeInterface $node): array
public static function serializeNode(Node $node): array
{
$result = [
'_identifier' => $node->getIdentifier(),
'_nodeType' => $node->getNodeType()->getName(),
'_name' => $node->getName(),
'_workspace' => $node->getWorkspace()->getName(),
'_path' => $node->getPath(),
'subgraphIdentity' => $node->subgraphIdentity,
'nodeAggregateId' => $node->nodeAggregateId,
'originDimensionSpacePoint' => $node->originDimensionSpacePoint,
'nodeTypeName' => $node->nodeTypeName,
'nodeName' => $node->nodeName,
];

try {
foreach ($node->getProperties()->getIterator() as $key => $property) {
foreach ($node->properties as $key => $property) {
if (is_object($property)) {
$property = get_class($property);
}
Expand Down