Skip to content

Commit

Permalink
TASK: Refactor controller to not use static fusion path
Browse files Browse the repository at this point in the history
The fusion path is now dynamically determined by controller / action
This enables additional actions with separate templates for that controller.
  • Loading branch information
daniellienert committed Jul 5, 2021
1 parent 28b69b2 commit b146826
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 275 deletions.
13 changes: 0 additions & 13 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Domain\Service\ContextFactoryInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Http\Component\SetHeaderComponent;
use Neos\Flow\Mvc\Controller\ActionController;
use Neos\Flow\Mvc\Exception\NoSuchArgumentException;
use Neos\Flow\Mvc\Exception\StopActionException;
Expand All @@ -26,7 +25,6 @@
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Flow\ResourceManagement\ResourceManager;
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;
Expand Down Expand Up @@ -112,17 +110,6 @@ class BackendController extends ActionController
*/
protected $linkingService;

/**
* Initializes the view before invoking an action method.
*
* @param ViewInterface $view The view to be initialized
* @return void
*/
public function initializeView(ViewInterface $view)
{
$view->setFusionPath('backend');
}

/**
* Displays the backend interface
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
Neos.Neos.Ui.BackendController.index = Neos.Fusion:Template {
templatePath = 'resource://Neos.Neos.Ui/Private/Templates/Backend/Index.html'

headScripts = ${headScripts}
headStylesheets = ${headStylesheets}
splashScreenPartial = ${splashScreenPartial}

headIcons = Neos.Fusion:Join {
appleTouchIcon = Neos.Fusion:Tag {
tagName = 'link'
attributes {
href = Neos.Fusion:ResourceUri {
path = 'resource://Neos.Neos.Ui/Public/Images/apple-touch-icon.png'
}
sizes = '180x180'
rel = 'apple-touch-icon'
}
}
favicon16 = Neos.Fusion:Tag {
tagName = 'link'
attributes {
href = Neos.Fusion:ResourceUri {
path = 'resource://Neos.Neos.Ui/Public/Images/favicon-16x16.png'
}
sizes = '16x16'
rel = 'icon'
type = 'image/png'
}
}
favicon32 = Neos.Fusion:Tag {
tagName = 'link'
attributes {
href = Neos.Fusion:ResourceUri {
path = 'resource://Neos.Neos.Ui/Public/Images/favicon-32x32.png'
}
sizes = '32x32'
rel = 'icon'
type = 'image/png'
}
}
safariPinnedTab = Neos.Fusion:Tag {
tagName = 'link'
attributes {
href = Neos.Fusion:ResourceUri {
path = 'resource://Neos.Neos.Ui/Public/Images/safari-pinned-tab.svg'
}
rel = 'mask-icon'
color = '#00adee'
}
}
}

configuration = Neos.Fusion:DataStructure {
nodeTree = ${Configuration.setting('Neos.Neos.userInterface.navigateComponent.nodeTree')}
structureTree = ${Configuration.setting('Neos.Neos.userInterface.navigateComponent.structureTree')}
allowedTargetWorkspaces = ${Neos.Ui.Workspace.getAllowedTargetWorkspaces()}
endpoints = Neos.Fusion:DataStructure {
nodeTypeSchema = Neos.Fusion:UriBuilder {
package = 'Neos.Neos'
controller = 'Backend\\Schema'
action = 'nodeTypeSchema'
absolute = true
arguments = Neos.Fusion:DataStructure {
# TODO: dirty hack to not have to re-implement neos:backend.configurationCacheVersion VH
version = Neos.Fusion:Template {
templatePath = 'resource://Neos.Neos.Ui/Private/Templates/Backend/ConfigurationVersion.html'
@process.trim = ${String.trim(value)}
}
}
}
translations = Neos.Fusion:UriBuilder {
package = 'Neos.Neos'
controller = 'Backend\\Backend'
action = 'xliffAsJson'
absolute = true
arguments = Neos.Fusion:DataStructure {
locale = ${interfaceLanguage}

# TODO: dirty hack to not have to re-implement neos:backend.configurationCacheVersion VH
version = Neos.Fusion:Template {
templatePath = 'resource://Neos.Neos.Ui/Private/Templates/Backend/ConfigurationVersion.html'
@process.trim = ${String.trim(value)}
}
}
}
}
@process.json = ${Json.stringify(value)}
}

routes = Neos.Fusion:DataStructure {
prototype(Neos.Fusion:UriBuilder) {
absolute = true
}

ui = Neos.Fusion:DataStructure {
service = Neos.Fusion:DataStructure {
prototype(Neos.Fusion:UriBuilder) {
package = 'Neos.Neos.Ui'
controller = 'BackendService'
}

change = Neos.Fusion:UriBuilder {
action = 'change'
}
publish = Neos.Fusion:UriBuilder {
action = 'publish'
}
discard = Neos.Fusion:UriBuilder {
action = 'discard'
}
changeBaseWorkspace = Neos.Fusion:UriBuilder {
action = 'changeBaseWorkspace'
}
copyNodes = Neos.Fusion:UriBuilder {
action = 'copyNodes'
}
cutNodes = Neos.Fusion:UriBuilder {
action = 'cutNodes'
}
clearClipboard = Neos.Fusion:UriBuilder {
action = 'clearClipboard'
}
loadTree = Neos.Fusion:UriBuilder {
action = 'loadTree'
}
flowQuery = Neos.Fusion:UriBuilder {
action = 'flowQuery'
}
getWorkspaceInfo = Neos.Fusion:UriBuilder {
action = 'getWorkspaceInfo'
}
getAdditionalNodeMetadata = Neos.Fusion:UriBuilder {
action = 'getAdditionalNodeMetadata'
}
}
}
core = Neos.Fusion:DataStructure {
prototype(Neos.Fusion:UriBuilder) {
package = 'Neos.Neos'
}

content = Neos.Fusion:DataStructure {
prototype(Neos.Fusion:UriBuilder) {
controller = 'Backend\\Content'
}

imageWithMetadata = Neos.Fusion:UriBuilder {
action = 'imageWithMetaData'
}
createImageVariant = Neos.Fusion:UriBuilder {
action = 'createImageVariant'
}
loadMasterPlugins = Neos.Fusion:UriBuilder {
action = 'masterPlugins'
}
loadPluginViews = Neos.Fusion:UriBuilder {
action = 'pluginViews'
}
uploadAsset = Neos.Fusion:UriBuilder {
action = 'uploadAsset'
}
}
service = Neos.Fusion:DataStructure {
assetProxies = Neos.Fusion:UriBuilder {
controller = 'Service\\AssetProxies'
action = 'index'
}
assets = Neos.Fusion:UriBuilder {
controller = 'Service\\Assets'
action = 'index'
}
nodes = Neos.Fusion:UriBuilder {
controller = 'Service\\Nodes'
action = 'index'
}
userPreferences = Neos.Fusion:UriBuilder {
subpackage = 'Service'
controller = 'UserPreference'
action = 'index'
format = 'json'
}
dataSource = Neos.Fusion:UriBuilder {
subpackage = 'Service'
controller = 'DataSource'
action = 'index'
format = 'json'
}
contentDimensions = Neos.Fusion:UriBuilder {
package = 'Neos.Neos'
controller = 'Service\\ContentDimensions'
action = 'index'
}
}
modules = Neos.Fusion:DataStructure {
prototype(Neos.Fusion:UriBuilder) {
controller = 'Backend\\Module'
}
workspaces = Neos.Fusion:UriBuilder {
action = 'index'
arguments {
module = 'management/workspaces'
}
}
userSettings = Neos.Fusion:UriBuilder {
controller = 'Backend\\Module'
action = 'index'
arguments {
module = 'user/usersettings'
}
}
mediaBrowser = Neos.Fusion:UriBuilder {
controller = 'Backend\\Module'
action = 'index'
arguments {
module = 'media/browser'
}
}
}
login = Neos.Fusion:UriBuilder {
controller = 'Login'
action = 'index'
format = 'json'
}
logout = Neos.Fusion:UriBuilder {
controller = 'Login'
action = 'logout'
}
}
@process.json = ${Json.stringify(value)}
}

frontendConfiguration = Neos.Neos.Ui:RenderConfiguration {
path = 'frontendConfiguration'
@process.json = ${Json.stringify(value)}
}

nodeTypes = Neos.Fusion:DataStructure {
roles = ${Configuration.setting('Neos.Neos.Ui.nodeTypeRoles')}
groups = ${Neos.Ui.PositionalArraySorter.sort(Configuration.setting('Neos.Neos.nodeTypes.groups'))}

@process.json = ${Json.stringify(value)}
}

menu = Neos.Neos.Ui:Component.ModuleMenu

initialState = Neos.Neos.Ui:RenderConfiguration {
path = 'initialState'
context {
documentNode = ${documentNode}
site = ${site}
user = ${user}
clipboardNodes = ${clipboardNodes}
clipboardMode = ${clipboardMode}
}

@process.json = ${Json.stringify(value)}
}

env = ${Configuration.setting('Neos.Flow.core.context')}
}
Loading

0 comments on commit b146826

Please sign in to comment.