Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
reportdispatcher.php
1<?php
2
4
11
17{
18 private $view;
19 private $report;
20 private $errors = array();
21
25 public function getReportCompatibleData()
26 {
27 if (!$this->getView())
28 {
29 $this->errors[] = new Error("Set view to get data");
30 return null;
31 }
32 if (!$this->getReport())
33 {
34 $this->errors[] = new Error("Set report to get data");
35 return null;
36 }
37
38 $compatibleDataType = $this->getView()->getCompatibleDataType();
39 $result = array();
40
41 if(!isset(Common::$reportImplementationTypesMap[$compatibleDataType]))
42 {
43 $this->errors[] = new Error("No isset : '" . $compatibleDataType . "' compatible data type.'");
44 return null;
45 }
46 else
47 {
48 $reportHandler = $this->getReport()->getReportHandler();
49 if (!$reportHandler->isEnabled())
50 {
51 return null;
52 }
53
54 $reportHandler->setView($this->getView());
55 if ($reportHandler instanceof Common::$reportImplementationTypesMap[$compatibleDataType]['interface'])
56 {
57 if (!Dashboard::getBoardModeIsDemo($this->getReport()->getWidget()->getBoardId()))
58 {
59 $reportHandler->setCalculatedData($reportHandler->prepare());
60 $getDataMethodName = Common::$reportImplementationTypesMap[$compatibleDataType]['method'];
61 $result = $reportHandler->{$getDataMethodName}();
62 }
63 else
64 {
65 $getDemoDataMethodName = Common::$reportImplementationTypesMap[$compatibleDataType]['demoMethod'];
66 $result = $reportHandler->{$getDemoDataMethodName}();
67 }
68 }
69 elseif ($reportHandler::getClassName() === BaseReport::getClassName())
70 {
71 $getDataMethodName = Common::$reportImplementationTypesMap[$compatibleDataType]['method'];
72 if (method_exists($reportHandler, $getDataMethodName))
73 {
74 $result = $reportHandler->{$getDataMethodName}();
75 }
76 else
77 {
78 $result = array();
79 }
80
81 }
82 else
83 {
84 $this->errors[] = new Error('Report handler ' . $reportHandler::getClassName() . ' does not implement a compatible interface');
85 return null;
86 }
87 }
88
89
90 return $result;
91 }
92
96 public function getErrors()
97 {
98 return $this->errors;
99 }
100
104 public function getView()
105 {
106 return $this->view;
107 }
108
113 public function setView(View $view)
114 {
115 $this->view = $view;
116 }
117
121 public function getReport()
122 {
123 return $this->report;
124 }
125
130 public function setReport($report)
131 {
132 $this->report = $report;
133 }
134}