我對服務,實體和存儲庫有點困惑,我應該在什麼地方放置什麼工作。我想我錯過了一些東西,我擔心我會以錯誤的方式去做。我不認爲原則映射表名稱是理想的報告,因爲有很多列和列往往是其他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