【发布时间】:2018-04-29 14:14:45
【问题描述】:
我想创建一个外部菜单链接,这是我的代码。
class MyClass extends DeriverBase implements ContainerDeriverInterface {
public function getDerivativeDefinitions($base_plugin_definition) {
$links = [];
$sites = [
'www.google.com' => 'http://gwa-caromaww2.netsol.local/',
'www.drupal.org' => 'http://drupal.org/'
];
foreach ($sites as $key => $site) {
$links['sites'.$key] = [
'title' => $key,
'path' => $site,
] + $base_plugin_definition;
}
return $links;
}
}
当我安装我的自定义模块时,它会生成一条错误消息:
Symfony\Component\Routing\Exception\RouteNotFoundException:路由“”不存在。在 Drupal\Core\Routing\RouteProvider->getRouteByName() (D:\workspace\projects\caromaww\core\lib\Drupal\Core\Routing\RouteProvider.php 的第 190 行)。
【问题讨论】:
-
Drupal 8 允许您创建开箱即用的外部菜单链接。