-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3647 from neos/4622-outOfBandRendering
FEATURE: 4622 - decouple out-of-band rendering from Fusion
- Loading branch information
Showing
6 changed files
with
138 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?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\View; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
|
||
/** | ||
* The interface for views capable of out-of-band rendering by accepting string serialized entry points | ||
*/ | ||
interface OutOfBandRenderingCapable | ||
{ | ||
/** | ||
* Set the rendering entry point, e.g. a Fusion path to use for rendering | ||
*/ | ||
public function setRenderingEntryPoint(string $renderingEntryPoint): void; | ||
|
||
public function render(): string|ResponseInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?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\View; | ||
|
||
use Neos\Neos\View\FusionView; | ||
|
||
/** | ||
* A Fusion view capable of out-of-band rendering | ||
*/ | ||
class OutOfBandRenderingFusionView extends FusionView implements OutOfBandRenderingCapable | ||
{ | ||
public function setRenderingEntryPoint(string $renderingEntryPoint): void | ||
{ | ||
$this->setFusionPath($renderingEntryPoint); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?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\View; | ||
|
||
use Neos\Flow\Mvc\View\AbstractView; | ||
use Neos\Flow\Annotations as Flow; | ||
|
||
class OutOfBandRenderingViewFactory | ||
{ | ||
/** | ||
* @phpstan-var class-string | ||
*/ | ||
#[Flow\InjectConfiguration(path: 'outOfBandRendering.viewObjectName')] | ||
protected string $viewObjectName; | ||
|
||
public function resolveView(): AbstractView&OutOfBandRenderingCapable | ||
{ | ||
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 OutOfBandRenderingCapable) { | ||
throw new \DomainException( | ||
'Declared view (' . $this->viewObjectName . ') does not implement ' . OutOfBandRenderingCapable::class | ||
. ' required for out-of-band rendering', | ||
1697821364 | ||
); | ||
} | ||
|
||
return $view; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters