Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/9.0' into feature/4726-extract-w…
Browse files Browse the repository at this point in the history
…orkspace-metadata-and-user-assignment-to-neos
  • Loading branch information
mhsdesign committed Sep 17, 2024
2 parents 9788dce + 93bd781 commit ef54031
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,47 @@

namespace Neos\TestNodeTypes\Application\RemoveAdditionalSettings\Controller;

use GuzzleHttp\Psr7\Response;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\ActionResponse;
use Neos\Flow\Mvc\Controller\ControllerInterface;
use Neos\TestNodeTypes\Application\RemoveAdditionalSettings\RemoveAdditionalSettingsCommand;
use Neos\TestNodeTypes\Application\RemoveAdditionalSettings\RemoveAdditionalSettingsCommandHandler;
use Psr\Http\Message\ResponseInterface;

#[Flow\Scope("singleton")]
final class RemoveAdditionalSettingsController implements ControllerInterface
{
#[Flow\Inject]
protected RemoveAdditionalSettingsCommandHandler $commandHandler;

public function processRequest(ActionRequest $request, ActionResponse $response)
public function processRequest(ActionRequest $request): ResponseInterface
{
$request->setDispatched(true);
$response->setContentType('application/json');

try {
$command = RemoveAdditionalSettingsCommand::fromArray($request->getArguments());
$this->commandHandler->handle($command);

$response->setStatusCode(200);
$response->setContent(
json_encode(
['success' => true],
JSON_THROW_ON_ERROR
)
);
return new Response(status: 200, headers: ['Content-Type' => 'application/json'], body: json_encode(
['success' => true],
JSON_THROW_ON_ERROR
));
} catch (\InvalidArgumentException $e) {
$response->setStatusCode(400);
$response->setContent(
json_encode(
['error' => [
'type' => $e::class,
'code' => $e->getCode(),
'message' => $e->getMessage(),
]],
JSON_THROW_ON_ERROR
)
);
return new Response(status: 400, headers: ['Content-Type' => 'application/json'], body: json_encode(
['error' => [
'type' => $e::class,
'code' => $e->getCode(),
'message' => $e->getMessage(),
]],
JSON_THROW_ON_ERROR
));
} catch (\Exception $e) {
$response->setStatusCode(500);
$response->setContent(
json_encode(
['error' => [
'type' => $e::class,
'code' => $e->getCode(),
'message' => $e->getMessage(),
]],
JSON_THROW_ON_ERROR
)
);
return new Response(status: 500, headers: ['Content-Type' => 'application/json'], body: json_encode(
['error' => [
'type' => $e::class,
'code' => $e->getCode(),
'message' => $e->getMessage(),
]],
JSON_THROW_ON_ERROR
));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,47 @@

namespace Neos\TestNodeTypes\Application\WriteAdditionalSettings\Controller;

use GuzzleHttp\Psr7\Response;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\ActionResponse;
use Neos\Flow\Mvc\Controller\ControllerInterface;
use Neos\TestNodeTypes\Application\WriteAdditionalSettings\WriteAdditionalSettingsCommand;
use Neos\TestNodeTypes\Application\WriteAdditionalSettings\WriteAdditionalSettingsCommandHandler;
use Psr\Http\Message\ResponseInterface;

#[Flow\Scope("singleton")]
final class WriteAdditionalSettingsController implements ControllerInterface
{
#[Flow\Inject]
protected WriteAdditionalSettingsCommandHandler $commandHandler;

public function processRequest(ActionRequest $request, ActionResponse $response)
public function processRequest(ActionRequest $request): ResponseInterface
{
$request->setDispatched(true);
$response->setContentType('application/json');

try {
$command = WriteAdditionalSettingsCommand::fromArray($request->getArguments());
$this->commandHandler->handle($command);

$response->setStatusCode(200);
$response->setContent(
json_encode(
['success' => true],
JSON_THROW_ON_ERROR
)
);
return new Response(status: 200, headers: ['Content-Type' => 'application/json'], body: json_encode(
['success' => true],
JSON_THROW_ON_ERROR
));
} catch (\InvalidArgumentException $e) {
$response->setStatusCode(400);
$response->setContent(
json_encode(
['error' => [
'type' => $e::class,
'code' => $e->getCode(),
'message' => $e->getMessage(),
]],
JSON_THROW_ON_ERROR
)
);
return new Response(status: 400, headers: ['Content-Type' => 'application/json'], body: json_encode(
['error' => [
'type' => $e::class,
'code' => $e->getCode(),
'message' => $e->getMessage(),
]],
JSON_THROW_ON_ERROR
));
} catch (\Exception $e) {
$response->setStatusCode(500);
$response->setContent(
json_encode(
['error' => [
'type' => $e::class,
'code' => $e->getCode(),
'message' => $e->getMessage(),
]],
JSON_THROW_ON_ERROR
)
);
return new Response(status: 500, headers: ['Content-Type' => 'application/json'], body: json_encode(
['error' => [
'type' => $e::class,
'code' => $e->getCode(),
'message' => $e->getMessage(),
]],
JSON_THROW_ON_ERROR
));
}
}
}
7 changes: 0 additions & 7 deletions packages/neos-ui-guest-frame/src/initializeGuestFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ export default ({globalRegistry, store}) => function * initializeGuestFrame() {
return;
}

// Load legacy node data scripts from guest frame - remove with Neos 9.0
const legacyNodeData = guestFrameWindow['@Neos.Neos.Ui:Nodes'] || {};

// Load all nodedata for nodes in the guest frame and filter duplicates
const {q} = yield backend.get();
const nodeContextPathsInGuestFrame = findAllNodesInGuestFrame().map(node => node.getAttribute('data-__neos-node-contextpath'));
Expand All @@ -83,7 +80,6 @@ export default ({globalRegistry, store}) => function * initializeGuestFrame() {

const nodes = Object.assign(
{},
legacyNodeData, // Merge legacy node data from the guest frame - remove with Neos 9.0
fullyLoadedNodesFromContent,
{
[documentInformation.metaData.documentNode]: documentInformation.metaData.documentNodeSerialization
Expand All @@ -93,9 +89,6 @@ export default ({globalRegistry, store}) => function * initializeGuestFrame() {
// Merge new nodes into the store
yield put(actions.CR.Nodes.merge(nodes));

// Remove the legacy inline scripts after initialization - remove with Neos 9.0
Array.prototype.forEach.call(guestFrameWindow.document.querySelectorAll('script[data-neos-nodedata]'), element => element.parentElement.removeChild(element));

const state = store.getState();

// Set the current document node to the one that is rendered in the guest frame which might be different from the one that is currently selected in the page tree
Expand Down

0 comments on commit ef54031

Please sign in to comment.