我正在尝试加载实体类并在循环中使用,以便将文件中的内容动态加载到相关内容中 表格。 p>
有什么方法可以加载以下 p>
中的所有Entity文件,使用AppBundle \ Entity \ aaPostcode;
use AppBundle \ Entity \ abPostcode;
use AppBundle \ Entity \ acPostcode;
use AppBundle \ Entity \ adPostcode;
code> pre>
以这样的方式? p>
使用AppBundle \ Entity \ *
code> pre>
不确定Symfony是否可以这样做。 p>
我的下一个问题是在循环中使用prefixedEntity,如下所示 - p>
new $ entityPrefix
code> pre>
当我将$ entityPrefix设置为以下格式时 p>
$ entityPrefix = str_replace([“。csv”],“”,$ entityFilename)。 “邮政编码”。 '()';
code> pre>
返回字符串 p>
“abPostcode()”
代码> pre>
任何人都可以建议为什么要调用 p>
new $ entityPrefix;
code> pre>
无法正常工作 p>
提前感谢您的帮助! p>
尝试拨打 p>
new $ entityPrefix();
code> pre>
返回 p>
[Symfony \ Component \ Debug \ Exception \ ClassNotFoundException]
试图从全局命名空间加载类“abPostcode”。
你忘记了“AppBundle \ Entity \ abPostcode”的“使用”声明吗?
code> pre>
即使我当前正在使用hlad编码使用stament来调用 p>
使用AppBundle \ Entity \ abPostcode;
code> pre>
div>