我如何找出 symfony 中的学说模型是否存在方法?

发布于 2024-09-10 20:29:27 字数 158 浏览 2 评论 0原文

我有一个具有 getSomethingId() 方法的学说模型

,并且我正在制作一个自动表单生成器供公司内部使用,

我如何检查我的模型是否具有此方法?

我尝试过使用 php 的 method_exists,但每个方法都返回 false,我该怎么办? 谢谢

I have a doctrine model that has a method getSomethingId()

and I'm making something of an automated form generator for internal use in the company

how can I check if my model has this method?

I've tried with php's method_exists but it returns false for every method, what can I do?
thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡笑忘祈一世凡恋 2024-09-17 20:29:27

我会尝试 is_callable()

I'd try is_callable()

野生奥特曼 2024-09-17 20:29:27

普鲁巴阿西

$class=get_class($object);
if ( method_exists($class , $method)||$object->getTable()->hasField($fieldName)) {
  $string= str_replace($matches,call_user_func(array($object, $method)),$string);
}

prueba asi

$class=get_class($object);
if ( method_exists($class , $method)||$object->getTable()->hasField($fieldName)) {
  $string= str_replace($matches,call_user_func(array($object, $method)),$string);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文