アクションでリポジトリを使用して、テーブル User から Id を取得したいと考えています。
$user = $this->getDoctrine()->getRepository('AppMyBundle:User')
->findByUsername($token['name']);
$id = $user['id']; // also $user->id or $user->getId() give me error?
それは私にこのエラーを与えます:
Notice: Undefined index: id in /var/www/project/src/App/MyBundle/Controller/DefaultController.php line 56
最後に var_daump 出力:
echo "<pre>";
var_dump($user);
exit();
echo "</pre>";
array(1) {
[0]=>
object(App\MyBundle\Entity\User)#351 (21) {
["id":protected]=>
int(17)
....
....