1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\DashboardBundle\Repository; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityRepository; |
6
|
|
|
use Kunstmaan\DashboardBundle\Entity\AnalyticsConfig; |
7
|
|
|
use Kunstmaan\DashboardBundle\Entity\AnalyticsOverview; |
8
|
|
|
use Kunstmaan\DashboardBundle\Entity\AnalyticsSegment; |
9
|
|
|
|
10
|
|
|
class AnalyticsOverviewRepository extends EntityRepository |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Get then default overviews (without a segment) |
14
|
|
|
* |
15
|
|
|
* @return array |
16
|
|
|
*/ |
17
|
|
|
public function getDefaultOverviews($config = false) |
18
|
|
|
{ |
19
|
|
|
$em = $this->getEntityManager(); |
20
|
|
|
$dql = 'SELECT o FROM KunstmaanDashboardBundle:AnalyticsOverview o WHERE o.segment IS NULL'; |
21
|
|
|
if ($config) { |
22
|
|
|
$dql .= " AND o.config = $config"; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
$query = $em->createQuery($dql); |
26
|
|
|
|
27
|
|
|
return $query->getResult(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Add overviews for a config and optionally a segment |
32
|
|
|
* |
33
|
|
|
* @param AnalyticsConfig $config |
34
|
|
|
* @param AnalyticsSegment $segment |
|
|
|
|
35
|
|
|
*/ |
36
|
|
|
public function addOverviews(&$config, &$segment = null) |
37
|
|
|
{ |
38
|
|
|
$em = $this->getEntityManager(); |
39
|
|
|
|
40
|
|
|
$today = new AnalyticsOverview(); |
41
|
|
|
$today->setTitle('dashboard.ga.tab.today'); |
42
|
|
|
$today->setTimespan(0); |
43
|
|
|
$today->setStartOffset(0); |
44
|
|
|
$today->setConfig($config); |
|
|
|
|
45
|
|
|
$today->setSegment($segment); |
|
|
|
|
46
|
|
|
$em->persist($today); |
47
|
|
|
|
48
|
|
|
$yesterday = new AnalyticsOverview(); |
49
|
|
|
$yesterday->setTitle('dashboard.ga.tab.yesterday'); |
50
|
|
|
$yesterday->setTimespan(1); |
51
|
|
|
$yesterday->setStartOffset(1); |
52
|
|
|
$yesterday->setConfig($config); |
|
|
|
|
53
|
|
|
$yesterday->setSegment($segment); |
|
|
|
|
54
|
|
|
$em->persist($yesterday); |
55
|
|
|
|
56
|
|
|
$week = new AnalyticsOverview(); |
57
|
|
|
$week->setTitle('dashboard.ga.tab.last_7_days'); |
58
|
|
|
$week->setTimespan(7); |
59
|
|
|
$week->setStartOffset(1); |
60
|
|
|
$week->setConfig($config); |
|
|
|
|
61
|
|
|
$week->setSegment($segment); |
|
|
|
|
62
|
|
|
$em->persist($week); |
63
|
|
|
|
64
|
|
|
$month = new AnalyticsOverview(); |
65
|
|
|
$month->setTitle('dashboard.ga.tab.last_30_days'); |
66
|
|
|
$month->setTimespan(30); |
67
|
|
|
$month->setStartOffset(1); |
68
|
|
|
$month->setConfig($config); |
|
|
|
|
69
|
|
|
$month->setSegment($segment); |
|
|
|
|
70
|
|
|
$em->persist($month); |
71
|
|
|
|
72
|
|
|
$year = new AnalyticsOverview(); |
73
|
|
|
$year->setTitle('dashboard.ga.tab.last_12_months'); |
74
|
|
|
$year->setTimespan(365); |
75
|
|
|
$year->setStartOffset(1); |
76
|
|
|
$year->setConfig($config); |
|
|
|
|
77
|
|
|
$year->setSegment($segment); |
|
|
|
|
78
|
|
|
$em->persist($year); |
79
|
|
|
|
80
|
|
|
$yearToDate = new AnalyticsOverview(); |
81
|
|
|
$yearToDate->setTitle('dashboard.ga.tab.year_to_date'); |
82
|
|
|
$yearToDate->setTimespan(365); |
83
|
|
|
$yearToDate->setStartOffset(1); |
84
|
|
|
$yearToDate->setConfig($config); |
|
|
|
|
85
|
|
|
$yearToDate->setSegment($segment); |
|
|
|
|
86
|
|
|
$yearToDate->setUseYear(true); |
|
|
|
|
87
|
|
|
$em->persist($yearToDate); |
88
|
|
|
|
89
|
|
|
$em->flush(); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.