无法猜测如何从参数的请求信息中获取Doctrine实例

时间:2019-03-19 08:02:03

标签: php symfony doctrine

我有一个控制器,它从Twig获取字符串boolean mobileDataEnabled = false; // Assume disabled ConnectivityManager cm = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); try { Class cmClass = Class.forName(cm.getClass().getName()); Method method = cmClass.getDeclaredMethod("getMobileDataEnabled"); method.setAccessible(true); // Make the method callable // get the setting for "mobile data" mobileDataEnabled = (Boolean)method.invoke(cm); Log.e("mobileDataEnabled",mobileDataEnabled+""); } catch (Exception e) { // Some problem accessible private API // TODO do whatever error handling you want here } 作为参数:

hashId

class UserController extends AbstractController { /** * @Route("/user/{hashId}", name="user_read", methods="GET")") * @Entity("user", class="App\Entity\User", expr="repository.findOneByHashId(hashId)") */ public function read(User $user, Request $request): Response { return $this->render('user.html.twig', [ 'user' => $user, ]); } } hashId中解码并传递到UserRepository.php

findOneBy()

但是,我收到此错误:“无法猜测如何从参数“用户”的请求信息中获取Doctrine实例。 这里可能有什么问题?谢谢

0 个答案:

没有答案