我对服务,实体和存储库有点困惑,我应该在什么地方放置什么工作。我想我错过了一些东西,我担心我会以错误的方式去做。我不认为原则映射表名称是理想的报告,因为有很多列和列往往是其他groupby在日期,月份等的结果。symfony2实体,存储库,服务混淆
项目简要概述是一个基于Web的集合报告(作为捆绑)。
为了创建报告,我必须使用销售日记帐包预先生成数据。销售日志从事务数据库中提取数据,并将其放入表中,准备好由各种其他报告运行,即具有自定义索引等的数据。数据聚合是解释它的更好方式。数据来源有几百万的预订数据回去年,所以它的效率不高直接根源,使多数民众赞成在销售杂志进来的基础报告。
SalesJournalBundle - fetches data from source and puts it into a table ready for other reports
WeeklyConversionReportBundle - exports sales journal into weekly conversion report table has functions for totals for the week, totals for month, etc
OtherReportBundle - etc
salesJournal
类运行销售杂志和从大表导出到另一个表。
createQuery($parameters);
runQuery($exportTableName);
WeeklyConversionBundle
// runs the sales journal and saves to the report. Entity? Or Service or Repoistory?
runSalesJournalQuery();
// generates conversion figures and saves the to the table? Entity Or Service or Repoistory?
generateConversions();
getWeekTotals(); // used when displaying the report..
getMonthTotals($month) // used when displaying the report..
getTotals() // used when displaying the report..
etc.
所以,当我开始这个项目我认为所有的功能在实体类属于..但林不知道他们是严格的模型,因为他们需要数据库访问和访问其他类?混淆类/方法的放置位置。任何反馈将不胜感激。
感谢您的回复。我认为关键字运行有帮助。销售日志查询的运行必须是服务。当你扩展仓库时,这意味着你必须使用doctrine sql吗? – 2013-03-07 14:30:39
存储库是由教条提供的用于管理查询的类。您可以通过添加自定义方法来扩展它。 – 2013-03-07 14:34:52
如何将依赖项添加到服务中以便我可以运行查询? – 2013-03-07 14:53:30