0
我有一物體應該更新基本控制器:Symfony的 - getter和setter失蹤
(我硬編碼的測試ID)
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class UserController extends Controller {
/**
* @Route("/lorem", name="ipsum")
*/
public function defaultAction(Request $request) {
$em = $this->getDoctrine()->getManager();
$user = $em->getRepository('AppBundle:Customer\Customer')->find(3);
if (!$user) {
throw $this->createNotFoundException(
'No user found for id 3'
);
}
// I cant access setter and getter from user object !
$user->setName('afsd');
$em->flush();
return $this->render(
'AppBundle:directoy:index.html.twig',
[]
);
}
}
如果我想使用的setter和getter上用戶對象,我不能。
Method setName() not found...
任何人都可以想象爲什麼?
感謝和問候!