class-wpml-tm-jobs-summary-report-process-factory.php
2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
class WPML_TM_Jobs_Summary_Report_Process_Factory {
/** @var WPML_TM_Jobs_Summary_Report_View $template */
private $template;
/** @var WPML_TM_Jobs_Summary_Report_Process $weekly_report */
private $weekly_report;
/** @var WPML_TM_Jobs_Summary_Report_Process $daily_report */
private $daily_report;
/**
* @return WPML_TM_Jobs_Summary_Report_Process
*/
public function create_weekly_report() {
if ( ! $this->weekly_report ) {
$summary_report = $this->get_summary_report( WPML_TM_Jobs_Summary::WEEKLY_REPORT );
$this->weekly_report = new WPML_TM_Jobs_Summary_Report_Process(
$this->get_template(),
new WPML_TM_Jobs_Weekly_Summary_Report_Model(),
$summary_report->get_jobs()
);
}
return $this->weekly_report;
}
/**
* @return WPML_TM_Jobs_Summary_Report_Process
*/
public function create_daily_report() {
if ( ! $this->daily_report ) {
$summary_report = $this->get_summary_report( WPML_TM_Jobs_Summary::DAILY_REPORT );
$this->daily_report = new WPML_TM_Jobs_Summary_Report_Process(
$this->get_template(),
new WPML_TM_Jobs_Daily_Summary_Report_Model(),
$summary_report->get_jobs()
);
}
return $this->daily_report;
}
/**
* @param string $frequency
*
* @return WPML_TM_Jobs_Summary_Report
*/
private function get_summary_report( $frequency ) {
global $sitepress, $wpdb;
$word_count_records_factory = new WPML_TM_Word_Count_Records_Factory();
$word_count_records = $word_count_records_factory->create();
$single_process_factory = new WPML_TM_Word_Count_Single_Process_Factory();
$single_process = $single_process_factory->create();
return new WPML_TM_Jobs_Summary_Report(
new WPML_Translation_Jobs_Collection( $wpdb, array() ),
new WPML_TM_String( false, $word_count_records, $single_process ),
new WPML_TM_Post( false, $word_count_records, $single_process ),
$frequency,
new WPML_Translation_Element_Factory( $sitepress )
);
}
/**
* @return WPML_TM_Jobs_Summary_Report_View
*/
private function get_template() {
if ( ! $this->template ) {
$template_service_factory = new WPML_TM_Email_Twig_Template_Factory();
$this->template = new WPML_TM_Jobs_Summary_Report_View( $template_service_factory->create() );
}
return $this->template;
}
}