【问题标题】:ZF3 Doctrine Object provided to Escape helper, but flags do not allow recursionZF3 Doctrine Object 提供给 Escape 助手,但标志不允许递归
【发布时间】:2020-01-24 11:23:41
【问题描述】:

在我的专业实体中,我想加入 al 列并显示来自加入列的专业行,但我收到错误:对象提供给 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; ?> 

【问题讨论】:

    标签: zend-framework orm doctrine-orm


    【解决方案1】:

    它返回对象,所以我必须使用引用对象的方法:

    $user->getBeschikbaarheid()->getOpZoekNaar());

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-07
      • 2012-04-07
      • 1970-01-01
      • 2019-03-24
      • 2014-12-25
      相关资源
      最近更新 更多