if ($u = $this->generateUrl('_'.$specific.'_thanks')) return $this->redirect($u); else return $this->redirect($this->generateUrl('_thanks'));
当它存在时,我不想重定向到_specific_thanks url.那么如何检查网址是否存在?
当我这样做时,我遇到了这个错误:
Route “_specific_thanks” does not exist.
我认为没有直接的方法来检查路线是否存在.但是你可以通过路由器服务寻找路由存在.
$router = $this->container->get('router');
然后,您可以获取路由集合并为给定路由调用get(),如果它不存在则返回null.
$router->getRouteCollection()->get('_'. $specific. '_thanks');
原文地址:https://www.jb51.cc/php/135012.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。