[英]How to add a shortcut link programmatically in Drupal 9?
Trying to add some shortcut link I get this error尝试添加一些快捷链接我收到此错误
Fatal error: InvalidArgumentException: The URI '' is invalid.致命错误:InvalidArgumentException:URI“”无效。 You must use a valid URI scheme.您必须使用有效的 URI 方案。 in../core/lib/Drupal/Core/Url.php:293在../core/lib/Drupal/Core/Url.php:293
use Drupal\shortcut\Entity\Shortcut;
$taxo_shorcut = Shortcut::create([
'shortcut_set' =>'default',
'title' => 'Test',
'link' => 'admin/structure/taxonomy',
]);
$taxo_shorcut->save();
Any help?有什么帮助吗?
Build the URI structure correctly with a uri
key value using the internal:
scheme:使用internal:
方案使用uri
键值正确构建 URI 结构:
$taxo_shorcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => 'Test',
'link' => [
'uri' => 'internal:/admin/structure/taxonomy',
],
]);
$taxo_shorcut->save();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.