Skip to content

Commit

Permalink
!!!FEATURE: Introduce ApplicationView to replace Fusion for bootstr…
Browse files Browse the repository at this point in the history
…apping the UI

The `ApplicationView` builds the foundational HTML document (via string
concatenation) for bootstrapping the Neos UI.

Formerly, Fusion was used to retrieve and render the initial data for
the UI. This task has been delegated to a set of dedicated classes,
namely:

- `ConfigurationProvider` - retrieves the `nodeTree` and `structureTree`
segments from `Neos.Neos.userInterface.navigateComponent` settings,
`allowedTargetWorkspaces` from the ContentRepository's
`WorkspaceService` as well as the `nodeTypeSchema` and `translations`
endpoints.
- `RoutesProviderInterface` - retrieves all other routes/endpoints
required for communication with the Neos server application
- `FrontendConfigurationProvider` - reads and preprocesses the
`Neos.Neos.Ui.frontendConfiguration` settings that are mostly used by
third-party plugins to share data between server and client
- `NodeTypesProvider` - retrieves information about node type roles and
node type groups. Roles are a dedicated UI-concept that is meant to
distinguish between document, content and collection nodes. Groups refer
the grouping of node types in the creation dialog.
- `MenuProvider` - retrieves all data needed to render the main burger
menu located in the top left corner of the UI.
- `InitialStateProvider` - reads and preprocesses the
`Neos.Neos.Ui.frontendConfiguration` settings that are used to hydrate
the UI's redux store

The responsibilities of these classes is entirely derived from their
former Fusion counterparts. All of them have been marked `@internal` to
allow for later removal. Nonetheless, it remains possible to implement
their accompanying interfaces and replace their implementations via
`Objects.yaml`. This enables rare edge cases and unplanned
extensibility.

The splash screen, formerly a Fluid template, is now hard-coded into the
`ApplicationView` class, which renders the `Neos.Neos.Ui.splashScreen`
setting obsolete. It has therefore been removed.
  • Loading branch information
grebaldi committed Jan 22, 2024
1 parent 2c98f1c commit d288e5f
Show file tree
Hide file tree
Showing 20 changed files with 1,074 additions and 46 deletions.
99 changes: 59 additions & 40 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,13 @@
* source code.
*/

use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
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\NodeTypeNameFactory;
Expand All @@ -32,13 +27,18 @@
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
use Neos\Neos\Service\BackendRedirectionService;
use Neos\Neos\Service\UserService;
use Neos\Neos\Ui\Domain\Service\StyleAndJavascriptInclusionService;
use Neos\Neos\Ui\Service\NodeClipboard;
use Neos\Neos\Ui\Domain\ConfigurationProviderInterface;
use Neos\Neos\Ui\Domain\FrontendConfigurationProviderInterface;
use Neos\Neos\Ui\Domain\InitialStateProviderInterface;
use Neos\Neos\Ui\Domain\MenuProviderInterface;
use Neos\Neos\Ui\Domain\NodeTypesProviderInterface;
use Neos\Neos\Ui\Domain\RoutesProviderInterface;
use Neos\Neos\Ui\Presentation\ApplicationView;

class BackendController extends ActionController
{
/**
* @var FusionView
* @var ApplicationView
*/
protected $view;

Expand Down Expand Up @@ -72,53 +72,59 @@ class BackendController extends ActionController
*/
protected $session;

/**
* @Flow\Inject(lazy=false)
* @var BackendRedirectionService
*/
protected $backendRedirectionService;

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

/**
* @Flow\Inject
* @var MenuHelper
* @var Context
*/
protected $menuHelper;
protected $securityContext;

/**
* @Flow\Inject(lazy=false)
* @var BackendRedirectionService
* @Flow\Inject
* @var ConfigurationProviderInterface
*/
protected $backendRedirectionService;
protected $configurationProvider;

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

/**
* @Flow\Inject
* @var Context
* @var FrontendConfigurationProviderInterface
*/
protected $securityContext;
protected $frontendConfigurationProvider;

/**
* @Flow\Inject
* @var StyleAndJavascriptInclusionService
* @var NodeTypesProviderInterface
*/
protected $styleAndJavascriptInclusionService;
protected $nodeTypesProvider;

/**
* @Flow\Inject
* @var NodeClipboard
* @var MenuProviderInterface
*/
protected $clipboard;
protected $menuProvider;

/**
* @Flow\InjectConfiguration(package="Neos.Neos.Ui", path="splashScreen.partial")
* @var string
* @Flow\Inject
* @var InitialStateProviderInterface
*/
protected $splashScreenPartial;
protected $initialStateProvider;

/**
* Displays the backend interface
Expand Down Expand Up @@ -181,22 +187,35 @@ public function indexAction(string $node = null)
$node = $subgraph->findNodeById($nodeAddress->nodeAggregateId);
}

$this->view->assign('user', $user);
$this->view->assign('documentNode', $node);
$this->view->assign('site', $siteNode);
$this->view->assign('clipboardNodes', $this->clipboard->getSerializedNodeAddresses());
$this->view->assign('clipboardMode', $this->clipboard->getMode());
$this->view->assign('headScripts', $this->styleAndJavascriptInclusionService->getHeadScripts());
$this->view->assign('headStylesheets', $this->styleAndJavascriptInclusionService->getHeadStylesheets());
$this->view->assign('sitesForMenu', $this->menuHelper->buildSiteList($this->getControllerContext()));
$this->view->assign('modulesForMenu', $this->menuHelper->buildModuleList($this->getControllerContext()));
$this->view->assign('contentRepositoryId', $siteDetectionResult->contentRepositoryId);

$this->view->assignMultiple([
'subgraph' => $subgraph
'configuration' =>
$this->configurationProvider->getConfiguration(
contentRepository: $contentRepository,
uriBuilder: $this->controllerContext->getUriBuilder(),
),
'routes' =>
$this->routesProvider->getRoutes(
uriBuilder: $this->controllerContext->getUriBuilder()
),
'frontendConfiguration' =>
$this->frontendConfigurationProvider->getFrontendConfiguration(
controllerContext: $this->controllerContext,
),
'nodeTypes' =>
$this->nodeTypesProvider->getNodeTypes(),
'menu' =>
$this->menuProvider->getMenu(
controllerContext: $this->controllerContext,
),
'initialState' =>
$this->initialStateProvider->getInitialState(
controllerContext: $this->controllerContext,
contentRepositoryId: $siteDetectionResult->contentRepositoryId,
documentNode: $node,
site: $siteNode,
user: $user,
),
]);

$this->view->assign('interfaceLanguage', $this->userService->getInterfaceLanguage());
}

/**
Expand Down
23 changes: 23 additions & 0 deletions Classes/Domain/CacheConfigurationVersionProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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;

/**
* @internal
*/
interface CacheConfigurationVersionProviderInterface
{
public function getCacheConfigurationVersion(): string;
}
29 changes: 29 additions & 0 deletions Classes/Domain/ConfigurationProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\Flow\Mvc\Routing\UriBuilder;

/**
* @internal
*/
interface ConfigurationProviderInterface
{
public function getConfiguration(
ContentRepository $contentRepository,
UriBuilder $uriBuilder,
): array;
}
27 changes: 27 additions & 0 deletions Classes/Domain/FrontendConfigurationProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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;

use Neos\Flow\Mvc\Controller\ControllerContext;

/**
* @internal
*/
interface FrontendConfigurationProviderInterface
{
public function getFrontendConfiguration(
ControllerContext $controllerContext
): array;
}
34 changes: 34 additions & 0 deletions Classes/Domain/InitialStateProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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;

use Neos\ContentRepository\Core\Factory\ContentRepositoryId;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Neos\Domain\Model\User;

/**
* @internal
*/
interface InitialStateProviderInterface
{
public function getInitialState(
ControllerContext $controllerContext,
ContentRepositoryId $contentRepositoryId,
?Node $documentNode,
?Node $site,
User $user,
): array;
}
25 changes: 25 additions & 0 deletions Classes/Domain/MenuProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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;

use Neos\Flow\Mvc\Controller\ControllerContext;

/**
* @internal
*/
interface MenuProviderInterface
{
public function getMenu(ControllerContext $controllerContext): array;
}
23 changes: 23 additions & 0 deletions Classes/Domain/NodeTypesProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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;

/**
* @internal
*/
interface NodeTypesProviderInterface
{
public function getNodeTypes(): array;
}
25 changes: 25 additions & 0 deletions Classes/Domain/RoutesProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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;

use Neos\Flow\Mvc\Routing\UriBuilder;

/**
* @internal
*/
interface RoutesProviderInterface
{
public function getRoutes(UriBuilder $uriBuilder): array;
}
Loading

0 comments on commit d288e5f

Please sign in to comment.