routeEnhancers для несуществующего URL-адреса новости

Я настроил routeEnhancers для новостей и вроде все работает. Мой URL выглядит удобным для пользователя domain.my/news/details/something-new-242. Теперь я хочу проверить, что происходит, когда кто-то добавляет несколько символов в мой URL-адрес fe domain. My/news/details/something-new-242-2ddwdwedw

typo3 выдает ошибку: параметр «acec1fc0ac7e1adfbcd522115dc07925» для маршрута «tx_news_pi1_0» должен соответствовать «[^ /] ++» («» задано) для создания соответствующего URL.

Я ожидал, что страница с ошибкой 404.

Мой вопрос в том, как изменить routeEnhancers, чтобы выбросить 404

routeEnhancers:

  NewsPlugin:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      - { routePath: '/{news_post}', _controller: 'News::detail', _arguments: {'news_post': 'news'} }
      - { routePath: '/{tag_name}', _controller: 'News::list', _arguments: {'tag_name': 'overwriteDemand/tags'} }
      - { routePath: '/{category}', _controller: 'News::list', _arguments: {'category': 'overwriteDemand/categories'} }
      - { routePath: '/{page}', _controller: 'News::list', _arguments: {'page': '@widget_0/currentPage'} }
      - { routePath: '/{year}/{month}', _controller: 'News::list', _arguments: {'year': 'overwriteDemand/year', 'month': 'overwriteDemand/month' } }
      - { routePath: '/{year}/{month}/{day}', _controller: 'News::list', _arguments: {'year': 'overwriteDemand/year', 'month': 'overwriteDemand/month', 'day': 'overwriteDemand/day' } }
    defaultController: 'News::list'
    aspects:
      news_post:
        type: PersistedPatternMapper
        tableName: 'tx_news_domain_model_news'
        routeFieldPattern: '^(?P<path_segment>.+)-(?P<uid>\d+)$'
        routeFieldResult: '{path_segment}-{uid}'
      tag_name:
        type: PersistedAliasMapper
        tableName: 'tx_news_domain_model_tag'
        routeFieldName: 'slug'
      category:
        type: PersistedAliasMapper
        tableName: 'sys_category'
        routeFieldName: 'slug'
      page:
        type: StaticRangeMapper
        start: '1'
        end: '1000'

person Bartosz    schedule 11.05.2019    source источник


Ответы (1)


Еще одна вещь, которую вы пропустили, - это конфигурация перенаправления 404. Попробуйте это,

routeEnhancers:

  NewsPlugin:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      - { routePath: '/{news_post}', _controller: 'News::detail', _arguments: {'news_post': 'news'} }
      - { routePath: '/{tag_name}', _controller: 'News::list', _arguments: {'tag_name': 'overwriteDemand/tags'} }
      - { routePath: '/{category}', _controller: 'News::list', _arguments: {'category': 'overwriteDemand/categories'} }
      - { routePath: '/{page}', _controller: 'News::list', _arguments: {'page': '@widget_0/currentPage'} }
      - { routePath: '/{year}/{month}', _controller: 'News::list', _arguments: {'year': 'overwriteDemand/year', 'month': 'overwriteDemand/month' } }
      - { routePath: '/{year}/{month}/{day}', _controller: 'News::list', _arguments: {'year': 'overwriteDemand/year', 'month': 'overwriteDemand/month', 'day': 'overwriteDemand/day' } }
    defaultController: 'News::list'
    aspects:
      news_post:
        type: PersistedPatternMapper
        tableName: 'tx_news_domain_model_news'
        routeFieldPattern: '^(?P<path_segment>.+)-(?P<uid>\d+)$'
        routeFieldResult: '{path_segment}-{uid}'
      tag_name:
        type: PersistedAliasMapper
        tableName: 'tx_news_domain_model_tag'
        routeFieldName: 'slug'
      category:
        type: PersistedAliasMapper
        tableName: 'sys_category'
        routeFieldName: 'slug'
      page:
        type: StaticRangeMapper
        start: '1'
        end: '1000'

errorHandling:
  -
    errorCode: '404'
    errorHandler: Page
    errorContentSource: 't3://page?uid=14'

Думаю, это то, что ты хочешь, не так ли?

person GNB    schedule 11.05.2019
comment
Привет. У меня уже было это в моем конфиге. Это не решает проблему с неправильным URL-адресом новости - person Bartosz; 12.05.2019