flow-frameworkneoscms

Routes for Neos plugin


I'm trying to define routes for my plugin. Everything is working as it should, because I got pretty URL on output, but unfortunately while I'm trying to access it I get an 404 error with message:

#1303209195: No controller could be resolved which would match your request. Package key: "", controller name: "Standard". (GET http://test.local/dashboard/page/subpage/q/1fcff21b-7690-4f54-7491-f49c825ca05f/38f8b0cf-03e9-1717-b5b3-9bc7aa926862)

Main Routes.yaml:

-
  name: 'AcmeMyPlugin'
  uriPattern: '<AcmeMyPluginSubroutes>'
  subRoutes:
    AcmeMyPluginSubroutes:
      package: 'AcmeMyPlugin'
      variables:
        'defaultUriSuffix': ''

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

Plugin Routes.yaml:

-
  name: 'Nice urls for my plugin'
  uriPattern:    '{node}/q(/{--acme_myplugin-element.object1}/{--acme_myplugin-element.object2})'
  defaults:
    '@package':    'TYPO3.Neos'
    '@controller': 'Frontend\Node'
    '@action':     'show'
    '@format': 'html'
    '--acme_myplugin-element':
      '@package': 'Acme.MyPlugin'
      '@controller': 'Standard'
      '@action': 'display'
      '@format': 'html'
  routeParts:
    node:
      handler:    TYPO3\Neos\Routing\FrontendNodeRoutePartHandler
  appendExceedingArguments: FALSE

Root.ts2 for plugin:

prototype(Acme.MyPlugin:Element) < prototype(TYPO3.Neos:Plugin) {
    package = 'Acme.MyPlugin'
    controller = 'Standard'
    action = 'display'
}

Action which I'm trying to execute:

public function displayAction(Object1 $object1 = NULL, Object2 $object2 = NULL) {
    // body
}

I'm using Neos 2.0.x-dev. Did I miss something in my configuration?


Solution

  • Ok, I finally figure out what was wrong. I defined my route for plugin with optional params, which somehow was wrongly interpreted by request handler. Correct routes for my plugin should looks as follows:

    -
      name: 'Nice urls for my plugin'
      uriPattern:    '{node}/q/{--acme_myplugin-element.object1}/{--acme_myplugin-element.object2}'
      defaults:
        '@package':    'TYPO3.Neos'
        '@controller': 'Frontend\Node'
        '@action':     'show'
        '@format': 'html'
        '--acme_myplugin-element':
          '@package': 'Acme.MyPlugin'
          '@controller': 'Standard'
          '@action': 'display'
          '@format': 'html'
      routeParts:
        node:
          handler:    TYPO3\Neos\Routing\FrontendNodeRoutePartHandler
      appendExceedingArguments: FALSE