url link redirect drupal8

  • l() is gone. Use \Drupal\Core\Link for full link objects,   -- 链接对象
    and \Drupal\Core\Url for URL generation.       --- 生成url
  • drupal_goto() is gone. Use a RedirectResponse, or the redirect() method in your controller.  -- 跳转
  • ------------------   https://dev.acquia.com/blog/generating-urls-and-redirects-in-drupal-8/22/02/2016/9626

记得前段时间对drupal/core/url->toString(TRUE|FALSE) 还纠结了半天
其实文档说的很清楚啊
就是如果TRUE的话,那返回一个对象,而这很多时候我们是只需要一个字符串的

* @return string|\Drupal\Core\GeneratedUrl
* A string URL.
* When $collect_bubbleable_metadata is TRUE, a GeneratedUrl object is
* returned, containing the generated URL plus bubbleable metadata.

猜你喜欢

转载自www.cnblogs.com/qinqiu/p/9023308.html
今日推荐