提供给 Escape 助手的 ZF3 Doctrine 对象,但标志不允许递归
ZF3 Doctrine Object provided to Escape helper, but flags do not allow recursion
在我的 specialisme 实体中,我想连接所有列并显示来自 specialisme 的行与连接的列,但我得到错误:对象提供给 Escape 助手,但标志不允许递归
专业实体:
/**
* @ORM\OneToOne(targetEntity="User\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $fullname;
//...
/**
* Returns fullname.
* @return string
*/
public function getFullName()
{
return $this->fullname;
}
在控制器中:
public function indexAction()
{
//Array met alle user samenstellen
$users = $this->entityManager->getRepository(Specialisme::class)->findBy([], ['id'=>'ASC']);
//Users doorgeven aan view model
return new ViewModel([
'users' => $users
]);
return new ViewModel();
}
查看:
<tr>
<th>Naam</th>
<th>Specialisme</th>
<th>Sub-specialisme</th>
</tr>
<?php foreach ($users as $user): ?>
<tr>
<td>f</td>
<td><?= $this->escapeHtml($user->getId()); ?></td>
<td><?= $this->escapeHtml($user->getFullName()); ?></td>
</tr>
<?php endforeach; ?>
它返回对象,所以我必须使用引用对象的方法:
$user->getBeschikbaarheid()->getOpZoekNaar());
在我的 specialisme 实体中,我想连接所有列并显示来自 specialisme 的行与连接的列,但我得到错误:对象提供给 Escape 助手,但标志不允许递归
专业实体:
/**
* @ORM\OneToOne(targetEntity="User\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $fullname;
//...
/**
* Returns fullname.
* @return string
*/
public function getFullName()
{
return $this->fullname;
}
在控制器中:
public function indexAction()
{
//Array met alle user samenstellen
$users = $this->entityManager->getRepository(Specialisme::class)->findBy([], ['id'=>'ASC']);
//Users doorgeven aan view model
return new ViewModel([
'users' => $users
]);
return new ViewModel();
}
查看:
<tr>
<th>Naam</th>
<th>Specialisme</th>
<th>Sub-specialisme</th>
</tr>
<?php foreach ($users as $user): ?>
<tr>
<td>f</td>
<td><?= $this->escapeHtml($user->getId()); ?></td>
<td><?= $this->escapeHtml($user->getFullName()); ?></td>
</tr>
<?php endforeach; ?>
它返回对象,所以我必须使用引用对象的方法:
$user->getBeschikbaarheid()->getOpZoekNaar());