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: 4622 - decouple out-of-band rendering from Fusion #3647

Merged
merged 5 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/*
* This file is part of the Neos.Neos.Ui 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\Ui\Domain\Model\Feedback\Operations;

use Neos\Flow\Mvc\View\AbstractView;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\View\RenderingEntryPointAware;

class OutOfBandRenderingViewFactory
{
/**
* @phpstan-var class-string
*/
#[Flow\InjectConfiguration(path: 'outOfBandRendering.viewObjectName')]
protected string $viewObjectName;

public function resolveView(): AbstractView&RenderingEntryPointAware
{
if (!class_exists($this->viewObjectName)) {
throw new \DomainException(
'Declared view for out of band rendering (' . $this->viewObjectName . ') does not exist',
1697821296
);
}
$view = new $this->viewObjectName();
if (!$view instanceof AbstractView) {
throw new \DomainException(
'Declared view (' . $this->viewObjectName . ') does not implement ' . AbstractView::class
. ' required for out-of-band rendering',
1697821429
);
}
if (!$view instanceof RenderingEntryPointAware) {
throw new \DomainException(
'Declared view (' . $this->viewObjectName . ') does not implement ' . RenderingEntryPointAware::class
. ' required for out-of-band rendering',
1697821364
);
}

return $view;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
use Neos\Neos\Ui\Domain\Model\FeedbackInterface;
use Neos\Neos\Ui\Domain\Model\RenderedNodeDomAddress;
use Neos\Neos\View\FusionView;
use Psr\Http\Message\ResponseInterface;

class ReloadContentOutOfBand extends AbstractFeedback
Expand Down Expand Up @@ -53,6 +52,9 @@ class ReloadContentOutOfBand extends AbstractFeedback
#[Flow\Inject]
protected RenderingModeService $renderingModeService;

#[Flow\Inject]
protected OutOfBandRenderingViewFactory $outOfBandRenderingViewFactory;

public function setNode(Node $node): void
{
$this->node = $node;
Expand Down Expand Up @@ -137,14 +139,14 @@ protected function renderContent(ControllerContext $controllerContext): string|R
if ($this->nodeDomAddress) {
$renderingMode = $this->renderingModeService->findByCurrentUser();

$fusionView = new FusionView();
$fusionView->setControllerContext($controllerContext);
$fusionView->setOption('renderingModeName', $renderingMode->name);
$view = $this->outOfBandRenderingViewFactory->resolveView();
$view->setControllerContext($controllerContext);
$view->setOption('renderingModeName', $renderingMode->name);

$fusionView->assign('value', $this->node);
$fusionView->setFusionPath($this->nodeDomAddress->getFusionPathForContentRendering());
$view->assign('value', $this->node);
$view->setRenderingEntryPoint($this->nodeDomAddress->getFusionPathForContentRendering());

return $fusionView->render();
return $view->render();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
namespace Neos\Neos\Ui\Domain\Model\Feedback\Operations;

/*
* This file is part of the Neos.Neos.Ui package.
Expand All @@ -11,6 +10,10 @@
* source code.
*/

declare(strict_types=1);

namespace Neos\Neos\Ui\Domain\Model\Feedback\Operations;

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Neos\Domain\Service\RenderingModeService;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
Expand All @@ -23,7 +26,6 @@
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
use Neos\Neos\Ui\Domain\Model\FeedbackInterface;
use Neos\Neos\Ui\Domain\Model\RenderedNodeDomAddress;
use Neos\Neos\View\FusionView;
use Psr\Http\Message\ResponseInterface;

class RenderContentOutOfBand extends AbstractFeedback
Expand Down Expand Up @@ -63,6 +65,9 @@ class RenderContentOutOfBand extends AbstractFeedback
#[Flow\Inject]
protected RenderingModeService $renderingModeService;

#[Flow\Inject]
protected OutOfBandRenderingViewFactory $outOfBandRenderingViewFactory;

public function setNode(Node $node): void
{
$this->node = $node;
Expand Down Expand Up @@ -183,14 +188,14 @@ protected function renderContent(ControllerContext $controllerContext): string|R
if ($parentDomAddress) {
$renderingMode = $this->renderingModeService->findByCurrentUser();

$fusionView = new FusionView();
$fusionView->setControllerContext($controllerContext);
$fusionView->setOption('renderingModeName', $renderingMode->name);
$view = $this->outOfBandRenderingViewFactory->resolveView();
$view->setControllerContext($controllerContext);
$view->setOption('renderingModeName', $renderingMode->name);

$fusionView->assign('value', $parentNode);
$fusionView->setFusionPath($parentDomAddress->getFusionPath());
$view->assign('value', $parentNode);
$view->setRenderingEntryPoint($parentDomAddress->getFusionPath());

return $fusionView->render();
return $view->render();
}
}

Expand Down
2 changes: 2 additions & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ Neos:
'Neos.Neos.Ui:MoveBefore': Neos\Neos\Ui\Domain\Model\Changes\MoveBefore
'Neos.Neos.Ui:MoveAfter': Neos\Neos\Ui\Domain\Model\Changes\MoveAfter
'Neos.Neos.Ui:MoveInto': Neos\Neos\Ui\Domain\Model\Changes\MoveInto
outOfBandRendering:
viewObjectName: 'Neos\Neos\View\FusionView'
Flow:
security:
authentication:
Expand Down
Loading