简体   繁体   English

如何使用ezplatform model 多对一关系?

[英]how to model many-to-one relation using ezplatform?

project has lots of asset, an asset belongs to a group.项目有很多资产,资产属于一个组。 then we have 3 content types那么我们有 3 种内容类型

Project, ProjectAsset, AssetGroup项目、项目资产、资产组

  1. store the assets relation in Project content type.将资产关系存储在项目内容类型中。

    Project项目

    name assets relation名称资产关系

    ProjectAsset项目资产

    image group relation图像组关系

    Group团体

    name姓名

with this approach, we need to upload project asset first, then add this relation to project.使用这种方法,我们需要先上传项目资产,然后将此关系添加到项目中。

  1. Store relation in ProjectAsset itself.将关系存储在 ProjectAsset 本身中。

    Project项目

    name姓名

    ProjectAsset项目资产

    image group relation project simple relation to project.图像组关系项目与项目的简单关系。

    Group团体

    name姓名

with this approach, we specity relations(project, group relation) when we upload project asset.使用这种方法,我们在上传项目资产时指定关系(项目、组关系)。

what I want to do我想做的事

  1. when delete project, the project asset should be deleted as well.删除项目时,项目资产也应删除。 does ezplatform support embed association like doctrine orm? ezplatform 是否支持像 doctrine orm 这样的嵌入关联?

  2. when query project, I also need to get the project assets.在查询项目时,我还需要获取项目资产。 what is the efficient way to do this?这样做的有效方法是什么? the query might be for a single project or a lists of project. query可能针对单个项目或项目列表。

Hi "out of the box" it's not possible but of course there is a solution for that.嗨,“开箱即用”这是不可能的,但当然有解决方案。 It requires some developpement though What I would do is add an EventListener (or EventSubscriber) plugged on specific object type deletion so it triggers the appropriate deletions of related objects.它需要一些开发,但我要做的是添加一个插入特定 object 类型删除的 EventListener(或 EventSubscriber),以便触发相关对象的适当删除。

https://symfony.com/doc/current/event_dispatcher.html https://symfony.com/doc/current/event_dispatcher.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM