主义取代与其ID的关联

时间:2015-06-11 17:08:14

标签: symfony doctrine-orm fosrestbundle

我正在使用Symfony2中的public function helperRemoveAssociations($entities) { $em = $this->getEntityManager(); $data = array(); /** @var WBEntity $entity */ foreach ($entities as $entity) { $entityAssociations = $entity->getAssociationNames($em); // ex: array('category', 'comments') foreach ($entityAssociations as $associationName) { $associationGetter = 'get' . ucfirst($associationName); $associationSetter = 'set' . ucfirst($associationName); /** @var WBEntity $associationObject */ $associationObject = $entity->$associationGetter(); $associationId = $associationObject->getEntityId($em); // ex: 51 $entity->$associationSetter($associationId); // I am not allowed to write an integer } $data[] = $entity; } return $data; } 构建API,我正试图从没有运气的实体中删除实体关联,以最小化API响应中发送的JSON数据。< / p>

disabled="disabled"

如何完成此操作,将相关实体替换为各自的ID。

0 个答案:

没有答案