Neos: Routings for Inspector Editors

435 views Asked by At

I try to create an own inspector editor which should be able to load data via a controller. For this I render an LINK-tag – like Neos does – in the header:

<link rel="vendor-package-backend-content" href="http://typo3-neos-1.1.x.dev/vendor.package/backend/content/load />

A controller Packages/Application/Vendor.Package/Classes/Vendor/Package/Controller/Backend/ContentController.php is created.

This is the file Configuration/Routes.yaml:

-
  name: 'TYPO3 Neos'
  uriPattern: '<TYPO3NeosSubroutes>'
  subRoutes:
    'TYPO3NeosSubroutes':
      package: 'TYPO3.Neos'
      variables:
        'defaultUriSuffix': '.html'

-
  name: 'Vendor Package
  uriPattern: '<VendorPackageSubroutes>'
  subRoutes:
    'VendorPackageSubroutes':
      package: 'Vendor.Package'
      variables:
        'defaultUriSuffix': '.html'

Here the file Packages/Application/Vendor.Package/Configuration/Routes.yaml

-
  name:  'Backend'
  uriPattern: 'vendor.package/<BackendSubRoutes>'
  defaults:
    '@package':    'Vendor.Package'
    '@action':     'index'
    '@format':     'html'
  subRoutes:
    'BackendSubRoutes':
      package: 'Vendor.Package'
      suffix:  'Backend'

And finaly the file Packages/Application/Vendor.Package/Configuration/Routes.Backend.yaml

-
  name: 'Backend Content Controller'
  uriPattern: 'backend/content(/{@action})'
  defaults:
    '@package':    'Vendor.Package'
    '@controller': 'Backend\Content'
  appendExceedingArguments: TRUE

If the URL is now called: http://domain.com/vendor.package/backend/content/index an "Page not found" error is thrown. I have to deactivate the TYPO3.Flow.error.exceptionHandler.renderingGroups.notFoundExceptions to see more details:

Sorry, the page you requested was not found. Technical details:

Could not find a preset for content dimension "language" through the given URI segment "vendor.package". (reference code: 2014121115590523bc78)

But I don't find out how the path segment for /neos is defined for dimensions, there it works…

How I must configure this?

2

There are 2 answers

0
k.tarkin On

Try putting your vendor routes definition above neos in main Routs.yaml. Check your Data/Logs/System_Development.log if it matches what it should.

Hm, and remove this part for your Vendor.Package:

  variables:
    'defaultUriSuffix': '.html'
0
user2513437 On

Thanks tarkin. The Development-Log was a good hint :) I think I've got it and I will share this. There are several configurations to set:

1) The LINK-tag rendered through the TS2 page – like Neos does – in the header with login required.

<f:security.ifAccess resource="Vendor_Package_BackendAccess">
    <link rel="vendor-package-backend-content" href="http://typo3-neos-1.1.x.dev/vendor.package/backend/content/load />
</f:security.ifAccess>

2) A controller Packages/Application/Vendor.Package/Classes/Vendor/Package/Controller/Backend/ContentController.php.

3) Settings in the file Configuration/Routes.yaml:

-
  name: 'Vendor Package
  uriPattern: '<VendorPackageSubroutes>'
  subRoutes:
    'VendorPackageSubroutes':
      package: 'Vendor.Package'
      variables:
        'defaultUriSuffix': '.html'

4) The file Packages/Application/Vendor.Package/Configuration/Routes.yaml

-
  name:  'Backend'
  uriPattern: 'vendor.package/<BackendSubRoutes>'
  defaults:
    '@package':    'Vendor.Package'
    '@action':     'index'
    '@format':     'html'
  subRoutes:
    'BackendSubRoutes':
      package: 'Vendor.Package'
      suffix:  'Backend'

5) The file Packages/Application/Vendor.Package/Configuration/Routes.Backend.yaml

-
  name: 'Backend Content Controller'
  uriPattern: 'backend/content(/{@action})'
  defaults:
    '@package':    'Vendor.Package'
    '@controller': 'Backend\Content'
  appendExceedingArguments: TRUE

6) The file Packages/Application/Vendor.Package/Configuration/Policy.yaml.

resources:
  methods:
    Vendor_Package_BackendAccess: 'method(Vendor\Package\Controller\Backend\ContentController->.*Action())'

acls:
  'TYPO3.Neos:Editor':
    methods:
      Vendor_Package_BackendAccess: GRANT

7) And at least Packages/Application/Vendor.Package/Configuration/Settings.yaml

  Flow:
    security:
      authentication:
        providers:
          Typo3BackendProvider:
            requestPatterns:
              controllerObjectName: 'TYPO3\Neos\Controller\.*|TYPO3\Neos\Service\.*|TYPO3\Media\Controller\.*|Vendor\Package\Controller\Backend\.*'

8) There is one more thing for Packages/Application/Vendor.Package/Configuration/Settings.yaml, else you get an error cause of missing dimension mapping.

  TYPO3CR:
    contentDimensions:
      'language':
        presets:
          'vendor.packages':
            label: ''
            values: ['mul_ZZ']
            uriSegment: 'vendor.packages'

This will be the first part of the answer :)

But there are some questions left:

1) This will be at least a package. So I wounder why I have to set stuff in Configuration/Routes.yaml, which will not be part of the installation process (?).

2) In this example it's required to override the path Flow.security.authentication.providers.Typo3BackendProvider.requestPatterns.controllerObjectName. I don't think, that this is usefull and that there must be another way.