【问题标题】:Notice: Undefined index: path in Drupal\Core\Routing\注意:未定义索引:Drupal\Core\Routing\ 中的路径
【发布时间】:2018-11-06 08:10:53
【问题描述】:

我在 Drupal 8 中创建了一个模块,添加路由后,我在日志消息中收到一条通知:

注意:未定义索引:Drupal\Core\Routing\RouteBuilder->rebuild() 中的路径(/home/...的第 172 行...

我的模块 routing.yml 如下所示:

---
mymodule.mypage:
  path: /mypage
  defaults:
    _controller: Drupal\mymodule\Controller\MyPageController::customPage
    _title: My custom page
requirements:
  _role: anonymous

访问我收到此消息的页面:

访问被拒绝 您无权访问此页面。

【问题讨论】:

    标签: drupal module drupal-8


    【解决方案1】:

    对我来说看起来像是错误的缩进。并且可能不检查角色,而是检查access content 权限。

    mymodule.mypage:
      path: '/mypage'
      defaults:
        _controller: 'Drupal\mymodule\Controller\MyPageController::customPage'
        _title: 'My custom page'
      requirements:
        _permission: 'access content'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-02
      • 2014-02-06
      • 1970-01-01
      • 2015-12-01
      • 2013-11-27
      • 2021-09-08
      • 1970-01-01
      相关资源
      最近更新 更多